Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible USB Configuration and optimize sam3u2c_if #1041

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/hic/sam3u2c.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Based on ATSAM3U2C chip ([Datasheet](https://ww1.microchip.com/downloads/en/Devi
- Cortex-M3 96 Mhz
- 128 KB Flash
- 36 KB RAM
- High-speed USB 2.0 device controller: up to 7 bi-directional endpoints including EP0 (*)
- High-speed USB 2.0 device controller: up to 7 endpoints including EP0 (*)
- LQFP100 packaging

(*) "up to 7 bidirectional Endpoints" (source: Datasheet](https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6430-32-bit-Cortex-M3-Microcontroller-SAM3U4-SAM3U2-SAM3U1_Datasheet.pdf))
Expand Down
2 changes: 2 additions & 0 deletions projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ projects:
sam3u2c_if:
- *module_if
- *module_hic_sam3u2c
- records/usb/usb-bulk.yaml
- records/board/sam3u2c_if.yaml
- records/family/all_family.yaml
stm32f072x8_if:
- *module_if
Expand Down
5 changes: 5 additions & 0 deletions records/board/sam3u2c_if.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
common:
macros:
- HID_ENDPOINT_DISABLE
- MSC_ENDPOINT_DISABLE
- DRAG_N_DROP_DISABLE
4 changes: 2 additions & 2 deletions source/board/microbitv2/microbitv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "gpio_extra.h"
#include "board_id.h"

#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
#include "flash_intf.h"
#endif

Expand Down Expand Up @@ -155,7 +155,7 @@ static void reset_power_led_state()
// Handle the reset button behavior, this function is called in the main task every 30ms
void handle_reset_button()
{
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
if (!flash_intf_target->flash_busy()) //added checking if flashing on target is in progress
#endif
{
Expand Down
10 changes: 6 additions & 4 deletions source/daplink/cmsis-dap/DAP_vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
#include "uart.h"
#include "settings.h"
#include "target_family.h"
#include "flash_manager.h"
#include <string.h>
#include "daplink_vendor_commands.h"

#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
#include "file_stream.h"
#include "flash_manager.h"
#endif

//**************************************************************************************************
Expand Down Expand Up @@ -76,6 +76,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += (len + 1); // increment response count by ID length + length byte
break;
}
#if defined(CDC_ENDPOINT) && !defined(CDC_ENDPOINT_DISABLE)
case ID_DAP_UART_GetLineCoding: {
// get line coding
int32_t read_len = sizeof(CDC_LINE_CODING);
Expand Down Expand Up @@ -121,6 +122,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += ((write_len + 1) << 16) | 1;
break;
}
#endif
case ID_DAP_Vendor5: break;
case ID_DAP_Vendor6: break;
case ID_DAP_Vendor7: break;
Expand All @@ -145,7 +147,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += 1;
break;
}
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
case ID_DAP_MSD_Open: {
// open mass storage device stream
*response = stream_open((stream_type_t)(*request));
Expand All @@ -167,7 +169,6 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += ((write_len + 1) << 16) | 1;
break;
}
#endif
case ID_DAP_SelectEraseMode: {
// switching between chip erase and page erase
// COMMAND(OUT Packet)
Expand All @@ -187,6 +188,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += (1U << 16) | 1U; // increment request and response count each by 1
break;
}
#endif
case ID_DAP_Vendor14: break;
case ID_DAP_Vendor15: break;
case ID_DAP_Vendor16: break;
Expand Down
4 changes: 4 additions & 0 deletions source/daplink/drag-n-drop/file_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <string.h>

#include "file_stream.h"
Expand Down Expand Up @@ -364,3 +366,5 @@ static error_t close_hex(void *state)
status = flash_decoder_close();
return status;
}

#endif
6 changes: 5 additions & 1 deletion source/daplink/drag-n-drop/flash_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <string.h>

#include "flash_decoder.h"
Expand Down Expand Up @@ -292,7 +294,7 @@ error_t flash_decoder_write(uint32_t addr, const uint8_t *data, uint32_t size)
state = DECODER_STATE_ERROR;
return status;
}

