diff --git a/source/daplink/bootloader/main.h b/source/daplink/bootloader/main.h index 8715861cf..c52bedd40 100644 --- a/source/daplink/bootloader/main.h +++ b/source/daplink/bootloader/main.h @@ -3,7 +3,7 @@ * @brief * * DAPLink Interface Firmware - * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved + * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -22,11 +22,7 @@ #ifndef MAIN_H #define MAIN_H -#include "stdint.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include /** * @enum main_usb_busy_t @@ -59,6 +55,10 @@ typedef enum { MAIN_LED_FLASH_PERMANENT } main_led_state_t; +#ifdef __cplusplus +extern "C" { +#endif + /** * Allows other parts of the program to request the device to eject physical media * @param none diff --git a/source/daplink/circ_buf.c b/source/daplink/circ_buf.c index 3a40828eb..9f191d9b7 100644 --- a/source/daplink/circ_buf.c +++ b/source/daplink/circ_buf.c @@ -22,7 +22,6 @@ #include "circ_buf.h" #include "cortex_m.h" -#include "macro.h" #include "util.h" void circ_buf_init(circ_buf_t *circ_buf, uint8_t *buffer, uint32_t size) @@ -74,7 +73,7 @@ uint8_t circ_buf_pop(circ_buf_t *circ_buf) } cortex_int_restore(state); - + return data; } @@ -94,7 +93,7 @@ uint32_t circ_buf_count_used(circ_buf_t *circ_buf) cortex_int_restore(state); return cnt; } - + uint32_t circ_buf_count_free(circ_buf_t *circ_buf) { uint32_t cnt; diff --git a/source/daplink/circ_buf.h b/source/daplink/circ_buf.h index 4e1a36f4f..245abbdff 100644 --- a/source/daplink/circ_buf.h +++ b/source/daplink/circ_buf.h @@ -22,8 +22,8 @@ #ifndef CIRC_BUF_H #define CIRC_BUF_H -#include "stdbool.h" -#include "stdint.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/source/daplink/cortex_m.h b/source/daplink/cortex_m.h index f5443dfe0..e1a77ca67 100644 --- a/source/daplink/cortex_m.h +++ b/source/daplink/cortex_m.h @@ -22,8 +22,8 @@ #ifndef CORTEX_M_H #define CORTEX_M_H -#include "stdint.h" -#include "stdbool.h" +#include +#include #include "IO_Config.h" diff --git a/source/daplink/crc.h b/source/daplink/crc.h index ec343d4d8..dafb5ae6c 100644 --- a/source/daplink/crc.h +++ b/source/daplink/crc.h @@ -21,7 +21,7 @@ #ifndef _crc_h #define _crc_h -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/daplink/daplink.h b/source/daplink/daplink.h index 0fd27f89f..44fa1a82a 100644 --- a/source/daplink/daplink.h +++ b/source/daplink/daplink.h @@ -22,8 +22,8 @@ #ifndef DAPLINK_H #define DAPLINK_H -#include "stdbool.h" -#include "stdint.h" +#include +#include #include "daplink_addr.h" #include "compiler.h" diff --git a/source/daplink/daplink_debug.h b/source/daplink/daplink_debug.h index 0101266ce..3fa67aec0 100644 --- a/source/daplink/daplink_debug.h +++ b/source/daplink/daplink_debug.h @@ -22,13 +22,13 @@ #ifndef DAPLINK_DEBUG_H #define DAPLINK_DEBUG_H -#include "stdarg.h" -#include "stdio.h" -#include "string.h" -#include "stdint.h" +#include +#include +#include +#include #include "cmsis_os2.h" #include "rl_usb.h" -#include "macro.h" +#include "util.h" #ifdef __cplusplus extern "C" { diff --git a/source/daplink/drag-n-drop/file_stream.c b/source/daplink/drag-n-drop/file_stream.c index 2ef69692d..284ccc9f8 100644 --- a/source/daplink/drag-n-drop/file_stream.c +++ b/source/daplink/drag-n-drop/file_stream.c @@ -19,11 +19,10 @@ * limitations under the License. */ -#include "string.h" +#include #include "file_stream.h" #include "util.h" -#include "macro.h" #include "intelhex.h" #include "flash_decoder.h" #include "error.h" @@ -80,7 +79,7 @@ stream_t stream[] = { {detect_bin, open_bin, write_bin, close_bin}, // STREAM_TYPE_BIN {detect_hex, open_hex, write_hex, close_hex}, // STREAM_TYPE_HEX }; -COMPILER_ASSERT(ELEMENTS_IN_ARRAY(stream) == STREAM_TYPE_COUNT); +COMPILER_ASSERT(ARRAY_SIZE(stream) == STREAM_TYPE_COUNT); // STREAM_TYPE_NONE must not be included in count COMPILER_ASSERT(STREAM_TYPE_NONE > STREAM_TYPE_COUNT); diff --git a/source/daplink/drag-n-drop/file_stream.h b/source/daplink/drag-n-drop/file_stream.h index 95378ebd4..50bf38e08 100644 --- a/source/daplink/drag-n-drop/file_stream.h +++ b/source/daplink/drag-n-drop/file_stream.h @@ -22,7 +22,7 @@ #ifndef FILE_STREAM_H #define FILE_STREAM_H -#include "stdint.h" +#include #include "virtual_fs.h" #include "error.h" diff --git a/source/daplink/drag-n-drop/flash_decoder.c b/source/daplink/drag-n-drop/flash_decoder.c index e0dcd2a80..3854f57e2 100644 --- a/source/daplink/drag-n-drop/flash_decoder.c +++ b/source/daplink/drag-n-drop/flash_decoder.c @@ -19,11 +19,10 @@ * limitations under the License. */ -#include "string.h" +#include #include "flash_decoder.h" #include "util.h" -#include "macro.h" #include "daplink.h" #include "flash_manager.h" #include "target_config.h" // for target_device @@ -353,7 +352,7 @@ static bool flash_decoder_is_at_end(uint32_t addr, const uint8_t *data, uint32_t case FLASH_DECODER_TYPE_INTERFACE: end_addr = DAPLINK_ROM_IF_START + DAPLINK_ROM_IF_SIZE; break; - + case FLASH_DECODER_TYPE_TARGET: //only if we are sure it is a bin for the target; without check unordered hex files will cause to terminate flashing if (flash_type_target_bin && g_board_info.target_cfg) { @@ -367,7 +366,7 @@ static bool flash_decoder_is_at_end(uint32_t addr, const uint8_t *data, uint32_t if(end_addr == 0){ //invalid end_addr return false; } - + } else { return false; diff --git a/source/daplink/drag-n-drop/flash_decoder.h b/source/daplink/drag-n-drop/flash_decoder.h index 97b1ba122..2895c93d0 100644 --- a/source/daplink/drag-n-drop/flash_decoder.h +++ b/source/daplink/drag-n-drop/flash_decoder.h @@ -22,8 +22,8 @@ #ifndef FLASH_DECODER_H #define FLASH_DECODER_H -#include "stdint.h" -#include "stdbool.h" +#include +#include #include "flash_intf.h" #include "error.h" diff --git a/source/daplink/drag-n-drop/flash_intf.h b/source/daplink/drag-n-drop/flash_intf.h index c1f55eeef..68d80bc02 100644 --- a/source/daplink/drag-n-drop/flash_intf.h +++ b/source/daplink/drag-n-drop/flash_intf.h @@ -22,7 +22,7 @@ #ifndef FLASH_INTF_H #define FLASH_INTF_H -#include "stdint.h" +#include #include "error.h" diff --git a/source/daplink/drag-n-drop/flash_manager.c b/source/daplink/drag-n-drop/flash_manager.c index 022e82695..b07546640 100755 --- a/source/daplink/drag-n-drop/flash_manager.c +++ b/source/daplink/drag-n-drop/flash_manager.c @@ -19,12 +19,8 @@ * limitations under the License. */ -#include "string.h" -#include "stdbool.h" - #include "flash_manager.h" #include "util.h" -#include "macro.h" #include "error.h" // Set to 1 to enable debugging @@ -97,7 +93,7 @@ error_t flash_manager_init(const flash_intf_t *flash_intf) return status; } - if (!page_erase_enabled) { + if (!page_erase_enabled) { // Erase flash and unint if there are errors status = intf->erase_chip(); flash_manager_printf(" intf->erase_chip ret=%i\r\n", status); @@ -136,16 +132,16 @@ error_t flash_manager_data(uint32_t addr, const uint8_t *data, uint32_t size) current_sector_valid = true; last_addr = addr; } - + //non-increasing address support - if (ROUND_DOWN(addr, current_write_block_size) != ROUND_DOWN(last_addr, current_write_block_size)) { + if (ROUND_DOWN(addr, current_write_block_size) != ROUND_DOWN(last_addr, current_write_block_size)) { status = flush_current_block(addr); if (ERROR_SUCCESS != status) { state = STATE_ERROR; return status; } } - + if (ROUND_DOWN(addr, current_sector_size) != ROUND_DOWN(last_addr, current_sector_size)) { status = setup_next_sector(addr); if (ERROR_SUCCESS != status) { @@ -273,7 +269,7 @@ static bool flash_intf_valid(const flash_intf_t *flash_intf) if (0 == flash_intf->erase_sector_size) { return false; } - + if (0 == flash_intf->flash_busy) { return false; } @@ -329,7 +325,7 @@ static error_t setup_next_sector(uint32_t addr) return status; } } - + if (page_erase_enabled) { // Erase the current sector status = intf->erase_sector(current_sector_addr); @@ -337,7 +333,7 @@ static error_t setup_next_sector(uint32_t addr) if (ERROR_SUCCESS != status) { intf->uninit(); return status; - } + } } // Clear out buffer in case block size changed diff --git a/source/daplink/drag-n-drop/flash_manager.h b/source/daplink/drag-n-drop/flash_manager.h index 8928d158e..853e8719e 100644 --- a/source/daplink/drag-n-drop/flash_manager.h +++ b/source/daplink/drag-n-drop/flash_manager.h @@ -22,8 +22,8 @@ #ifndef FLASH_MANAGER_H #define FLASH_MANAGER_H -#include "stdint.h" -#include "stdbool.h" +#include +#include #include "flash_intf.h" #include "error.h" diff --git a/source/daplink/drag-n-drop/iap_flash_intf.c b/source/daplink/drag-n-drop/iap_flash_intf.c index 051750ee5..dd9db6e56 100644 --- a/source/daplink/drag-n-drop/iap_flash_intf.c +++ b/source/daplink/drag-n-drop/iap_flash_intf.c @@ -29,7 +29,6 @@ #include "compiler.h" #include "crc.h" #include "info.h" -#include "macro.h" // Application start must be aligned to page write COMPILER_ASSERT(DAPLINK_ROM_APP_START % DAPLINK_MIN_WRITE_SIZE == 0); diff --git a/source/daplink/drag-n-drop/intelhex.c b/source/daplink/drag-n-drop/intelhex.c index 56f8c7ae6..58f7c7883 100644 --- a/source/daplink/drag-n-drop/intelhex.c +++ b/source/daplink/drag-n-drop/intelhex.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "intelhex.h" @@ -136,7 +136,7 @@ hexfile_parse_status_t parse_hex_blob(const uint8_t *hex_blob, const uint32_t he default: if (low_nibble) { line.buf[idx] |= ctoh((uint8_t)(*hex_blob)) & 0xf; - if (++idx >= (line.byte_count + 5)) { //all data in + if (++idx >= (line.byte_count + 5)) { //all data in if (0 == validate_checksum(&line)) { status = HEX_PARSE_CKSUM_FAIL; goto hex_parser_exit; @@ -201,7 +201,7 @@ hexfile_parse_status_t parse_hex_blob(const uint8_t *hex_blob, const uint32_t he break; } } - } + } } } else { if (idx < sizeof(hex_line_t)) { diff --git a/source/daplink/drag-n-drop/intelhex.h b/source/daplink/drag-n-drop/intelhex.h index d5ad93795..d1b2409ad 100644 --- a/source/daplink/drag-n-drop/intelhex.h +++ b/source/daplink/drag-n-drop/intelhex.h @@ -26,7 +26,7 @@ * @{ */ -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/daplink/drag-n-drop/vfs_manager.c b/source/daplink/drag-n-drop/vfs_manager.c index e657995b8..a2941eede 100644 --- a/source/daplink/drag-n-drop/vfs_manager.c +++ b/source/daplink/drag-n-drop/vfs_manager.c @@ -19,8 +19,7 @@ * limitations under the License. */ -#include "stdbool.h" -#include "ctype.h" +#include #include "main.h" #include "cmsis_os2.h" @@ -635,7 +634,7 @@ static void transfer_reset_file_info() file_transfer_state = default_transfer_state; abort_remount(); } - + } // Update the tranfer state with new information diff --git a/source/daplink/drag-n-drop/vfs_manager.h b/source/daplink/drag-n-drop/vfs_manager.h index 27fb536ca..4f2104fab 100644 --- a/source/daplink/drag-n-drop/vfs_manager.h +++ b/source/daplink/drag-n-drop/vfs_manager.h @@ -22,8 +22,8 @@ #ifndef VFS_MANAGER_USER_H #define VFS_MANAGER_USER_H -#include "stdint.h" -#include "stdbool.h" +#include +#include #include "virtual_fs.h" #include "error.h" diff --git a/source/daplink/drag-n-drop/vfs_user.c b/source/daplink/drag-n-drop/vfs_user.c index 72235161a..09d33bf05 100644 --- a/source/daplink/drag-n-drop/vfs_user.c +++ b/source/daplink/drag-n-drop/vfs_user.c @@ -19,13 +19,12 @@ * limitations under the License. */ -#include "stdbool.h" -#include "ctype.h" -#include "string.h" +#include +#include +#include #include "vfs_user.h" #include "vfs_manager.h" -#include "macro.h" #include "error.h" #include "util.h" #include "settings.h" @@ -37,9 +36,11 @@ #include "cortex_m.h" #include "target_board.h" -// Must be bigger than 4x the flash size of the biggest supported -// device. This is to accomodate for hex file programming. -static const uint32_t disc_size = MB(64); +//! @brief Size in bytes of the virtual disk. +//! +//! Must be bigger than 4x the flash size of the biggest supported +//! device. This is to accomodate for hex file programming. +#define VFS_DISK_SIZE (MB(64)) //! @brief Constants for magic action or config files. //! @@ -126,14 +127,12 @@ static void erase_target(void); static uint32_t expand_info(uint8_t *buf, uint32_t bufsize); -#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) - void vfs_user_build_filesystem() { uint32_t file_size; vfs_file_t file_handle; // Setup the filesystem based on target parameters - vfs_init(get_daplink_drive_name(), disc_size); + vfs_init(get_daplink_drive_name(), VFS_DISK_SIZE); // MBED.HTM file_size = get_file_size(read_file_mbed_htm); vfs_create_file(get_daplink_url_name(), read_file_mbed_htm, 0, file_size); @@ -387,7 +386,7 @@ static uint32_t read_file_assert_txt(uint32_t sector_offset, uint8_t *data, uint uint32_t * hexdumps = 0; uint8_t valid_hexdumps = 0; uint8_t index = 0; - + if (sector_offset != 0) { return 0; } @@ -425,7 +424,7 @@ static uint32_t read_file_assert_txt(uint32_t sector_offset, uint8_t *data, uint pos += util_write_string(buf + pos, "\r\n"); } } - + return pos; } diff --git a/source/daplink/drag-n-drop/virtual_fs.c b/source/daplink/drag-n-drop/virtual_fs.c index 2dc45115f..94c80bfb3 100644 --- a/source/daplink/drag-n-drop/virtual_fs.c +++ b/source/daplink/drag-n-drop/virtual_fs.c @@ -19,13 +19,12 @@ * limitations under the License. */ -#include "string.h" +#include #include "virtual_fs.h" #include "info.h" #include "settings.h" #include "compiler.h" -#include "macro.h" #include "util.h" // Virtual file system driver @@ -257,7 +256,7 @@ const virtual_media_t virtual_media_tmpl[] = { /* Raw filesystem contents follow */ }; // Keep virtual_media_idx_t in sync with virtual_media_tmpl -COMPILER_ASSERT(MEDIA_IDX_COUNT == ELEMENTS_IN_ARRAY(virtual_media_tmpl)); +COMPILER_ASSERT(MEDIA_IDX_COUNT == ARRAY_SIZE(virtual_media_tmpl)); static const FatDirectoryEntry_t root_dir_entry = { /*uint8_t[11] */ .filename = {""}, @@ -311,7 +310,7 @@ static void write_fat(file_allocation_table_t *fat, uint32_t idx, uint16_t val) high_idx = idx * 2 + 1; // Assert that this is still within the fat table - if (high_idx >= ELEMENTS_IN_ARRAY(fat->f)) { + if (high_idx >= ARRAY_SIZE(fat->f)) { util_assert(0); return; } @@ -349,10 +348,10 @@ void vfs_init(const vfs_filename_t drive_name, uint32_t disk_size) } if (total_sectors >= 0x10000) { mbr.total_logical_sectors = 0; - mbr.big_sectors_on_drive = total_sectors; + mbr.big_sectors_on_drive = total_sectors; } else { mbr.total_logical_sectors = total_sectors; - mbr.big_sectors_on_drive = 0; + mbr.big_sectors_on_drive = 0; } // FAT table will likely be larger than needed, but this is allowed by the // fat specification @@ -366,7 +365,7 @@ void vfs_init(const vfs_filename_t drive_name, uint32_t disk_size) virtual_media_idx = MEDIA_IDX_COUNT; data_start = 0; - for (i = 0; i < ELEMENTS_IN_ARRAY(virtual_media_tmpl); i++) { + for (i = 0; i < ARRAY_SIZE(virtual_media_tmpl); i++) { data_start += virtual_media[i].length; } @@ -424,7 +423,7 @@ vfs_file_t vfs_create_file(const vfs_filename_t filename, vfs_read_cb_t read_cb, } // Update directory entry - if (dir_idx >= ELEMENTS_IN_ARRAY(dir_current.f)) { + if (dir_idx >= ARRAY_SIZE(dir_current.f)) { util_assert(0); return VFS_FILE_INVALID; } @@ -438,7 +437,7 @@ vfs_file_t vfs_create_file(const vfs_filename_t filename, vfs_read_cb_t read_cb, de->first_cluster_low_16 = (first_cluster >> 0) & 0xFFFF; // Update virtual media - if (virtual_media_idx >= ELEMENTS_IN_ARRAY(virtual_media)) { + if (virtual_media_idx >= ARRAY_SIZE(virtual_media)) { util_assert(0); return VFS_FILE_INVALID; } @@ -502,7 +501,7 @@ void vfs_read(uint32_t requested_sector, uint8_t *buf, uint32_t num_sectors) memset(buf, 0, num_sectors * VFS_SECTOR_SIZE); current_sector = 0; - for (i = 0; i < ELEMENTS_IN_ARRAY(virtual_media); i++) { + for (i = 0; i < ARRAY_SIZE(virtual_media); i++) { uint32_t vm_sectors = virtual_media[i].length / VFS_SECTOR_SIZE; uint32_t vm_start = current_sector; uint32_t vm_end = current_sector + vm_sectors; @@ -613,7 +612,7 @@ static uint32_t read_dir(uint32_t sector_offset, uint8_t *data, uint32_t num_sec util_assert(0); return 0; } - + // Zero buffer data is VFS_SECTOR_SIZE max memset(data, 0, VFS_SECTOR_SIZE); diff --git a/source/daplink/drag-n-drop/virtual_fs.h b/source/daplink/drag-n-drop/virtual_fs.h index c95fbb285..581017c8f 100644 --- a/source/daplink/drag-n-drop/virtual_fs.h +++ b/source/daplink/drag-n-drop/virtual_fs.h @@ -22,7 +22,7 @@ #ifndef VIRTUAL_FS_H #define VIRTUAL_FS_H -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/daplink/error.c b/source/daplink/error.c index 9c2d89521..ab2174985 100644 --- a/source/daplink/error.c +++ b/source/daplink/error.c @@ -21,7 +21,6 @@ #include "error.h" #include "util.h" -#include "macro.h" #include "compiler.h" static const char *const error_message[] = { @@ -223,7 +222,7 @@ static error_type_t error_type[] = { ERROR_TYPE_INTERFACE, }; -COMPILER_ASSERT(ERROR_COUNT == ELEMENTS_IN_ARRAY(error_message)); +COMPILER_ASSERT(ERROR_COUNT == ARRAY_SIZE(error_message)); const char *error_get_string(error_t error) { diff --git a/source/daplink/info.h b/source/daplink/info.h index 2460f0933..389725fa1 100644 --- a/source/daplink/info.h +++ b/source/daplink/info.h @@ -22,8 +22,8 @@ #ifndef INFO_H #define INFO_H -#include "stdbool.h" -#include "stdint.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/source/daplink/interface/main.c b/source/daplink/interface/main.c index 09d10ba98..42e3d6499 100644 --- a/source/daplink/interface/main.c +++ b/source/daplink/interface/main.c @@ -19,9 +19,8 @@ * limitations under the License. */ -#include "string.h" -#include "stdio.h" -#include "stdint.h" +#include +#include #include "cmsis_os2.h" #include "rl_usb.h" diff --git a/source/daplink/interface/main.h b/source/daplink/interface/main.h index aac2f7db3..665418e43 100644 --- a/source/daplink/interface/main.h +++ b/source/daplink/interface/main.h @@ -3,7 +3,7 @@ * @brief * * DAPLink Interface Firmware - * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved + * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -22,12 +22,8 @@ #ifndef MAIN_H #define MAIN_H -#include "stdint.h" -#include "stdbool.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include +#include // LED state typedef enum main_led_state { @@ -45,13 +41,14 @@ typedef enum main_usb_connect { USB_DISCONNECTING } main_usb_connect_t; +#ifdef __cplusplus +extern "C" { +#endif + void main_reset_target(uint8_t send_unique_id); void main_usb_set_test_mode(bool enabled); -void main_usb_configure_event(void); -void main_usb_busy_event(void); void main_powerdown_event(void); void main_disable_debug_event(void); -void main_hid_send_event(void); void main_cdc_send_event(void); void main_msc_disconnect_event(void); void main_msc_delay_disconnect_event(void); diff --git a/source/daplink/interface/target_flash.c b/source/daplink/interface/target_flash.c index 917435259..da32b9679 100644 --- a/source/daplink/interface/target_flash.c +++ b/source/daplink/interface/target_flash.c @@ -19,7 +19,7 @@ * limitations under the License. */ #ifdef DRAG_N_DROP_SUPPORT -#include "string.h" +#include #include "target_config.h" #include "gpio.h" @@ -89,7 +89,7 @@ static program_target_t * get_flash_algo(uint32_t addr) } } } - + //could not find a flash algo for the region; use default if (default_region) { flash_start = default_region->start; @@ -139,9 +139,9 @@ static error_t target_flash_set(uint32_t addr) if (0 == swd_write_memory(new_flash_algo->algo_start, (uint8_t *)new_flash_algo->algo_blob, new_flash_algo->algo_size)) { return ERROR_ALGO_DL; } - + current_flash_algo = new_flash_algo; - + } return ERROR_SUCCESS; } @@ -150,13 +150,13 @@ static error_t target_flash_init() { if (g_board_info.target_cfg) { last_flash_func = FLASH_FUNC_NOP; - + current_flash_algo = NULL; - + if (0 == target_set_state(RESET_PROGRAM)) { return ERROR_RESET; } - + //get default region region_info_t * flash_region = g_board_info.target_cfg->flash_regions; for (; flash_region->start != 0 || flash_region->end != 0; ++flash_region) { @@ -171,7 +171,7 @@ static error_t target_flash_init() } else { return ERROR_FAILURE; } - + } static error_t target_flash_uninit(void) @@ -191,7 +191,7 @@ static error_t target_flash_uninit(void) // Check to see if anything needs to be done after programming. // This is usually a no-op for most targets. target_set_state(POST_FLASH_RESET); - + state = STATE_CLOSED; swd_off(); return ERROR_SUCCESS; @@ -205,11 +205,11 @@ static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint if (g_board_info.target_cfg) { error_t status = ERROR_SUCCESS; program_target_t * flash = current_flash_algo; - + if (!flash) { return ERROR_INTERNAL; } - + // check if security bits were set if (g_target_family && g_target_family->security_bits_set){ if (1 == g_target_family->security_bits_set(addr, (uint8_t *)buf, size)) { @@ -222,7 +222,7 @@ static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint if (status != ERROR_SUCCESS) { return status; } - + while (size > 0) { uint32_t write_size = MIN(size, flash->program_buffer_size); @@ -277,11 +277,11 @@ static error_t target_flash_program_page(uint32_t addr, const uint8_t *buf, uint addr += write_size; buf += write_size; size -= write_size; - + } return ERROR_SUCCESS; - + } else { return ERROR_FAILURE; } @@ -296,7 +296,7 @@ static error_t target_flash_erase_sector(uint32_t addr) if (!flash) { return ERROR_INTERNAL; } - + // Check to make sure the address is on a sector boundary if ((addr % target_flash_erase_sector_size(addr)) != 0) { return ERROR_ERASE_SECTOR; @@ -307,7 +307,7 @@ static error_t target_flash_erase_sector(uint32_t addr) if (status != ERROR_SUCCESS) { return status; } - + if (0 == swd_flash_syscall_exec(&flash->sys_call_s, flash->erase_sector, addr, 0, 0, 0)) { return ERROR_ERASE_SECTOR; } @@ -325,7 +325,7 @@ static error_t target_flash_erase_chip(void) region_info_t * flash_region = g_board_info.target_cfg->flash_regions; for (; flash_region->start != 0 || flash_region->end != 0; ++flash_region) { - status = target_flash_set(flash_region->start); + status = target_flash_set(flash_region->start); if (status != ERROR_SUCCESS) { return status; } @@ -365,7 +365,7 @@ static uint32_t target_flash_program_page_min_size(uint32_t addr) static uint32_t target_flash_erase_sector_size(uint32_t addr) { if (g_board_info.target_cfg){ - if(g_board_info.target_cfg->sector_info_length > 0) { + if(g_board_info.target_cfg->sector_info_length > 0) { int sector_index = g_board_info.target_cfg->sector_info_length - 1; for (; sector_index >= 0; sector_index--) { if (addr >= g_board_info.target_cfg->sectors_info[sector_index].start) { diff --git a/source/daplink/macro.h b/source/daplink/macro.h deleted file mode 100644 index c5a08b6c8..000000000 --- a/source/daplink/macro.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file macro.h - * @brief useful things - * - * DAPLink Interface Firmware - * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MACRO_H -#define MACRO_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define ELEMENTS_IN_ARRAY(array) (sizeof(array)/sizeof(array[0])) - -#define MB(size) ((size) * 1024 * 1024) - -#define KB(size) ((size) * 1024) - -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - -#define MAX(a,b) ((a) > (b) ? (a) : (b)) - -#define ROUND_UP(value, boundary) ((value) + ((boundary) - (value)) % (boundary)) - -#define ROUND_DOWN(value, boundary) ((value) - ((value) % (boundary))) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/source/daplink/settings/settings.c b/source/daplink/settings/settings.c index dc42c0f57..e83c06e1e 100644 --- a/source/daplink/settings/settings.c +++ b/source/daplink/settings/settings.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "settings.h" #include "target_config.h" @@ -48,14 +48,14 @@ typedef struct __attribute__((__packed__)) cfg_ram { char assert_file_name[64 + 1]; uint16_t assert_line; uint8_t assert_source; - + // Additional debug information on faults uint8_t valid_dumps; uint32_t hexdump[ALLOWED_HEXDUMP]; //Alignments checked - + // Disable msd support uint8_t disable_msd; - + //Add new entries from here } cfg_ram_t; @@ -214,7 +214,7 @@ uint8_t config_ram_get_hexdumps(uint32_t **hexdumps) if (config_ram.valid_dumps == 0) { return 0; } - + //prevent memcopy check alignment *hexdumps = config_ram.hexdump; return config_ram.valid_dumps; diff --git a/source/daplink/settings/settings.h b/source/daplink/settings/settings.h index b19ae8ee6..189e9056d 100644 --- a/source/daplink/settings/settings.h +++ b/source/daplink/settings/settings.h @@ -21,8 +21,8 @@ #ifndef SETTINGS_H #define SETTINGS_H -#include "stdint.h" -#include "stdbool.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/source/daplink/settings/settings_rom.c b/source/daplink/settings/settings_rom.c index 9d99c7382..52943591d 100644 --- a/source/daplink/settings/settings_rom.c +++ b/source/daplink/settings/settings_rom.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "settings.h" #include "target_config.h" diff --git a/source/daplink/settings/settings_rom_stub.c b/source/daplink/settings/settings_rom_stub.c index 2da808c5d..22d82013e 100644 --- a/source/daplink/settings/settings_rom_stub.c +++ b/source/daplink/settings/settings_rom_stub.c @@ -19,8 +19,6 @@ * limitations under the License. */ -#include "stdbool.h" - #include "settings.h" void config_rom_init() diff --git a/source/daplink/usb2uart/usbd_user_cdc_acm.c b/source/daplink/usb2uart/usbd_user_cdc_acm.c index 5538761a3..1f4e57e23 100644 --- a/source/daplink/usb2uart/usbd_user_cdc_acm.c +++ b/source/daplink/usb2uart/usbd_user_cdc_acm.c @@ -114,9 +114,9 @@ static U32 start_break_time = 0; int32_t USBD_CDC_ACM_SendBreak(uint16_t dur) { uint32_t end_break_time; -#ifdef DRAG_N_DROP_SUPPORT - if (!flash_intf_target->flash_busy()) -#endif +#ifdef DRAG_N_DROP_SUPPORT + if (!flash_intf_target->flash_busy()) +#endif { //added checking if flashing on target is in progress // reset and send the unique id over CDC if (dur != 0) { @@ -187,7 +187,7 @@ void cdc_process_event() main_blink_cdc_led(MAIN_LED_FLASH); } } - + // Always process events main_cdc_send_event(); } diff --git a/source/daplink/util.c b/source/daplink/util.c index b337b5880..8214ff2f0 100644 --- a/source/daplink/util.c +++ b/source/daplink/util.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "util.h" #include "settings.h" diff --git a/source/daplink/util.h b/source/daplink/util.h index b90376adf..a220df919 100644 --- a/source/daplink/util.h +++ b/source/daplink/util.h @@ -3,7 +3,7 @@ * @brief useful things * * DAPLink Interface Firmware - * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved + * Copyright (c) 2009-2020, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -22,8 +22,32 @@ #ifndef UTIL_H #define UTIL_H -#include "stdbool.h" -#include "stdint.h" +#include +#include + +// Protect commonly-defined macros with ifdefs, to prevent conflicts if redefined +// in imported sources (mostly vendor SDKs). + +#if !defined(ARRAY_SIZE) +//! @brief Get number of elements in the array. +#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) +#endif + +#if !defined(MIN) +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#if !defined(MAX) +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#define MB(size) ((size) * 1024 * 1024) + +#define KB(size) ((size) * 1024) + +#define ROUND_UP(value, boundary) ((value) + ((boundary) - (value)) % (boundary)) + +#define ROUND_DOWN(value, boundary) ((value) - ((value) % (boundary))) #ifdef __cplusplus extern "C" { diff --git a/source/daplink/validation.c b/source/daplink/validation.c index 1f8493ed6..24c5b2d25 100644 --- a/source/daplink/validation.c +++ b/source/daplink/validation.c @@ -19,8 +19,8 @@ * limitations under the License. */ +#include #include "validation.h" -#include "string.h" #include "target_config.h" #include "target_family.h" #include "target_board.h" @@ -34,7 +34,7 @@ uint8_t validate_bin_nvic(const uint8_t *buf) { if (g_target_family && g_target_family->validate_bin_nvic) { return g_target_family && g_target_family->validate_bin_nvic(buf); - } else if (g_board_info.target_cfg) { + } else if (g_board_info.target_cfg) { uint32_t i = 4, nvic_val = 0; uint8_t in_range = 0; // test the initial SP value @@ -47,7 +47,7 @@ uint8_t validate_bin_nvic(const uint8_t *buf) break; } } - + if (in_range == 0) { return 0; } diff --git a/source/daplink/validation.h b/source/daplink/validation.h index 8e2d7ff50..7363d700a 100644 --- a/source/daplink/validation.h +++ b/source/daplink/validation.h @@ -22,7 +22,7 @@ #ifndef VALIDATION_H #define VALIDATION_H -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/hic_hal/FlashOS.h b/source/hic_hal/FlashOS.h index 4a82fa086..7d97571d5 100644 --- a/source/hic_hal/FlashOS.h +++ b/source/hic_hal/FlashOS.h @@ -1,6 +1,6 @@ /** * @file FlashOS.h - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved @@ -22,7 +22,7 @@ #ifndef FLASHOS_H #define FLASHOS_H -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/hic_hal/FlashPrg.h b/source/hic_hal/FlashPrg.h index 600f48cbc..26db8bb77 100644 --- a/source/hic_hal/FlashPrg.h +++ b/source/hic_hal/FlashPrg.h @@ -1,6 +1,6 @@ /** * @file FlashPrg.h - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved @@ -22,7 +22,7 @@ #ifndef FLASHPRG_H #define FLASHPRG_H -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/hic_hal/atmel/sam3u2c/uart.c b/source/hic_hal/atmel/sam3u2c/uart.c index 1ffe14d75..53e04d8fc 100644 --- a/source/hic_hal/atmel/sam3u2c/uart.c +++ b/source/hic_hal/atmel/sam3u2c/uart.c @@ -1,6 +1,6 @@ /** * @file uart.c - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved @@ -35,9 +35,6 @@ #define RX_OVRF_MSG_SIZE (sizeof(RX_OVRF_MSG) - 1) -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - #define I8 int8_t #define I16 int16_t #define I32 int32_t @@ -185,7 +182,7 @@ static int get_tx_ready() { if (!_FlowControlEnabled) { return 1; - } + } return ((PIOA->PIO_PDSR >> BIT_CDC_USB2UART_CTS) & 1) == 0; } diff --git a/source/hic_hal/flash_blob.h b/source/hic_hal/flash_blob.h index 6de0ce1a6..a1ee4f064 100644 --- a/source/hic_hal/flash_blob.h +++ b/source/hic_hal/flash_blob.h @@ -1,6 +1,6 @@ /** * @file flash_blob.h - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved @@ -22,7 +22,7 @@ #ifndef FLASH_BLOB_H #define FLASH_BLOB_H -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/hic_hal/freescale/iap/fsl_common.h b/source/hic_hal/freescale/iap/fsl_common.h index 6d78c2a84..08ba24214 100644 --- a/source/hic_hal/freescale/iap/fsl_common.h +++ b/source/hic_hal/freescale/iap/fsl_common.h @@ -126,17 +126,17 @@ typedef int32_t status_t; /*! @name Min/max macros */ /* @{ */ -#if !defined(MIN) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -#if !defined(MAX) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif -/* @} */ - -/*! @brief Computes the number of elements in an array. */ -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +// #if !defined(MIN) +// #define MIN(a, b) ((a) < (b) ? (a) : (b)) +// #endif +// +// #if !defined(MAX) +// #define MAX(a, b) ((a) > (b) ? (a) : (b)) +// #endif +// /* @} */ +// +// /*! @brief Computes the number of elements in an array. */ +// #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /*! @name UINT16_MAX/UINT32_MAX value */ /* @{ */ diff --git a/source/hic_hal/freescale/k20dx/usb_config.c b/source/hic_hal/freescale/k20dx/usb_config.c index a9cdb3d4f..5b232ec8e 100644 --- a/source/hic_hal/freescale/k20dx/usb_config.c +++ b/source/hic_hal/freescale/k20dx/usb_config.c @@ -1,6 +1,6 @@ /** * @file usb_config.h - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved @@ -19,6 +19,8 @@ * limitations under the License. */ +#include "util.h" + // USB Device // Enable the USB Device functionality #define USBD_ENABLE 1 @@ -393,7 +395,7 @@ #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) diff --git a/source/hic_hal/freescale/k26f/usb_config.c b/source/hic_hal/freescale/k26f/usb_config.c index ad15157c0..c2dcd52c1 100644 --- a/source/hic_hal/freescale/k26f/usb_config.c +++ b/source/hic_hal/freescale/k26f/usb_config.c @@ -19,6 +19,8 @@ * limitations under the License. */ +#include "util.h" + //*** <<< Use Configuration Wizard in Context Menu >>> *** // **** @@ -403,7 +405,7 @@ #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) @@ -542,7 +544,7 @@ #define USBD_MAX_PACKET_CALC1 ((USBD_ADC_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET ) ? (USBD_ADC_MAX_PACKET ) : (USBD_CDC_ACM_MAX_PACKET )) #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 )) #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 )) -#define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) +#define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) /*------------------------------------------------------------------------------ diff --git a/source/hic_hal/freescale/kl26z/usb_config.c b/source/hic_hal/freescale/kl26z/usb_config.c index 7cfacd35e..ad35f74d0 100644 --- a/source/hic_hal/freescale/kl26z/usb_config.c +++ b/source/hic_hal/freescale/kl26z/usb_config.c @@ -1,6 +1,6 @@ /** * @file usb_config.c - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved @@ -19,6 +19,8 @@ * limitations under the License. */ +#include "util.h" + // USB Device // Enable the USB Device functionality #define USBD_ENABLE 1 @@ -394,7 +396,7 @@ #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) @@ -404,7 +406,7 @@ #define USBD_EP_NUM_CALC6 MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5) #define USBD_EP_NUM_CALC7 MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT))) #define USBD_EP_NUM MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7) - + #if (USBD_HID_ENABLE) #if (USBD_MSC_ENABLE) @@ -479,7 +481,7 @@ #define USBD_WEBUSB_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE) #define USBD_MSC_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE) #define USBD_BULK_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE+USBD_BULK_ENABLE) - + #if (USBD_HID_ENABLE) #if (USBD_HID_HS_ENABLE) diff --git a/source/hic_hal/maxim/max32620/usb_config.c b/source/hic_hal/maxim/max32620/usb_config.c index dd14531fc..b9f1a811a 100644 --- a/source/hic_hal/maxim/max32620/usb_config.c +++ b/source/hic_hal/maxim/max32620/usb_config.c @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "util.h" + /*------------------------------------------------------------------------------ * USB Device Configuration *----------------------------------------------------------------------------*/ @@ -393,7 +396,7 @@ #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) @@ -403,7 +406,7 @@ #define USBD_EP_NUM_CALC6 MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5) #define USBD_EP_NUM_CALC7 MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT))) #define USBD_EP_NUM MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7) - + #if (USBD_EP_NUM > 7) #error "Max32620 only have 8 individual endpoints including EP0!" #endif @@ -480,7 +483,7 @@ #define USBD_WEBUSB_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE) #define USBD_MSC_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE) #define USBD_BULK_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE+USBD_BULK_ENABLE) - + #if (USBD_HID_ENABLE) #if (USBD_HID_HS_ENABLE) #define USBD_HID_MAX_PACKET ((USBD_HID_HS_WMAXPACKETSIZE > USBD_HID_WMAXPACKETSIZE) ? USBD_HID_HS_WMAXPACKETSIZE : USBD_HID_WMAXPACKETSIZE) @@ -538,7 +541,7 @@ #define USBD_MAX_PACKET_CALC1 ((USBD_ADC_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET ) ? (USBD_ADC_MAX_PACKET ) : (USBD_CDC_ACM_MAX_PACKET )) #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 )) #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 )) -#define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) +#define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) /*------------------------------------------------------------------------------ * USB Config Functions diff --git a/source/hic_hal/maxim/max32625/usb_config.c b/source/hic_hal/maxim/max32625/usb_config.c index 39bb6060f..44af7e941 100755 --- a/source/hic_hal/maxim/max32625/usb_config.c +++ b/source/hic_hal/maxim/max32625/usb_config.c @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "util.h" + /*------------------------------------------------------------------------------ * USB Device Configuration *----------------------------------------------------------------------------*/ @@ -391,9 +394,9 @@ /* USB Device Calculations ---------------------------------------------------*/ -#define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) +#define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) @@ -538,8 +541,8 @@ #define USBD_MAX_PACKET_CALC1 ((USBD_ADC_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET ) ? (USBD_ADC_MAX_PACKET ) : (USBD_CDC_ACM_MAX_PACKET )) #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 )) #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 )) -#define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) - +#define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) + /*------------------------------------------------------------------------------ * USB Config Functions diff --git a/source/hic_hal/nuvoton/m48ssidae/usb_config.c b/source/hic_hal/nuvoton/m48ssidae/usb_config.c index b75fe6cd8..c04d53a3c 100644 --- a/source/hic_hal/nuvoton/m48ssidae/usb_config.c +++ b/source/hic_hal/nuvoton/m48ssidae/usb_config.c @@ -19,6 +19,8 @@ * limitations under the License. */ +#include "util.h" + // USB Device // Enable the USB Device functionality #define USBD_ENABLE 1 @@ -392,7 +394,7 @@ #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) diff --git a/source/hic_hal/nxp/lpc11u35/flash.c b/source/hic_hal/nxp/lpc11u35/flash.c index 2d13a958b..afbb9745b 100644 --- a/source/hic_hal/nxp/lpc11u35/flash.c +++ b/source/hic_hal/nxp/lpc11u35/flash.c @@ -19,11 +19,11 @@ * limitations under the License. */ +#include #include "flash_hal.h" #include "iap.h" -#include "macro.h" +#include "util.h" #include "LPC11Uxx.h" -#include "string.h" // page buffer must be 4 byte algined and must reside in ram bank 1 static __attribute__((section("RAM1"))) uint32_t page_buf[64]; @@ -48,7 +48,7 @@ uint32_t EraseChip(void) uint32_t EraseSector(uint32_t adr) { uint32_t num = get_sector_num(adr); - + iap_lock(); iap_op.cmd = 50; // Prepare Sector for Erase diff --git a/source/hic_hal/nxp/lpc11u35/usb_config.c b/source/hic_hal/nxp/lpc11u35/usb_config.c index 7655842e2..828b0c761 100644 --- a/source/hic_hal/nxp/lpc11u35/usb_config.c +++ b/source/hic_hal/nxp/lpc11u35/usb_config.c @@ -1,6 +1,6 @@ /** * @file usb_config.c - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved @@ -19,6 +19,8 @@ * limitations under the License. */ +#include "util.h" + // USB Device // Enable the USB Device functionality #define USBD_ENABLE 1 @@ -396,10 +398,10 @@ #define USBD_BULK_STRDESC L"CMSIS-DAP v2" /* USB Device Calculations ---------------------------------------------------*/ - + #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) @@ -546,7 +548,7 @@ #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 )) #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 )) #define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) - + /*------------------------------------------------------------------------------ * USB Config Functions diff --git a/source/hic_hal/nxp/lpc4322/usb_config.c b/source/hic_hal/nxp/lpc4322/usb_config.c index f7ec3d070..77c0af231 100644 --- a/source/hic_hal/nxp/lpc4322/usb_config.c +++ b/source/hic_hal/nxp/lpc4322/usb_config.c @@ -1,6 +1,6 @@ /** * @file usb_config.c - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved @@ -19,6 +19,8 @@ * limitations under the License. */ +#include "util.h" + // USB Device // Enable the USB Device functionality #define USBD_ENABLE 1 @@ -394,7 +396,7 @@ #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) @@ -404,7 +406,7 @@ #define USBD_EP_NUM_CALC6 MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5) #define USBD_EP_NUM_CALC7 MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT))) #define USBD_EP_NUM MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7) - + #if (USBD_HID_ENABLE) #if (USBD_MSC_ENABLE) @@ -479,7 +481,7 @@ #define USBD_WEBUSB_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE) #define USBD_MSC_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE) #define USBD_BULK_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE+USBD_BULK_ENABLE) - + #if (USBD_HID_ENABLE) #if (USBD_HID_HS_ENABLE) @@ -539,7 +541,7 @@ #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 )) #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 )) #define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) - + /*------------------------------------------------------------------------------ * USB Config Functions diff --git a/source/hic_hal/read_uid.h b/source/hic_hal/read_uid.h index 193187ef4..c8c6429d3 100644 --- a/source/hic_hal/read_uid.h +++ b/source/hic_hal/read_uid.h @@ -1,6 +1,6 @@ /** * @file read_uid.h - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved @@ -22,7 +22,7 @@ #ifndef READ_UID_H #define READ_UID_H -#include "stdint.h" +#include #ifdef __cplusplus extern "C" { diff --git a/source/hic_hal/stm32/stm32f103xb/gpio.c b/source/hic_hal/stm32/stm32f103xb/gpio.c index 8cafed11d..376cf3581 100644 --- a/source/hic_hal/stm32/stm32f103xb/gpio.c +++ b/source/hic_hal/stm32/stm32f103xb/gpio.c @@ -101,7 +101,7 @@ static void output_clock_enable(void) util_assert(0); return; } - + __HAL_TIM_SET_COMPARE(&timer, TIM_CHANNEL_1, period / 2); ret = HAL_TIM_PWM_Start(&timer, TIM_CHANNEL_1); if (ret != HAL_OK) { diff --git a/source/hic_hal/stm32/stm32f103xb/usb_config.c b/source/hic_hal/stm32/stm32f103xb/usb_config.c index 64ae4c594..646a27810 100644 --- a/source/hic_hal/stm32/stm32f103xb/usb_config.c +++ b/source/hic_hal/stm32/stm32f103xb/usb_config.c @@ -19,6 +19,8 @@ * limitations under the License. */ +#include "util.h" + // USB Device // Enable the USB Device functionality #define USBD_ENABLE 1 @@ -392,7 +394,7 @@ #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) -#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +// #define MAX(x, y) (((x) < (y)) ? (y) : (x)) #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT))) #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) @@ -402,7 +404,7 @@ #define USBD_EP_NUM_CALC6 MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5) #define USBD_EP_NUM_CALC7 MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT))) #define USBD_EP_NUM MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7) - + #if (USBD_HID_ENABLE) #if (USBD_MSC_ENABLE) @@ -477,7 +479,7 @@ #define USBD_WEBUSB_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE) #define USBD_MSC_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE) #define USBD_BULK_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE+USBD_BULK_ENABLE) - + #if (USBD_HID_ENABLE) #if (USBD_HID_HS_ENABLE) @@ -536,7 +538,7 @@ #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 )) #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 )) #define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) - + /*------------------------------------------------------------------------------ * USB Config Functions diff --git a/source/hic_hal/uart.h b/source/hic_hal/uart.h index e9a04f524..639c49424 100644 --- a/source/hic_hal/uart.h +++ b/source/hic_hal/uart.h @@ -1,6 +1,6 @@ /** * @file uart.h - * @brief + * @brief * * DAPLink Interface Firmware * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved @@ -22,8 +22,8 @@ #ifndef UART_H #define UART_H -#include "stdint.h" -#include "stdbool.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/source/target/target_board.c b/source/target/target_board.c index 553d8a27a..8142af14b 100644 --- a/source/target/target_board.c +++ b/source/target/target_board.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "target_board.h" // Default empty board info. diff --git a/source/target/target_config.h b/source/target/target_config.h index 96f397e4b..630fee846 100644 --- a/source/target/target_config.h +++ b/source/target/target_config.h @@ -22,11 +22,11 @@ #ifndef TARGET_CONFIG_H #define TARGET_CONFIG_H -#include "stddef.h" -#include "stdint.h" +#include +#include #include "flash_blob.h" -#include "macro.h" +#include "util.h" //! This can vary from target to target and should be in the structure or flash blob #define TARGET_AUTO_INCREMENT_PAGE_SIZE (1024) diff --git a/source/usb/bulk/usbd_bulk.c b/source/usb/bulk/usbd_bulk.c index a0a36be9a..8d94c9514 100644 --- a/source/usb/bulk/usbd_bulk.c +++ b/source/usb/bulk/usbd_bulk.c @@ -18,13 +18,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - #include "string.h" - + +#include + #include "rl_usb.h" #include "usb_for_lib.h" #include "util.h" -#include "macro.h" #include "DAP_queue.h" static U8 *ptrDataIn; @@ -66,7 +65,7 @@ void USBD_BULK_EP_BULKIN_Event(U32 event) */ void USBD_BULK_EP_BULKOUT_Event(U32 event) -{ +{ U16 bytes_rece; uint8_t * rbuf; diff --git a/source/usb/cdc/usbd_cdc_acm.c b/source/usb/cdc/usbd_cdc_acm.c index e26c66d0a..5bf005108 100644 --- a/source/usb/cdc/usbd_cdc_acm.c +++ b/source/usb/cdc/usbd_cdc_acm.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/cdc/usbd_core_cdc.c b/source/usb/cdc/usbd_core_cdc.c index a67c4809e..fd044d66c 100644 --- a/source/usb/cdc/usbd_core_cdc.c +++ b/source/usb/cdc/usbd_core_cdc.c @@ -19,8 +19,8 @@ * limitations under the License. */ -#include "string.h" - +#include + #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/hid/usbd_core_hid.c b/source/usb/hid/usbd_core_hid.c index f2d3982ab..af948ebac 100644 --- a/source/usb/hid/usbd_core_hid.c +++ b/source/usb/hid/usbd_core_hid.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/hid/usbd_hid.c b/source/usb/hid/usbd_hid.c index 44f0878ca..218858e2b 100644 --- a/source/usb/hid/usbd_hid.c +++ b/source/usb/hid/usbd_hid.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "rl_usb.h" #include "usb_for_lib.h" @@ -61,7 +61,7 @@ __weak U8 usbd_hid_get_protocol(void) }; __weak void usbd_hid_set_protocol(U8 protocol) { - + }; @@ -272,11 +272,11 @@ void USBD_HID_EP_INTIN_Event(U32 event) if (bytes_to_send > usbd_hid_maxpacketsize[USBD_HighSpeed]) { bytes_to_send = usbd_hid_maxpacketsize[USBD_HighSpeed]; } - + if (usbd_hid_ep_intin != 0) { //control ep does the sending to host USBD_WriteEP(usbd_hid_ep_intin | 0x80, ptrDataOut, bytes_to_send); } - + ptrDataOut += bytes_to_send; DataOutSentLen += bytes_to_send; diff --git a/source/usb/hid/usbd_user_hid.c b/source/usb/hid/usbd_user_hid.c index ad3c1c41f..2c52fe146 100644 --- a/source/usb/hid/usbd_user_hid.c +++ b/source/usb/hid/usbd_user_hid.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "rl_usb.h" #include "usb.h" #define __NO_USB_LIB_C @@ -74,7 +74,7 @@ int usbd_hid_get_report(U8 rtype, U8 rid, U8 *buf, U8 req) case USBD_HID_REQ_EP_CTRL: case USBD_HID_REQ_EP_INT: - if (DAP_queue_get_send_buf(&DAP_Cmd_queue, &sbuf, &slen)) { + if (DAP_queue_get_send_buf(&DAP_Cmd_queue, &sbuf, &slen)) { if (slen > USBD_HID_OUTREPORT_MAX_SZ){ util_assert(0); }else { @@ -96,7 +96,7 @@ int usbd_hid_get_report(U8 rtype, U8 rid, U8 *buf, U8 req) return (0); } -// USB HID override function return 1 if the activity is trivial or response is null +// USB HID override function return 1 if the activity is trivial or response is null __attribute__((weak)) uint8_t usbd_hid_no_activity(U8 *buf) { @@ -132,7 +132,7 @@ void usbd_hid_set_report(U8 rtype, U8 rid, U8 *buf, int len, U8 req) } else { util_assert(0); } - + main_blink_hid_led(led_next_state); break; diff --git a/source/usb/msc/usbd_core_msc.c b/source/usb/msc/usbd_core_msc.c index 70ad18fac..d47ed0745 100644 --- a/source/usb/msc/usbd_core_msc.c +++ b/source/usb/msc/usbd_core_msc.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/msc/usbd_msc.c b/source/usb/msc/usbd_msc.c index d7192ec47..fab86af9c 100644 --- a/source/usb/msc/usbd_msc.c +++ b/source/usb/msc/usbd_msc.c @@ -19,12 +19,11 @@ * limitations under the License. */ -#include "string.h" - +#include + #include "rl_usb.h" #include "usb_for_lib.h" #include "util.h" -#include "macro.h" BOOL USBD_MSC_MediaReady = __FALSE; BOOL USBD_MSC_ReadOnly = __FALSE; @@ -1091,7 +1090,7 @@ void USBD_MSC_BulkOut(void) case MSC_BS_RESET: // If Bulk-Only Mass Storage Reset command was received on // Control Endpoint ignore next Bulk OUT transfer if it was not - // a CBW (as it means it was a unprocessed leftover from + // a CBW (as it means it was a unprocessed leftover from // transfer before reset happened) BulkStage = MSC_BS_CBW; if (BulkLen == sizeof(USBD_MSC_CBW)) { diff --git a/source/usb/rl_usb.h b/source/usb/rl_usb.h index 11505fc92..1619abebb 100644 --- a/source/usb/rl_usb.h +++ b/source/usb/rl_usb.h @@ -26,7 +26,7 @@ extern "C" { #endif -#include "stdint.h" +#include #include "usb.h" /***************** Functions *************************************************/ diff --git a/source/usb/usbd_core.c b/source/usb/usbd_core.c index 7d1000a76..4e8ff1568 100644 --- a/source/usb/usbd_core.c +++ b/source/usb/usbd_core.c @@ -19,8 +19,8 @@ * limitations under the License. */ +#include #include "rl_usb.h" -#include "string.h" #include "usb_for_lib.h" #include "info.h" diff --git a/source/usb/webusb/usbd_core_webusb.c b/source/usb/webusb/usbd_core_webusb.c index 5613063fc..a2712117b 100644 --- a/source/usb/webusb/usbd_core_webusb.c +++ b/source/usb/webusb/usbd_core_webusb.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "rl_usb.h" #include "usb_for_lib.h" diff --git a/source/usb/winusb/usbd_core_winusb.c b/source/usb/winusb/usbd_core_winusb.c index 884cb4902..404ac099d 100644 --- a/source/usb/winusb/usbd_core_winusb.c +++ b/source/usb/winusb/usbd_core_winusb.c @@ -19,7 +19,7 @@ * limitations under the License. */ -#include "string.h" +#include #include "rl_usb.h" #include "usb_for_lib.h"