From 6da829690ffa40452cb0e6654bbf61f9796980e2 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 21 Apr 2017 09:36:04 -0500 Subject: [PATCH] subsys: convert to using newly introduced integer sized types Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99 integer types. Jira: ZEP-2051 Change-Id: Icbf9e542b23208890a3a32358447d44cdc274ef1 Signed-off-by: Kumar Gala --- subsys/console/getchar.c | 10 +-- subsys/debug/gdb_server.c | 14 ++-- subsys/debug/mem_safe_check_boundaries.c | 6 +- subsys/debug/openocd.c | 2 +- subsys/disk/disk_access_flash.c | 56 +++++++------- subsys/disk/disk_access_ram.c | 18 ++--- subsys/disk/fat12_ramdisk.h | 2 +- subsys/fs/fat_fs.c | 6 +- subsys/logging/event_logger.c | 36 ++++----- subsys/logging/kernel_event_logger.c | 22 +++--- subsys/shell/modules/kernel_service.c | 2 +- subsys/shell/shell.c | 2 +- subsys/usb/class/cdc_acm.c | 62 ++++++++-------- subsys/usb/class/cdc_acm.h | 20 ++--- subsys/usb/class/mass_storage.c | 94 ++++++++++++------------ subsys/usb/class/mass_storage.h | 22 +++--- subsys/usb/usb_device.c | 92 +++++++++++------------ 17 files changed, 233 insertions(+), 233 deletions(-) diff --git a/subsys/console/getchar.c b/subsys/console/getchar.c index dbed4b50c1c..a2725aa525c 100644 --- a/subsys/console/getchar.c +++ b/subsys/console/getchar.c @@ -15,10 +15,10 @@ #endif static K_SEM_DEFINE(uart_sem, 0, UINT_MAX); -static uint8_t uart_ringbuf[CONFIG_CONSOLE_GETCHAR_BUFSIZE]; -static uint8_t i_get, i_put; +static u8_t uart_ringbuf[CONFIG_CONSOLE_GETCHAR_BUFSIZE]; +static u8_t i_get, i_put; -static int console_irq_input_hook(uint8_t c) +static int console_irq_input_hook(u8_t c) { int i_next = (i_put + 1) & (CONFIG_CONSOLE_GETCHAR_BUFSIZE - 1); @@ -34,10 +34,10 @@ static int console_irq_input_hook(uint8_t c) return 1; } -uint8_t console_getchar(void) +u8_t console_getchar(void) { unsigned int key; - uint8_t c; + u8_t c; k_sem_take(&uart_sem, K_FOREVER); key = irq_lock(); diff --git a/subsys/debug/gdb_server.c b/subsys/debug/gdb_server.c index 3180000398f..08c5edd2b7c 100644 --- a/subsys/debug/gdb_server.c +++ b/subsys/debug/gdb_server.c @@ -474,11 +474,11 @@ static void remove_all_installed_breakpoints(void); #ifdef GDB_ARCH_HAS_REMOTE_SERIAL_EXT_USING_NOTIF_PACKETS static void handle_notification(void); static void request_notification_packet_flush(void); -static uint32_t write_to_console(char *buf, uint32_t len); +static u32_t write_to_console(char *buf, u32_t len); #endif #ifdef CONFIG_GDB_SERVER_INTERRUPT_DRIVEN -static int console_irq_input_hook(uint8_t ch); +static int console_irq_input_hook(u8_t ch); #endif static int get_hex_char_value(unsigned char ch) @@ -853,9 +853,9 @@ static inline int must_flush_notification_buffer(unsigned char ch) * * The buffer is also automatically flushed when system is stopped. */ -static uint32_t write_to_console(char *buf, uint32_t len) +static u32_t write_to_console(char *buf, u32_t len) { - uint32_t ix; + u32_t ix; unsigned char ch; int key = irq_lock(); @@ -887,8 +887,8 @@ static void handle_notification(void) int ix = 0; unsigned char ch; int more_data = 0; - uint32_t max_packet_size; - uint32_t data_size; + u32_t max_packet_size; + u32_t data_size; unsigned char *ptr = notif_data; /* First, check if there is pending data */ @@ -2381,7 +2381,7 @@ static UART_CONSOLE_OUT_DEBUG_HOOK_SIG(gdb_console_out) } #ifdef CONFIG_GDB_SERVER_INTERRUPT_DRIVEN -static int console_irq_input_hook(uint8_t ch) +static int console_irq_input_hook(u8_t ch) { if (ch == GDB_STOP_CHAR) { (void)irq_lock(); diff --git a/subsys/debug/mem_safe_check_boundaries.c b/subsys/debug/mem_safe_check_boundaries.c index f9243c3b56b..771d9314fb4 100644 --- a/subsys/debug/mem_safe_check_boundaries.c +++ b/subsys/debug/mem_safe_check_boundaries.c @@ -57,7 +57,7 @@ static inline void write_to_mem(void *dest, void *src, int width) *((vaddr_t *)dest) = *((const vaddr_t *)src); break; case 2: - *((uint16_t *)dest) = *((const uint16_t *)src); + *((u16_t *)dest) = *((const u16_t *)src); break; case 1: *((char *)dest) = *((const char *)src); @@ -169,7 +169,7 @@ static inline int mem_access(void *p, void *buf, size_t num_bytes, return 0; } -static inline int get_align(const uint32_t value) +static inline int get_align(const u32_t value) { return (value & 1) ? 1 : (value & 2) ? 2 : 4; } @@ -180,7 +180,7 @@ static inline int get_width(const void *p1, const void *p2, vaddr_t p1_addr = (vaddr_t)p1, p2_addr = (vaddr_t)p2; if (width == 0) { - uint32_t align_check = num_bytes | p1_addr | p2_addr; + u32_t align_check = num_bytes | p1_addr | p2_addr; return get_align(align_check); } diff --git a/subsys/debug/openocd.c b/subsys/debug/openocd.c index c0dbf51ae69..c4bb5751302 100644 --- a/subsys/debug/openocd.c +++ b/subsys/debug/openocd.c @@ -63,5 +63,5 @@ size_t _kernel_openocd_offsets[] = { }; __attribute__((used, section(".openocd_dbg"))) -uint8_t _kernel_openocd_size_t_size = (uint8_t)sizeof(size_t); +u8_t _kernel_openocd_size_t_size = (u8_t)sizeof(size_t); #endif diff --git a/subsys/disk/disk_access_flash.c b/subsys/disk/disk_access_flash.c index 2156ef6b5be..9b9d0ac0bc4 100644 --- a/subsys/disk/disk_access_flash.c +++ b/subsys/disk/disk_access_flash.c @@ -18,8 +18,8 @@ static struct device *flash_dev; /* flash read-copy-erase-write operation */ -static uint8_t read_copy_buf[CONFIG_DISK_ERASE_BLOCK_SIZE]; -static uint8_t *fs_buff = read_copy_buf; +static u8_t read_copy_buf[CONFIG_DISK_ERASE_BLOCK_SIZE]; +static u8_t *fs_buff = read_copy_buf; /* calculate number of blocks required for a given size */ #define GET_NUM_BLOCK(total_size, block_size) \ @@ -28,7 +28,7 @@ static uint8_t *fs_buff = read_copy_buf; #define GET_SIZE_TO_BOUNDARY(start, block_size) \ (block_size - (start & (block_size - 1))) -static off_t lba_to_address(uint32_t sector_num) +static off_t lba_to_address(u32_t sector_num) { off_t flash_addr; @@ -63,13 +63,13 @@ int disk_access_init(void) return 0; } -int disk_access_read(uint8_t *buff, uint32_t start_sector, - uint32_t sector_count) +int disk_access_read(u8_t *buff, u32_t start_sector, + u32_t sector_count) { off_t fl_addr; - uint32_t remaining; - uint32_t len; - uint32_t num_read; + u32_t remaining; + u32_t len; + u32_t num_read; fl_addr = lba_to_address(start_sector); remaining = (sector_count * SECTOR_SIZE); @@ -77,7 +77,7 @@ int disk_access_read(uint8_t *buff, uint32_t start_sector, num_read = GET_NUM_BLOCK(remaining, CONFIG_DISK_FLASH_MAX_RW_SIZE); - for (uint32_t i = 0; i < num_read; i++) { + for (u32_t i = 0; i < num_read; i++) { if (remaining < CONFIG_DISK_FLASH_MAX_RW_SIZE) { len = remaining; } @@ -95,13 +95,13 @@ int disk_access_read(uint8_t *buff, uint32_t start_sector, } /* This performs read-copy into an output buffer */ -static int read_copy_flash_block(off_t start_addr, uint32_t size, +static int read_copy_flash_block(off_t start_addr, u32_t size, const void *src_buff, - uint8_t *dest_buff) + u8_t *dest_buff) { off_t fl_addr; - uint32_t num_read; - uint32_t offset = 0; + u32_t num_read; + u32_t offset = 0; /* adjust offset if starting address is not erase-aligned address */ if (start_addr & (CONFIG_DISK_FLASH_ERASE_ALIGNMENT - 1)) { @@ -115,7 +115,7 @@ static int read_copy_flash_block(off_t start_addr, uint32_t size, CONFIG_DISK_FLASH_MAX_RW_SIZE); /* read one block from flash */ - for (uint32_t i = 0; i < num_read; i++) { + for (u32_t i = 0; i < num_read; i++) { int rc; rc = flash_read(flash_dev, @@ -136,11 +136,11 @@ static int read_copy_flash_block(off_t start_addr, uint32_t size, /* input size is either less or equal to a block size, * CONFIG_DISK_ERASE_BLOCK_SIZE. */ -static int update_flash_block(off_t start_addr, uint32_t size, const void *buff) +static int update_flash_block(off_t start_addr, u32_t size, const void *buff) { off_t fl_addr; - uint8_t *src = (uint8_t *)buff; - uint32_t num_write; + u8_t *src = (u8_t *)buff; + u32_t num_write; /* if size is a partial block, perform read-copy with user data */ if (size < CONFIG_DISK_ERASE_BLOCK_SIZE) { @@ -152,7 +152,7 @@ static int update_flash_block(off_t start_addr, uint32_t size, const void *buff) } /* now use the local buffer as the source */ - src = (uint8_t *)fs_buff; + src = (u8_t *)fs_buff; } /* always align starting address for flash write operation */ @@ -169,7 +169,7 @@ static int update_flash_block(off_t start_addr, uint32_t size, const void *buff) num_write = GET_NUM_BLOCK(CONFIG_DISK_ERASE_BLOCK_SIZE, CONFIG_DISK_FLASH_MAX_RW_SIZE); - for (uint32_t i = 0; i < num_write; i++) { + for (u32_t i = 0; i < num_write; i++) { /* flash_write reenabled write-protection so disable it again */ flash_write_protection_set(flash_dev, false); @@ -185,12 +185,12 @@ static int update_flash_block(off_t start_addr, uint32_t size, const void *buff) return 0; } -int disk_access_write(const uint8_t *buff, uint32_t start_sector, - uint32_t sector_count) +int disk_access_write(const u8_t *buff, u32_t start_sector, + u32_t sector_count) { off_t fl_addr; - uint32_t remaining; - uint32_t size; + u32_t remaining; + u32_t size; fl_addr = lba_to_address(start_sector); remaining = (sector_count * SECTOR_SIZE); @@ -254,22 +254,22 @@ int disk_access_write(const uint8_t *buff, uint32_t start_sector, return 0; } -int disk_access_ioctl(uint8_t cmd, void *buff) +int disk_access_ioctl(u8_t cmd, void *buff) { switch (cmd) { case DISK_IOCTL_CTRL_SYNC: return 0; case DISK_IOCTL_GET_SECTOR_COUNT: - *(uint32_t *)buff = CONFIG_DISK_VOLUME_SIZE / SECTOR_SIZE; + *(u32_t *)buff = CONFIG_DISK_VOLUME_SIZE / SECTOR_SIZE; return 0; case DISK_IOCTL_GET_SECTOR_SIZE: - *(uint32_t *) buff = SECTOR_SIZE; + *(u32_t *) buff = SECTOR_SIZE; return 0; case DISK_IOCTL_GET_ERASE_BLOCK_SZ: /* in sectors */ - *(uint32_t *)buff = CONFIG_DISK_ERASE_BLOCK_SIZE / SECTOR_SIZE; + *(u32_t *)buff = CONFIG_DISK_ERASE_BLOCK_SIZE / SECTOR_SIZE; return 0; case DISK_IOCTL_GET_DISK_SIZE: - *(uint32_t *)buff = CONFIG_DISK_VOLUME_SIZE; + *(u32_t *)buff = CONFIG_DISK_VOLUME_SIZE; return 0; default: break; diff --git a/subsys/disk/disk_access_ram.c b/subsys/disk/disk_access_ram.c index 00733b3cf52..6bdaef7fcde 100644 --- a/subsys/disk/disk_access_ram.c +++ b/subsys/disk/disk_access_ram.c @@ -22,10 +22,10 @@ * qemu testing (as it may exceed target's RAM limits). */ #define RAMDISK_VOLUME_SIZE (192 * RAMDISK_SECTOR_SIZE) -static uint8_t ramdisk_buf[RAMDISK_VOLUME_SIZE]; +static u8_t ramdisk_buf[RAMDISK_VOLUME_SIZE]; #endif -static void *lba_to_address(uint32_t lba) +static void *lba_to_address(u32_t lba) { __ASSERT(((lba * RAMDISK_SECTOR_SIZE) < RAMDISK_VOLUME_SIZE), "FS bound error"); @@ -43,36 +43,36 @@ int disk_access_init(void) return 0; } -int disk_access_read(uint8_t *buff, uint32_t sector, uint32_t count) +int disk_access_read(u8_t *buff, u32_t sector, u32_t count) { memcpy(buff, lba_to_address(sector), count * RAMDISK_SECTOR_SIZE); return 0; } -int disk_access_write(const uint8_t *buff, uint32_t sector, uint32_t count) +int disk_access_write(const u8_t *buff, u32_t sector, u32_t count) { memcpy(lba_to_address(sector), buff, count * RAMDISK_SECTOR_SIZE); return 0; } -int disk_access_ioctl(uint8_t cmd, void *buff) +int disk_access_ioctl(u8_t cmd, void *buff) { switch (cmd) { case DISK_IOCTL_CTRL_SYNC: break; case DISK_IOCTL_GET_SECTOR_COUNT: - *(uint32_t *)buff = RAMDISK_VOLUME_SIZE / RAMDISK_SECTOR_SIZE; + *(u32_t *)buff = RAMDISK_VOLUME_SIZE / RAMDISK_SECTOR_SIZE; break; case DISK_IOCTL_GET_SECTOR_SIZE: - *(uint32_t *)buff = RAMDISK_SECTOR_SIZE; + *(u32_t *)buff = RAMDISK_SECTOR_SIZE; break; case DISK_IOCTL_GET_ERASE_BLOCK_SZ: - *(uint32_t *)buff = 1; + *(u32_t *)buff = 1; break; case DISK_IOCTL_GET_DISK_SIZE: - *(uint32_t *)buff = RAMDISK_VOLUME_SIZE; + *(u32_t *)buff = RAMDISK_VOLUME_SIZE; break; default: return -EINVAL; diff --git a/subsys/disk/fat12_ramdisk.h b/subsys/disk/fat12_ramdisk.h index 513c45abe58..b0281c4fefc 100644 --- a/subsys/disk/fat12_ramdisk.h +++ b/subsys/disk/fat12_ramdisk.h @@ -11,7 +11,7 @@ * fat table (1, 2), directory table (3) and file(readme) contents (4). */ -static uint8_t ramdisk_buf[RAMDISK_VOLUME_SIZE] = { +static u8_t ramdisk_buf[RAMDISK_VOLUME_SIZE] = { 0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00, 0x01, 0x10, 0x00, 0x20, 0x00, 0xF8, 0x02, 0x00, diff --git a/subsys/fs/fat_fs.c b/subsys/fs/fat_fs.c index a460e6881a8..151825a3e21 100644 --- a/subsys/fs/fat_fs.c +++ b/subsys/fs/fat_fs.c @@ -57,7 +57,7 @@ static int translate_error(int error) int fs_open(fs_file_t *zfp, const char *file_name) { FRESULT res; - uint8_t fs_mode; + u8_t fs_mode; fs_mode = FA_READ | FA_WRITE | FA_OPEN_ALWAYS; @@ -171,7 +171,7 @@ int fs_truncate(fs_file_t *zfp, off_t length) * optimization. */ unsigned int bw; - uint8_t c = 0; + u8_t c = 0; for (int i = cur_length; i < length; i++) { res = f_write(&zfp->fp, &c, 1, &bw); @@ -283,7 +283,7 @@ static int fs_init(struct device *dev) /* If no file system found then create one */ if (res == FR_NO_FILESYSTEM) { - uint8_t work[_MAX_SS]; + u8_t work[_MAX_SS]; res = f_mkfs("", (FM_FAT | FM_SFD), 0, work, sizeof(work)); if (res == FR_OK) { diff --git a/subsys/logging/event_logger.c b/subsys/logging/event_logger.c index 9722508751d..0ea9ebad483 100644 --- a/subsys/logging/event_logger.c +++ b/subsys/logging/event_logger.c @@ -13,15 +13,15 @@ #include void sys_event_logger_init(struct event_logger *logger, - uint32_t *logger_buffer, uint32_t buffer_size) + u32_t *logger_buffer, u32_t buffer_size) { sys_ring_buf_init(&logger->ring_buf, buffer_size, logger_buffer); k_sem_init(&(logger->sync_sema), 0, UINT_MAX); } -static void event_logger_put(struct event_logger *logger, uint16_t event_id, - uint32_t *event_data, uint8_t data_size, +static void event_logger_put(struct event_logger *logger, u16_t event_id, + u32_t *event_data, u8_t data_size, void (*sem_give_fn)(struct k_sem *)) { int ret; @@ -41,8 +41,8 @@ static void event_logger_put(struct event_logger *logger, uint16_t event_id, } -void sys_event_logger_put(struct event_logger *logger, uint16_t event_id, - uint32_t *event_data, uint8_t data_size) +void sys_event_logger_put(struct event_logger *logger, u16_t event_id, + u32_t *event_data, u8_t data_size) { event_logger_put(logger, event_id, event_data, data_size, k_sem_give); } @@ -67,7 +67,7 @@ void sys_event_logger_put(struct event_logger *logger, uint16_t event_id, * @return No return value. */ void _sys_event_logger_put_non_preemptible(struct event_logger *logger, - uint16_t event_id, uint32_t *event_data, uint8_t data_size) + u16_t event_id, u32_t *event_data, u8_t data_size) { extern void _sem_give_non_preemptible(struct k_sem *sem); @@ -77,8 +77,8 @@ void _sys_event_logger_put_non_preemptible(struct event_logger *logger, static int event_logger_get(struct event_logger *logger, - uint16_t *event_id, uint8_t *dropped_event_count, - uint32_t *buffer, uint8_t *buffer_size) + u16_t *event_id, u8_t *dropped_event_count, + u32_t *buffer, u8_t *buffer_size) { int ret; @@ -102,9 +102,9 @@ static int event_logger_get(struct event_logger *logger, } -int sys_event_logger_get(struct event_logger *logger, uint16_t *event_id, - uint8_t *dropped_event_count, uint32_t *buffer, - uint8_t *buffer_size) +int sys_event_logger_get(struct event_logger *logger, u16_t *event_id, + u8_t *dropped_event_count, u32_t *buffer, + u8_t *buffer_size) { if (k_sem_take(&(logger->sync_sema), K_NO_WAIT) == 0) { return event_logger_get(logger, event_id, dropped_event_count, @@ -114,9 +114,9 @@ int sys_event_logger_get(struct event_logger *logger, uint16_t *event_id, } -int sys_event_logger_get_wait(struct event_logger *logger, uint16_t *event_id, - uint8_t *dropped_event_count, uint32_t *buffer, - uint8_t *buffer_size) +int sys_event_logger_get_wait(struct event_logger *logger, u16_t *event_id, + u8_t *dropped_event_count, u32_t *buffer, + u8_t *buffer_size) { k_sem_take(&(logger->sync_sema), K_FOREVER); @@ -127,10 +127,10 @@ int sys_event_logger_get_wait(struct event_logger *logger, uint16_t *event_id, #ifdef CONFIG_SYS_CLOCK_EXISTS int sys_event_logger_get_wait_timeout(struct event_logger *logger, - uint16_t *event_id, - uint8_t *dropped_event_count, - uint32_t *buffer, uint8_t *buffer_size, - uint32_t timeout) + u16_t *event_id, + u8_t *dropped_event_count, + u32_t *buffer, u8_t *buffer_size, + u32_t timeout) { if (k_sem_take(&(logger->sync_sema), __ticks_to_ms(timeout))) { return event_logger_get(logger, event_id, dropped_event_count, diff --git a/subsys/logging/kernel_event_logger.c b/subsys/logging/kernel_event_logger.c index 44847b788f2..224b8cee044 100644 --- a/subsys/logging/kernel_event_logger.c +++ b/subsys/logging/kernel_event_logger.c @@ -19,14 +19,14 @@ struct event_logger sys_k_event_logger; -uint32_t _sys_k_event_logger_buffer[CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE]; +u32_t _sys_k_event_logger_buffer[CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE]; #ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH void *_collector_coop_thread; #endif #ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP -uint32_t _sys_k_event_logger_sleep_start_time; +u32_t _sys_k_event_logger_sleep_start_time; #endif #ifdef CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC @@ -64,9 +64,9 @@ SYS_INIT(_sys_k_event_logger_init, sys_k_timer_func_t _sys_k_get_time = k_cycle_get_32; #endif /* CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP */ -void sys_k_event_logger_put_timed(uint16_t event_id) +void sys_k_event_logger_put_timed(u16_t event_id) { - uint32_t data[1]; + u32_t data[1]; data[0] = _sys_k_get_time(); @@ -78,13 +78,13 @@ void sys_k_event_logger_put_timed(uint16_t event_id) void _sys_k_event_logger_context_switch(void) { extern struct _kernel _kernel; - uint32_t data[2]; + u32_t data[2]; extern void _sys_event_logger_put_non_preemptible( struct event_logger *logger, - uint16_t event_id, - uint32_t *event_data, - uint8_t data_size); + u16_t event_id, + u32_t *event_data, + u8_t data_size); const int event_id = KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID; @@ -102,7 +102,7 @@ void _sys_k_event_logger_context_switch(void) } data[0] = _sys_k_get_time(); - data[1] = (uint32_t)_kernel.current; + data[1] = (u32_t)_kernel.current; /* * The mechanism we use to log the kernel events uses a sync semaphore @@ -141,7 +141,7 @@ void sys_k_event_logger_register_as_collector(void) #ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT void _sys_k_event_logger_interrupt(void) { - uint32_t data[2]; + u32_t data[2]; if (!sys_k_must_log_event(KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID)) { return; @@ -173,7 +173,7 @@ void _sys_k_event_logger_enter_sleep(void) void _sys_k_event_logger_exit_sleep(void) { - uint32_t data[3]; + u32_t data[3]; if (!sys_k_must_log_event(KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID)) { return; diff --git a/subsys/shell/modules/kernel_service.c b/subsys/shell/modules/kernel_service.c index b9ac4145e1b..284b665cbc0 100644 --- a/subsys/shell/modules/kernel_service.c +++ b/subsys/shell/modules/kernel_service.c @@ -13,7 +13,7 @@ static int shell_cmd_version(int argc, char *argv[]) { - uint32_t version = sys_kernel_version_get(); + u32_t version = sys_kernel_version_get(); ARG_UNUSED(argc); ARG_UNUSED(argv); diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 68a9a4ee7c3..411557c6b27 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -426,7 +426,7 @@ static int get_command_to_complete(char *str, char **command_prefix) return (str == NULL) ? dest : -1; } -static uint8_t completion(char *line, uint8_t len) +static u8_t completion(char *line, u8_t len) { const char *first_match = NULL; int common_chars = -1, space = 0; diff --git a/subsys/usb/class/cdc_acm.c b/subsys/usb/class/cdc_acm.c index 24769135a99..f56a8b1b026 100644 --- a/subsys/usb/class/cdc_acm.c +++ b/subsys/usb/class/cdc_acm.c @@ -81,27 +81,27 @@ struct cdc_acm_dev_data_t { /* Callback function pointer */ uart_irq_callback_t cb; /* Tx ready status. Signals when */ - uint8_t tx_ready; - uint8_t rx_ready; /* Rx ready status */ - uint8_t tx_irq_ena; /* Tx interrupt enable status */ - uint8_t rx_irq_ena; /* Rx interrupt enable status */ - uint8_t rx_buf[CDC_ACM_BUFFER_SIZE];/* Internal Rx buffer */ - uint32_t rx_buf_head; /* Head of the internal Rx buffer */ - uint32_t rx_buf_tail; /* Tail of the internal Rx buffer */ + u8_t tx_ready; + u8_t rx_ready; /* Rx ready status */ + u8_t tx_irq_ena; /* Tx interrupt enable status */ + u8_t rx_irq_ena; /* Rx interrupt enable status */ + u8_t rx_buf[CDC_ACM_BUFFER_SIZE];/* Internal Rx buffer */ + u32_t rx_buf_head; /* Head of the internal Rx buffer */ + u32_t rx_buf_tail; /* Tail of the internal Rx buffer */ /* Interface data buffer */ - uint8_t interface_data[CDC_CLASS_REQ_MAX_DATA_SIZE]; + u8_t interface_data[CDC_CLASS_REQ_MAX_DATA_SIZE]; /* CDC ACM line coding properties. LE order */ struct cdc_acm_line_coding line_coding; /* CDC ACM line state bitmap, DTE side */ - uint8_t line_state; + u8_t line_state; /* CDC ACM serial state bitmap, DCE side */ - uint8_t serial_state; + u8_t serial_state; /* CDC ACM notification sent status */ - uint8_t notification_sent; + u8_t notification_sent; }; /* Structure representing the global USB description */ -static const uint8_t cdc_acm_usb_description[] = { +static const u8_t cdc_acm_usb_description[] = { /* Device descriptor */ USB_DEVICE_DESC_SIZE, /* Descriptor size */ USB_DEVICE_DESC, /* Descriptor type */ @@ -255,7 +255,7 @@ static const uint8_t cdc_acm_usb_description[] = { * @return 0 on success, negative errno code on fail. */ int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup, - int32_t *len, uint8_t **data) + s32_t *len, u8_t **data) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev); @@ -271,13 +271,13 @@ int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup, break; case CDC_SET_CONTROL_LINE_STATE: - dev_data->line_state = (uint8_t)sys_le16_to_cpu(pSetup->wValue); + dev_data->line_state = (u8_t)sys_le16_to_cpu(pSetup->wValue); SYS_LOG_DBG("CDC_SET_CONTROL_LINE_STATE 0x%x", dev_data->line_state); break; case CDC_GET_LINE_CODING: - *data = (uint8_t *)(&dev_data->line_coding); + *data = (u8_t *)(&dev_data->line_coding); *len = sizeof(dev_data->line_coding); SYS_LOG_DBG("\nCDC_GET_LINE_CODING %d %d %d %d", sys_le32_to_cpu(dev_data->line_coding.dwDTERate), @@ -303,7 +303,7 @@ int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup, * * @return N/A. */ -static void cdc_acm_bulk_in(uint8_t ep, enum usb_dc_ep_cb_status_code ep_status) +static void cdc_acm_bulk_in(u8_t ep, enum usb_dc_ep_cb_status_code ep_status) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev); @@ -326,12 +326,12 @@ static void cdc_acm_bulk_in(uint8_t ep, enum usb_dc_ep_cb_status_code ep_status) * * @return N/A. */ -static void cdc_acm_bulk_out(uint8_t ep, +static void cdc_acm_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev); - uint32_t bytes_to_read, i, j, buf_head; - uint8_t tmp_buf[4]; + u32_t bytes_to_read, i, j, buf_head; + u8_t tmp_buf[4]; ARG_UNUSED(ep_status); @@ -380,7 +380,7 @@ static void cdc_acm_bulk_out(uint8_t ep, * * @return N/A. */ -static void cdc_acm_int_in(uint8_t ep, enum usb_dc_ep_cb_status_code ep_status) +static void cdc_acm_int_in(u8_t ep, enum usb_dc_ep_cb_status_code ep_status) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev); @@ -473,7 +473,7 @@ static struct usb_cfg_data cdc_acm_config = { * * @return N/A. */ -static void cdc_acm_baudrate_set(struct device *dev, uint32_t baudrate) +static void cdc_acm_baudrate_set(struct device *dev, u32_t baudrate) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -528,10 +528,10 @@ static int cdc_acm_init(struct device *dev) * @return Number of bytes sent. */ static int cdc_acm_fifo_fill(struct device *dev, - const uint8_t *tx_data, int len) + const u8_t *tx_data, int len) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); - uint32_t bytes_written = 0; + u32_t bytes_written = 0; if (dev_data->usb_status != USB_DC_CONFIGURED) { return 0; @@ -552,10 +552,10 @@ static int cdc_acm_fifo_fill(struct device *dev, * * @return Number of bytes read. */ -static int cdc_acm_fifo_read(struct device *dev, uint8_t *rx_data, +static int cdc_acm_fifo_read(struct device *dev, u8_t *rx_data, const int size) { - uint32_t avail_data, bytes_read, i; + u32_t avail_data, bytes_read, i; struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); avail_data = (CDC_ACM_BUFFER_SIZE + dev_data->rx_buf_head - @@ -737,11 +737,11 @@ static void cdc_acm_irq_callback_set(struct device *dev, * * @return N/A. */ -static int cdc_acm_send_notification(struct device *dev, uint16_t serial_state) +static int cdc_acm_send_notification(struct device *dev, u16_t serial_state) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); struct cdc_acm_notification notification; - uint32_t cnt = 0; + u32_t cnt = 0; notification.bmRequestType = 0xA1; notification.bNotificationType = 0x20; @@ -751,11 +751,11 @@ static int cdc_acm_send_notification(struct device *dev, uint16_t serial_state) notification.data = sys_cpu_to_le16(serial_state); dev_data->notification_sent = 0; - usb_write(CDC_ENDP_INT, (const uint8_t *)¬ification, + usb_write(CDC_ENDP_INT, (const u8_t *)¬ification, sizeof(notification), NULL); /* Wait for notification to be sent */ - while (!((volatile uint8_t)dev_data->notification_sent)) { + while (!((volatile u8_t)dev_data->notification_sent)) { k_busy_wait(1); if (++cnt > CDC_CONTROL_SERIAL_STATE_TIMEOUT_US) { @@ -777,7 +777,7 @@ static int cdc_acm_send_notification(struct device *dev, uint16_t serial_state) * @return 0 if successful, failed otherwise. */ static int cdc_acm_line_ctrl_set(struct device *dev, - uint32_t ctrl, uint32_t val) + u32_t ctrl, u32_t val) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -820,7 +820,7 @@ static int cdc_acm_line_ctrl_set(struct device *dev, * @return 0 if successful, failed otherwise. */ static int cdc_acm_line_ctrl_get(struct device *dev, - uint32_t ctrl, uint32_t *val) + u32_t ctrl, u32_t *val) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); diff --git a/subsys/usb/class/cdc_acm.h b/subsys/usb/class/cdc_acm.h index d179c7315d5..d151d4bf014 100644 --- a/subsys/usb/class/cdc_acm.h +++ b/subsys/usb/class/cdc_acm.h @@ -42,19 +42,19 @@ /* Data structure for GET_LINE_CODING / SET_LINE_CODING class requests */ struct cdc_acm_line_coding { - uint32_t dwDTERate; - uint8_t bCharFormat; - uint8_t bParityType; - uint8_t bDataBits; + u32_t dwDTERate; + u8_t bCharFormat; + u8_t bParityType; + u8_t bDataBits; } __packed; struct cdc_acm_notification { - uint8_t bmRequestType; - uint8_t bNotificationType; - uint16_t wValue; - uint16_t wIndex; - uint16_t wLength; - uint16_t data; + u8_t bmRequestType; + u8_t bNotificationType; + u16_t wValue; + u16_t wIndex; + u16_t wLength; + u16_t data; } __packed; /* Intel vendor ID */ diff --git a/subsys/usb/class/mass_storage.c b/subsys/usb/class/mass_storage.c index 0771eb6a335..83692caeb55 100644 --- a/subsys/usb/class/mass_storage.c +++ b/subsys/usb/class/mass_storage.c @@ -59,13 +59,13 @@ static volatile int thread_op; static char __stack mass_thread_stack[DISK_THREAD_STACK_SZ]; static struct k_sem disk_wait_sem; -static volatile uint32_t defered_wr_sz; +static volatile u32_t defered_wr_sz; -static uint8_t page[BLOCK_SIZE]; +static u8_t page[BLOCK_SIZE]; /* Initialized during mass_storage_init() */ -static uint32_t memory_size; -static uint32_t block_count; +static u32_t memory_size; +static u32_t block_count; /* CSW Status */ enum Status { @@ -93,18 +93,18 @@ static struct CBW cbw; static struct CSW csw; /*addr where will be read or written data*/ -static uint32_t addr; +static u32_t addr; /*length of a reading or writing*/ -static uint32_t length; +static u32_t length; -static uint8_t max_lun_count; +static u8_t max_lun_count; /*memory OK (after a memoryVerify)*/ static bool memOK; /* Structure representing the global USB description */ -static const uint8_t mass_usb_description[] = { +static const u8_t mass_usb_description[] = { /* Device descriptor */ USB_DEVICE_DESC_SIZE, /* Descriptor size */ USB_DEVICE_DESC, /* Descriptor type */ @@ -211,14 +211,14 @@ static void msd_init(void) static void sendCSW(void) { csw.Signature = CSW_Signature; - if (usb_write(EPBULK_IN, (uint8_t *)&csw, + if (usb_write(EPBULK_IN, (u8_t *)&csw, sizeof(struct CSW), NULL) != 0) { SYS_LOG_ERR("usb write failure"); } stage = WAIT_CSW; } -static bool write(uint8_t *buf, uint16_t size) +static bool write(u8_t *buf, u16_t size) { if (size >= cbw.DataLength) { size = cbw.DataLength; @@ -248,7 +248,7 @@ static bool write(uint8_t *buf, uint16_t size) * @return 0 on success, negative errno code on fail. */ static int mass_storage_class_handle_req(struct usb_setup_packet *pSetup, - int32_t *len, uint8_t **data) + s32_t *len, u8_t **data) { switch (pSetup->bRequest) { @@ -260,7 +260,7 @@ static int mass_storage_class_handle_req(struct usb_setup_packet *pSetup, case MSC_REQUEST_GET_MAX_LUN: SYS_LOG_DBG("\nMSC_REQUEST_GET_MAX_LUN "); max_lun_count = 0; - *data = (uint8_t *)(&max_lun_count); + *data = (u8_t *)(&max_lun_count); *len = 1; break; @@ -291,7 +291,7 @@ static void testUnitReady(void) static bool requestSense(void) { - uint8_t request_sense[] = { + u8_t request_sense[] = { 0x70, 0x00, 0x05, /* Sense Key: illegal request */ @@ -321,7 +321,7 @@ static bool requestSense(void) static bool inquiryRequest(void) { - uint8_t inquiry[] = { 0x00, 0x80, 0x00, 0x01, + u8_t inquiry[] = { 0x00, 0x80, 0x00, 0x01, 36 - 4, 0x80, 0x00, 0x00, 'Z', 'E', 'P', 'H', 'Y', 'R', ' ', ' ', 'Z', 'E', 'P', 'H', 'Y', 'R', ' ', 'U', 'S', 'B', ' ', 'D', 'I', 'S', 'K', ' ', @@ -336,7 +336,7 @@ static bool inquiryRequest(void) static bool modeSense6(void) { - uint8_t sense6[] = { 0x03, 0x00, 0x00, 0x00 }; + u8_t sense6[] = { 0x03, 0x00, 0x00, 0x00 }; if (!write(sense6, sizeof(sense6))) { return false; @@ -346,16 +346,16 @@ static bool modeSense6(void) static bool readFormatCapacity(void) { - uint8_t capacity[] = { 0x00, 0x00, 0x00, 0x08, - (uint8_t)((block_count >> 24) & 0xff), - (uint8_t)((block_count >> 16) & 0xff), - (uint8_t)((block_count >> 8) & 0xff), - (uint8_t)((block_count >> 0) & 0xff), + u8_t capacity[] = { 0x00, 0x00, 0x00, 0x08, + (u8_t)((block_count >> 24) & 0xff), + (u8_t)((block_count >> 16) & 0xff), + (u8_t)((block_count >> 8) & 0xff), + (u8_t)((block_count >> 0) & 0xff), 0x02, - (uint8_t)((BLOCK_SIZE >> 16) & 0xff), - (uint8_t)((BLOCK_SIZE >> 8) & 0xff), - (uint8_t)((BLOCK_SIZE >> 0) & 0xff), + (u8_t)((BLOCK_SIZE >> 16) & 0xff), + (u8_t)((BLOCK_SIZE >> 8) & 0xff), + (u8_t)((BLOCK_SIZE >> 0) & 0xff), }; if (!write(capacity, sizeof(capacity))) { return false; @@ -365,16 +365,16 @@ static bool readFormatCapacity(void) static bool readCapacity(void) { - uint8_t capacity[] = { - (uint8_t)(((block_count - 1) >> 24) & 0xff), - (uint8_t)(((block_count - 1) >> 16) & 0xff), - (uint8_t)(((block_count - 1) >> 8) & 0xff), - (uint8_t)(((block_count - 1) >> 0) & 0xff), + u8_t capacity[] = { + (u8_t)(((block_count - 1) >> 24) & 0xff), + (u8_t)(((block_count - 1) >> 16) & 0xff), + (u8_t)(((block_count - 1) >> 8) & 0xff), + (u8_t)(((block_count - 1) >> 0) & 0xff), - (uint8_t)((BLOCK_SIZE >> 24) & 0xff), - (uint8_t)((BLOCK_SIZE >> 16) & 0xff), - (uint8_t)((BLOCK_SIZE >> 8) & 0xff), - (uint8_t)((BLOCK_SIZE >> 0) & 0xff), + (u8_t)((BLOCK_SIZE >> 24) & 0xff), + (u8_t)((BLOCK_SIZE >> 16) & 0xff), + (u8_t)((BLOCK_SIZE >> 8) & 0xff), + (u8_t)((BLOCK_SIZE >> 0) & 0xff), }; if (!write(capacity, sizeof(capacity))) { return false; @@ -384,7 +384,7 @@ static bool readCapacity(void) static void thread_memory_read_done(void) { - uint32_t n; + u32_t n; n = (length > MAX_PACKET) ? MAX_PACKET : length; if ((addr + n) > memory_size) { @@ -409,7 +409,7 @@ static void thread_memory_read_done(void) static void memoryRead(void) { - uint32_t n; + u32_t n; n = (length > MAX_PACKET) ? MAX_PACKET : length; if ((addr + n) > memory_size) { @@ -438,7 +438,7 @@ static void memoryRead(void) static bool infoTransfer(void) { - uint32_t n; + u32_t n; /* Logical Block Address of First Block */ n = (cbw.CB[2] << 24) | (cbw.CB[3] << 16) | (cbw.CB[4] << 8) | @@ -496,14 +496,14 @@ static void fail(void) sendCSW(); } -static void CBWDecode(uint8_t *buf, uint16_t size) +static void CBWDecode(u8_t *buf, u16_t size) { if (size != sizeof(cbw)) { SYS_LOG_ERR("size != sizeof(cbw)"); return; } - memcpy((uint8_t *)&cbw, buf, size); + memcpy((u8_t *)&cbw, buf, size); if (cbw.Signature != CBW_Signature) { SYS_LOG_ERR("CBW Signature Mismatch"); return; @@ -603,9 +603,9 @@ static void CBWDecode(uint8_t *buf, uint16_t size) } -static void memoryVerify(uint8_t *buf, uint16_t size) +static void memoryVerify(u8_t *buf, u16_t size) { - uint32_t n; + u32_t n; if ((addr + size) > memory_size) { size = memory_size - addr; @@ -643,7 +643,7 @@ static void memoryVerify(uint8_t *buf, uint16_t size) } } -static void memoryWrite(uint8_t *buf, uint16_t size) +static void memoryWrite(u8_t *buf, u16_t size) { if ((addr + size) > memory_size) { size = memory_size - addr; @@ -679,11 +679,11 @@ static void memoryWrite(uint8_t *buf, uint16_t size) } -static void mass_storage_bulk_out(uint8_t ep, +static void mass_storage_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status) { - uint32_t bytes_read = 0; - uint8_t bo_buf[MASS_STORAGE_BULK_EP_MPS]; + u32_t bytes_read = 0; + u8_t bo_buf[MASS_STORAGE_BULK_EP_MPS]; ARG_UNUSED(ep_status); @@ -734,7 +734,7 @@ static void mass_storage_bulk_out(uint8_t ep, static void thread_memory_write_done(void) { - uint32_t size = defered_wr_sz; + u32_t size = defered_wr_sz; addr += size; length -= size; @@ -759,7 +759,7 @@ static void thread_memory_write_done(void) * * @return N/A. */ -static void mass_storage_bulk_in(uint8_t ep, +static void mass_storage_bulk_in(u8_t ep, enum usb_dc_ep_cb_status_code ep_status) { ARG_UNUSED(ep_status); @@ -901,7 +901,7 @@ static void mass_thread_main(int arg1, int unused) } } -static uint8_t interface_data[64]; +static u8_t interface_data[64]; /** * @brief Initialize USB mass storage setup * @@ -916,7 +916,7 @@ static uint8_t interface_data[64]; static int mass_storage_init(struct device *dev) { int ret; - uint32_t block_size = 0; + u32_t block_size = 0; ARG_UNUSED(dev); diff --git a/subsys/usb/class/mass_storage.h b/subsys/usb/class/mass_storage.h index b38341dc672..39c5358fda1 100644 --- a/subsys/usb/class/mass_storage.h +++ b/subsys/usb/class/mass_storage.h @@ -35,21 +35,21 @@ /* Bulk-only Command Block Wrapper (CBW) */ struct CBW { - uint32_t Signature; - uint32_t Tag; - uint32_t DataLength; - uint8_t Flags; - uint8_t LUN; - uint8_t CBLength; - uint8_t CB[16]; + u32_t Signature; + u32_t Tag; + u32_t DataLength; + u8_t Flags; + u8_t LUN; + u8_t CBLength; + u8_t CB[16]; } __packed; /* Bulk-only Command Status Wrapper (CSW) */ struct CSW { - uint32_t Signature; - uint32_t Tag; - uint32_t DataResidue; - uint8_t Status; + u32_t Signature; + u32_t Tag; + u32_t DataResidue; + u8_t Status; } __packed; /* Intel vendor ID */ diff --git a/subsys/usb/usb_device.c b/subsys/usb/usb_device.c index 948c5b77a23..79048086032 100644 --- a/subsys/usb/usb_device.c +++ b/subsys/usb/usb_device.c @@ -100,27 +100,27 @@ static struct usb_dev_priv { /** Setup packet */ struct usb_setup_packet setup; /** Pointer to data buffer */ - uint8_t *data_buf; + u8_t *data_buf; /** Eemaining bytes in buffer */ - int32_t data_buf_residue; + s32_t data_buf_residue; /** Total length of control transfer */ - int32_t data_buf_len; + s32_t data_buf_len; /** Installed custom request handler */ usb_request_handler custom_req_handler; /** USB stack status clalback */ usb_status_callback status_callback; /** Pointer to registered descriptors */ - const uint8_t *descriptors; + const u8_t *descriptors; /** Array of installed request handler callbacks */ usb_request_handler req_handlers[MAX_NUM_REQ_HANDLERS]; /** Array of installed request data pointers */ - uint8_t *data_store[MAX_NUM_REQ_HANDLERS]; + u8_t *data_store[MAX_NUM_REQ_HANDLERS]; /* Buffer used for storing standard usb request data */ - uint8_t std_req_data[MAX_STD_REQ_MSG_SIZE]; + u8_t std_req_data[MAX_STD_REQ_MSG_SIZE]; /** Variable to check whether the usb has been enabled */ bool enabled; /** Currently selected configuration */ - uint8_t configuration; + u8_t configuration; } usb_dev; /* @@ -158,9 +158,9 @@ static void usb_print_setup(struct usb_setup_packet *setup) * @return true if the request was handles successfully */ static bool usb_handle_request(struct usb_setup_packet *setup, - int32_t *len, uint8_t **data) + s32_t *len, u8_t **data) { - uint32_t type = REQTYPE_GET_TYPE(setup->bmRequestType); + u32_t type = REQTYPE_GET_TYPE(setup->bmRequestType); usb_request_handler handler = usb_dev.req_handlers[type]; SYS_LOG_DBG("** %d **\n", type); @@ -191,7 +191,7 @@ static bool usb_handle_request(struct usb_setup_packet *setup, */ static void usb_data_to_host(void) { - uint32_t chunk = min(MAX_PACKET_SIZE0, usb_dev.data_buf_residue); + u32_t chunk = min(MAX_PACKET_SIZE0, usb_dev.data_buf_residue); /*Always EP0 for control*/ usb_dc_ep_write(0x80, usb_dev.data_buf, chunk, &chunk); @@ -207,11 +207,11 @@ static void usb_data_to_host(void) * * @return N/A */ -static void usb_handle_control_transfer(uint8_t ep, +static void usb_handle_control_transfer(u8_t ep, enum usb_dc_ep_cb_status_code ep_status) { - uint32_t chunk = 0; - uint32_t type = 0; + u32_t chunk = 0; + u32_t type = 0; struct usb_setup_packet *setup = &usb_dev.setup; SYS_LOG_DBG("usb_handle_control_transfer ep %x, status %x\n", ep, @@ -222,7 +222,7 @@ static void usb_handle_control_transfer(uint8_t ep, * reset request message state machine */ if (usb_dc_ep_read(ep, - (uint8_t *)setup, sizeof(*setup), NULL) < 0) { + (u8_t *)setup, sizeof(*setup), NULL) < 0) { SYS_LOG_DBG("Read Setup Packet failed\n"); usb_dc_ep_set_stall(USB_CONTROL_IN_EP0); return; @@ -310,8 +310,8 @@ static void usb_handle_control_transfer(uint8_t ep, * * @return N/A */ -static void usb_register_request_handler(int32_t type, - usb_request_handler handler, uint8_t *data_store) +static void usb_register_request_handler(s32_t type, + usb_request_handler handler, u8_t *data_store) { usb_dev.req_handlers[type] = handler; usb_dev.data_store[type] = data_store; @@ -325,7 +325,7 @@ static void usb_register_request_handler(int32_t type, * * @param [in] usb_descriptors The descriptor byte array */ -static void usb_register_descriptors(const uint8_t *usb_descriptors) +static void usb_register_descriptors(const u8_t *usb_descriptors) { usb_dev.descriptors = usb_descriptors; } @@ -343,13 +343,13 @@ static void usb_register_descriptors(const uint8_t *usb_descriptors) * * @return true if the descriptor was found, false otherwise */ -static bool usb_get_descriptor(uint16_t type_index, uint16_t lang_id, - int32_t *len, uint8_t **data) +static bool usb_get_descriptor(u16_t type_index, u16_t lang_id, + s32_t *len, u8_t **data) { - uint8_t type = 0; - uint8_t index = 0; - uint8_t *p = NULL; - int32_t cur_index = 0; + u8_t type = 0; + u8_t index = 0; + u8_t *p = NULL; + s32_t cur_index = 0; bool found = false; /*Avoid compiler warning until this is used for something*/ @@ -358,7 +358,7 @@ static bool usb_get_descriptor(uint16_t type_index, uint16_t lang_id, type = GET_DESC_TYPE(type_index); index = GET_DESC_INDEX(type_index); - p = (uint8_t *)usb_dev.descriptors; + p = (u8_t *)usb_dev.descriptors; cur_index = 0; while (p[DESC_bLength] != 0) { @@ -407,11 +407,11 @@ static bool usb_get_descriptor(uint16_t type_index, uint16_t lang_id, * * @return true if successfully configured false if error or unconfigured */ -static bool usb_set_configuration(uint8_t config_index, uint8_t alt_setting) +static bool usb_set_configuration(u8_t config_index, u8_t alt_setting) { - uint8_t *p = NULL; - uint8_t cur_config = 0; - uint8_t cur_alt_setting = 0; + u8_t *p = NULL; + u8_t cur_config = 0; + u8_t cur_alt_setting = 0; if (config_index == 0) { /* unconfigure device */ @@ -421,7 +421,7 @@ static bool usb_set_configuration(uint8_t config_index, uint8_t alt_setting) } /* configure endpoints for this configuration/altsetting */ - p = (uint8_t *)usb_dev.descriptors; + p = (u8_t *)usb_dev.descriptors; cur_config = 0xFF; cur_alt_setting = 0xFF; @@ -480,10 +480,10 @@ static bool usb_set_configuration(uint8_t config_index, uint8_t alt_setting) * @return true if the request was handled successfully */ static bool usb_handle_std_device_req(struct usb_setup_packet *setup, - int32_t *len, uint8_t **data_buf) + s32_t *len, u8_t **data_buf) { bool ret = true; - uint8_t *data = *data_buf; + u8_t *data = *data_buf; switch (setup->bRequest) { case REQ_GET_STATUS: @@ -566,9 +566,9 @@ static bool usb_handle_std_device_req(struct usb_setup_packet *setup, * @return true if the request was handled successfully */ static bool usb_handle_std_interface_req(struct usb_setup_packet *setup, - int32_t *len, uint8_t **data_buf) + s32_t *len, u8_t **data_buf) { - uint8_t *data = *data_buf; + u8_t *data = *data_buf; switch (setup->bRequest) { case REQ_GET_STATUS: @@ -612,9 +612,9 @@ static bool usb_handle_std_interface_req(struct usb_setup_packet *setup, * @return true if the request was handled successfully */ static bool usb_handle_std_endpoint_req(struct usb_setup_packet *setup, - int32_t *len, uint8_t **data_buf) + s32_t *len, u8_t **data_buf) { - uint8_t *data = *data_buf; + u8_t *data = *data_buf; switch (setup->bRequest) { case REQ_GET_STATUS: @@ -669,7 +669,7 @@ static bool usb_handle_std_endpoint_req(struct usb_setup_packet *setup, * @return true if the request was handled successfully */ static int usb_handle_standard_request(struct usb_setup_packet *setup, - int32_t *len, uint8_t **data_buf) + s32_t *len, u8_t **data_buf) { int rc = 0; /* try the custom request handler first */ @@ -824,7 +824,7 @@ int usb_deconfig(void) int usb_enable(struct usb_cfg_data *config) { int ret; - uint32_t i; + u32_t i; struct usb_dc_ep_cfg_data ep0_cfg; if (true == usb_dev.enabled) { @@ -911,35 +911,35 @@ int usb_disable(void) return 0; } -int usb_write(uint8_t ep, const uint8_t *data, uint32_t data_len, - uint32_t *bytes_ret) +int usb_write(u8_t ep, const u8_t *data, u32_t data_len, + u32_t *bytes_ret) { return usb_dc_ep_write(ep, data, data_len, bytes_ret); } -int usb_read(uint8_t ep, uint8_t *data, uint32_t max_data_len, - uint32_t *ret_bytes) +int usb_read(u8_t ep, u8_t *data, u32_t max_data_len, + u32_t *ret_bytes) { return usb_dc_ep_read(ep, data, max_data_len, ret_bytes); } -int usb_ep_set_stall(uint8_t ep) +int usb_ep_set_stall(u8_t ep) { return usb_dc_ep_set_stall(ep); } -int usb_ep_clear_stall(uint8_t ep) +int usb_ep_clear_stall(u8_t ep) { return usb_dc_ep_clear_stall(ep); } -int usb_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len, - uint32_t *ret_bytes) +int usb_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len, + u32_t *ret_bytes) { return usb_dc_ep_read_wait(ep, data, max_data_len, ret_bytes); } -int usb_ep_read_continue(uint8_t ep) +int usb_ep_read_continue(u8_t ep) { return usb_dc_ep_read_continue(ep); }