// Validate incompatible target image file
if (config_get_detect_incompatible_target()){
status = flash_decoder_validate_target_image(flash_type, flash_buf, flash_buf_pos);
Expand Down Expand Up @@ -423,3 +425,5 @@ static bool flash_decoder_is_at_end(uint32_t addr, const uint8_t *data, uint32_t
return false;
}
}

#endif
4 changes: 4 additions & 0 deletions source/daplink/drag-n-drop/flash_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include "flash_intf.h"
#include "compiler.h"

__WEAK const flash_intf_t *const flash_intf_iap_protected = 0;
__WEAK const flash_intf_t *const flash_intf_target = 0;
__WEAK const flash_intf_t *const flash_intf_target_custom = 0;

#endif
5 changes: 4 additions & 1 deletion source/daplink/drag-n-drop/flash_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
* Copyright 2019, Cypress Semiconductor Corporation
* Copyright 2019, Cypress Semiconductor Corporation
* or a subsidiary of Cypress Semiconductor Corporation.
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -21,6 +21,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include "flash_manager.h"
#include "util.h"
#include "error.h"
Expand Down Expand Up @@ -348,3 +350,4 @@ static error_t setup_next_sector(uint32_t addr)
current_write_block_size, current_sector_size, min_prog_size);
return ERROR_SUCCESS;
}
#endif
4 changes: 4 additions & 0 deletions source/daplink/drag-n-drop/iap_flash_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <string.h>

#include "daplink.h"
Expand Down Expand Up @@ -505,3 +507,5 @@ static error_t critical_erase_and_program(uint32_t addr, const uint8_t *data, ui
static uint8_t target_flash_busy(void){
return (state == STATE_OPEN);
}

#endif
4 changes: 4 additions & 0 deletions source/daplink/drag-n-drop/intelhex.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <string.h>

#include "intelhex.h"
Expand Down Expand Up @@ -276,3 +278,5 @@ hexfile_parse_status_t parse_hex_blob(const uint8_t *hex_blob, const uint32_t he
#elif defined(__GNUC__) && !defined(__ARMCC_VERSION)
#pragma GCC pop_options
#endif

#endif
6 changes: 5 additions & 1 deletion source/daplink/drag-n-drop/vfs_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <ctype.h>

#include "daplink.h"
Expand Down Expand Up @@ -116,7 +118,7 @@ static const file_transfer_state_t default_transfer_state = {
};

//Compile option not to include MSC at all, these will be dummy variables
#ifndef MSC_ENDPOINT
#if !defined(MSC_ENDPOINT) || defined(MSC_ENDPOINT_DISABLE)
BOOL USBD_MSC_MediaReady = __FALSE;
BOOL USBD_MSC_ReadOnly = __FALSE;
U32 USBD_MSC_MemorySize;
Expand Down Expand Up @@ -845,3 +847,5 @@ static void transfer_update_state(error_t status)
vfs_mngr_fs_remount();
}
}

#endif
4 changes: 4 additions & 0 deletions source/daplink/drag-n-drop/vfs_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <stdbool.h>
#include <ctype.h>
#include <string.h>
Expand Down Expand Up @@ -700,3 +702,5 @@ static void erase_target(void)
flash_intf_target->erase_chip();
flash_intf_target->uninit();
}

#endif
4 changes: 4 additions & 0 deletions source/daplink/drag-n-drop/virtual_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* limitations under the License.
*/

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <string.h>

#include "virtual_fs.h"
Expand Down Expand Up @@ -741,3 +743,5 @@ static bool filename_character_valid(char character)
// All of the checks have passed so this is a valid file name character
return true;
}

#endif
4 changes: 2 additions & 2 deletions source/daplink/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ static void setup_basics(void)
//Family ID
string_family_id[idx++] = hex_to_ascii(((family_id >> 12) & 0xF));
string_family_id[idx++] = hex_to_ascii(((family_id >> 8) & 0xF));
#if !(defined(DAPLINK_BL)) && defined(DRAG_N_DROP_SUPPORT) //need to change the unique id when the msd is disabled
#if !(defined(DAPLINK_BL)) && defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
// Need to change the unique id when the msd is disabled
#if defined(MSC_ENDPOINT)
if (config_ram_get_disable_msd() == 1 || flash_algo_valid()==0){
string_family_id[idx++] = hex_to_ascii((((family_id >> 4) | 0x08) & 0xF));
Expand Down Expand Up @@ -321,4 +322,3 @@ uint32_t info_get_interface_version(void)

return info_if->version;
}

3 changes: 2 additions & 1 deletion source/daplink/interface/bootloader_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* limitations under the License.
*/

#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <stdbool.h>
#include <string.h>
#include "flash_manager.h"
Expand Down
2 changes: 1 addition & 1 deletion source/daplink/interface/daplink.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "daplink.h"

#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include "virtual_fs.h"
#include "compiler.h"
Expand Down
14 changes: 8 additions & 6 deletions source/daplink/interface/main_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "target_family.h"
#include "target_board.h"

#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
#include "vfs_manager.h"
#include "flash_intf.h"
#include "flash_manager.h"
Expand Down Expand Up @@ -156,7 +156,7 @@ __WEAK void handle_reset_button(void)

// handle reset button without eventing
if (!reset_pressed && gpio_get_reset_btn_fwrd()) {
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
if (!flash_intf_target->flash_busy()) //added checking if flashing on target is in progress
#endif
{
Expand Down Expand Up @@ -314,7 +314,7 @@ void main_task(void * arg)
swd_set_reset_connect(CONNECT_UNDER_RESET);
}
if (g_board_info.flags & kEnablePageErase) {
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
flash_manager_set_page_erase(true);
#endif
}
Expand All @@ -325,7 +325,7 @@ void main_task(void * arg)
bootloader_check_and_update();
// USB
usbd_init();
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
vfs_mngr_fs_enable((config_ram_get_disable_msd()==0));
#endif
usbd_connect(0);
Expand Down Expand Up @@ -384,17 +384,19 @@ void main_task(void * arg)
target_set_state(NO_DEBUG);
}

#if defined(CDC_ENDPOINT) && !defined(CDC_ENDPOINT_DISABLE)
if (flags & FLAGS_MAIN_CDC_EVENT) {
cdc_process_event();
}

#endif

if (flags & FLAGS_BOARD_EVENT) {
board_custom_event();
}

if (flags & FLAGS_MAIN_90MS) {
// Update USB busy status
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
vfs_mngr_periodic(90); // FLAGS_MAIN_90MS
#endif
// Update USB connect status
Expand Down
6 changes: 4 additions & 2 deletions source/daplink/interface/target_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
* Copyright 2019, Cypress Semiconductor Corporation
* Copyright 2019, Cypress Semiconductor Corporation
* or a subsidiary of Cypress Semiconductor Corporation.
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -20,7 +20,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef DRAG_N_DROP_SUPPORT

#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)

#include <string.h>

#include "target_config.h"
Expand Down
7 changes: 5 additions & 2 deletions source/daplink/usb2uart/usbd_user_cdc_acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
* limitations under the License.
*/

#if defined(CDC_ENDPOINT) && !defined(CDC_ENDPOINT_DISABLE)

#include "cmsis_os2.h"
#include "rl_usb.h"
#include "daplink.h"
#include DAPLINK_MAIN_HEADER
#include "uart.h"
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
#include "flash_intf.h"
#endif
#include "target_family.h"
Expand Down Expand Up @@ -122,7 +124,7 @@ static U32 start_break_time = 0;
int32_t USBD_CDC_ACM_SendBreak(usbd_cdc_num_t cdc_num, uint16_t dur)
{
uint32_t end_break_time;
#ifdef DRAG_N_DROP_SUPPORT
#if defined(DRAG_N_DROP_SUPPORT) && !defined(DRAG_N_DROP_DISABLE)
if (!flash_intf_target->flash_busy())
#endif
{ //added checking if flashing on target is in progress
Expand Down Expand Up @@ -203,3 +205,4 @@ void cdc_process_event(void)
}

#endif
#endif
Loading
Loading