mirror of
https://github.com/hathach/tinyusb.git
synced 2026-03-14 19:44:44 +00:00
add IAR warning flags to cmake build and fix them
This commit is contained in:
@ -238,7 +238,7 @@ int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void *buffer, u
|
||||
(void) buffer;
|
||||
(void) bufsize;
|
||||
|
||||
// currently no other commands is supported
|
||||
// currently no other commands are supported
|
||||
|
||||
// Set Sense = Invalid Command Operation
|
||||
(void) tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
|
||||
@ -324,20 +324,17 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
||||
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
||||
// - READ10 and WRITE10 has their own callbacks
|
||||
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
|
||||
// read10 & write10 has their own callback and MUST not be handled here
|
||||
(void) lun;
|
||||
(void) scsi_cmd;
|
||||
(void) buffer;
|
||||
(void) bufsize;
|
||||
|
||||
switch (scsi_cmd[0]) {
|
||||
default:
|
||||
// Set Sense = Invalid Command Operation
|
||||
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
// currently no other commands are supported
|
||||
|
||||
// negative means error -> tinyusb could stall and/or response with failed status
|
||||
return -1;
|
||||
}
|
||||
// Set Sense = Invalid Command Operation
|
||||
(void) tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
|
||||
return -1;
|
||||
return -1; // stall/failed command request;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -65,8 +65,6 @@ int main(void)
|
||||
// printf("Hello, world!\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -215,20 +215,17 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
||||
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
||||
// - READ10 and WRITE10 has their own callbacks
|
||||
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
|
||||
// read10 & write10 has their own callback and MUST not be handled here
|
||||
(void) lun;
|
||||
(void) scsi_cmd;
|
||||
(void) buffer;
|
||||
(void) bufsize;
|
||||
|
||||
switch (scsi_cmd[0]) {
|
||||
default:
|
||||
// Set Sense = Invalid Command Operation
|
||||
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
// currently no other commands are supported
|
||||
|
||||
// negative means error -> tinyusb could stall and/or response with failed status
|
||||
return -1;
|
||||
}
|
||||
// Set Sense = Invalid Command Operation
|
||||
(void) tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
|
||||
return -1;
|
||||
return -1; // stall/failed command request;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -67,8 +67,6 @@ int main(void) {
|
||||
|
||||
hid_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -103,8 +103,6 @@ int main(void) {
|
||||
led_blinking_task(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
@ -276,8 +276,6 @@ int main(void) {
|
||||
sys_check_timeouts(); // service lwip
|
||||
handle_link_state_switch();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* lwip has provision for using a mutex, when applicable */
|
||||
|
||||
@ -534,8 +534,9 @@ bool tud_audio_set_itf_close_ep_cb(uint8_t rhport, tusb_control_request_t const
|
||||
uint8_t const itf = tu_u16_low(tu_le16toh(p_request->wIndex));
|
||||
uint8_t const alt = tu_u16_low(tu_le16toh(p_request->wValue));
|
||||
|
||||
if (ITF_NUM_AUDIO_STREAMING == itf && alt == 0)
|
||||
if (ITF_NUM_AUDIO_STREAMING == itf && alt == 0) {
|
||||
blink_interval_ms = BLINK_MOUNTED;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -569,7 +570,8 @@ bool tud_audio_rx_done_isr(uint8_t rhport, uint16_t n_bytes_received, uint8_t fu
|
||||
|
||||
fifo_count = tud_audio_available();
|
||||
// Same averaging method used in UAC2 class
|
||||
fifo_count_avg = (uint32_t) (((uint64_t) fifo_count_avg * 63 + ((uint32_t) fifo_count << 16)) >> 6);
|
||||
const uint32_t ff_count32 = (uint32_t) fifo_count << 16;
|
||||
fifo_count_avg = (uint32_t) (((uint64_t) fifo_count_avg * 63 + ff_count32) >> 6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -98,8 +98,6 @@ int main(void) {
|
||||
tuh_task(); // tinyusb host task
|
||||
led_blinking_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -74,8 +74,6 @@ int main(void) {
|
||||
tuh_task();
|
||||
led_blinking_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*------------- TinyUSB Callbacks -------------*/
|
||||
|
||||
@ -105,7 +105,6 @@ int main(void) {
|
||||
tuh_task(); // tinyusb host task
|
||||
led_blinking_task(NULL);
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -58,8 +58,6 @@ int main(void) {
|
||||
led_blinking_task();
|
||||
midi_host_rx_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -92,8 +92,6 @@ int main(void) {
|
||||
msc_app_task();
|
||||
led_blinking_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -282,8 +282,6 @@ DRESULT disk_ioctl (
|
||||
default:
|
||||
return RES_PARERR;
|
||||
}
|
||||
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -105,6 +105,12 @@ set(WARN_FLAGS_GNU
|
||||
)
|
||||
set(WARN_FLAGS_Clang ${WARN_FLAGS_GNU})
|
||||
|
||||
set(WARN_FLAGS_IAR
|
||||
--warnings_are_errors
|
||||
--diag_suppress=Pa089
|
||||
--diag_suppress=Pe236
|
||||
)
|
||||
|
||||
# Optimization
|
||||
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
|
||||
@ -467,6 +473,7 @@ function(family_configure_common TARGET RTOS)
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
|
||||
endif ()
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_compile_options(${TARGET} PRIVATE $<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:${WARN_FLAGS_IAR}>)
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:--map=$<TARGET_FILE:${TARGET}>.map")
|
||||
|
||||
if (IAR_CSTAT)
|
||||
|
||||
@ -327,7 +327,7 @@ bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, const tusb_control
|
||||
|
||||
default:
|
||||
if (stage == CONTROL_STAGE_SETUP) {
|
||||
return reply_getstatus(rhport, request, _dfu_ctx.state, _dfu_ctx.status, 0);
|
||||
return reply_getstatus(rhport, request, (dfu_state_t) _dfu_ctx.state, (dfu_status_t) _dfu_ctx.status, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -376,7 +376,7 @@ static bool process_download_get_status(uint8_t rhport, uint8_t stage, const tus
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
return reply_getstatus(rhport, request, next_state, _dfu_ctx.status, timeout);
|
||||
return reply_getstatus(rhport, request, next_state, (dfu_status_t) _dfu_ctx.status, timeout);
|
||||
} else if (stage == CONTROL_STAGE_ACK) {
|
||||
if (_dfu_ctx.flashing_in_progress) {
|
||||
_dfu_ctx.state = DFU_DNBUSY;
|
||||
@ -405,7 +405,7 @@ static bool process_manifest_get_status(uint8_t rhport, uint8_t stage, const tus
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
return reply_getstatus(rhport, request, next_state, _dfu_ctx.status, timeout);
|
||||
return reply_getstatus(rhport, request, next_state, (dfu_status_t) _dfu_ctx.status, timeout);
|
||||
} else if (stage == CONTROL_STAGE_ACK) {
|
||||
if (_dfu_ctx.flashing_in_progress) {
|
||||
_dfu_ctx.state = DFU_MANIFEST;
|
||||
|
||||
@ -30,11 +30,6 @@
|
||||
|
||||
#define TU_FIFO_DBG 0
|
||||
|
||||
// Suppress IAR warning
|
||||
// Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement
|
||||
#if defined(__ICCARM__)
|
||||
#pragma diag_suppress = Pa082
|
||||
#endif
|
||||
|
||||
#if OSAL_MUTEX_REQUIRED
|
||||
|
||||
@ -496,7 +491,9 @@ uint16_t tu_fifo_peek_n_access_mode(tu_fifo_t *f, void *p_buffer, uint16_t n, ui
|
||||
// Read n items without removing it from the FIFO, correct read pointer if overflowed
|
||||
uint16_t tu_fifo_peek_n(tu_fifo_t *f, void *p_buffer, uint16_t n) {
|
||||
ff_lock(f->mutex_rd);
|
||||
const uint16_t ret = tu_fifo_peek_n_access_mode(f, p_buffer, n, f->wr_idx, f->rd_idx, NULL);
|
||||
const uint16_t wr_idx = f->wr_idx;
|
||||
const uint16_t rd_idx = f->rd_idx;
|
||||
const uint16_t ret = tu_fifo_peek_n_access_mode(f, p_buffer, n, wr_idx, rd_idx, NULL);
|
||||
ff_unlock(f->mutex_rd);
|
||||
return ret;
|
||||
}
|
||||
@ -506,7 +503,8 @@ uint16_t tu_fifo_read_n_access_mode(tu_fifo_t *f, void *buffer, uint16_t n, cons
|
||||
ff_lock(f->mutex_rd);
|
||||
|
||||
// Peek the data: f->rd_idx might get modified in case of an overflow so we can not use a local variable
|
||||
n = tu_fifo_peek_n_access_mode(f, buffer, n, f->wr_idx, f->rd_idx, access_mode);
|
||||
const uint16_t wr_idx = f->wr_idx;
|
||||
n = tu_fifo_peek_n_access_mode(f, buffer, n, wr_idx, f->rd_idx, access_mode);
|
||||
f->rd_idx = advance_index(f->depth, f->rd_idx, n);
|
||||
|
||||
ff_unlock(f->mutex_rd);
|
||||
@ -633,7 +631,8 @@ static bool ff_peek_local(tu_fifo_t *f, void *buf, uint16_t wr_idx, uint16_t rd_
|
||||
bool tu_fifo_read(tu_fifo_t *f, void *buffer) {
|
||||
// Peek the data
|
||||
// f->rd_idx might get modified in case of an overflow so we can not use a local variable
|
||||
const bool ret = ff_peek_local(f, buffer, f->wr_idx, f->rd_idx);
|
||||
const uint16_t wr_idx = f->wr_idx;
|
||||
const bool ret = ff_peek_local(f, buffer, wr_idx, f->rd_idx);
|
||||
if (ret) {
|
||||
ff_lock(f->mutex_rd);
|
||||
f->rd_idx = advance_index(f->depth, f->rd_idx, 1);
|
||||
@ -645,7 +644,9 @@ bool tu_fifo_read(tu_fifo_t *f, void *buffer) {
|
||||
|
||||
// Read one item without removing it from the FIFO, correct read index if overflowed
|
||||
bool tu_fifo_peek(tu_fifo_t *f, void *p_buffer) {
|
||||
return ff_peek_local(f, p_buffer, f->wr_idx, f->rd_idx);
|
||||
const uint16_t wr_idx = f->wr_idx;
|
||||
const uint16_t rd_idx = f->rd_idx;
|
||||
return ff_peek_local(f, p_buffer, wr_idx, rd_idx);
|
||||
}
|
||||
|
||||
// Write one element into the buffer
|
||||
|
||||
@ -120,9 +120,9 @@ typedef struct {
|
||||
uint8_t *buffer; // buffer pointer
|
||||
uint16_t depth; // max items
|
||||
bool overwritable; // overwritable when full
|
||||
// 1 byte padding here
|
||||
// 1 byte padding here
|
||||
|
||||
volatile uint16_t wr_idx; // write index TODO maybe can drop volatile
|
||||
volatile uint16_t wr_idx; // write index
|
||||
volatile uint16_t rd_idx; // read index
|
||||
|
||||
#if OSAL_MUTEX_REQUIRED
|
||||
@ -289,30 +289,26 @@ TU_ATTR_ALWAYS_INLINE static inline bool tu_fifo_empty(const tu_fifo_t *f) {
|
||||
return wr_idx == rd_idx;
|
||||
}
|
||||
|
||||
// Suppress IAR warning
|
||||
// Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement
|
||||
#if defined(__ICCARM__)
|
||||
#pragma diag_suppress = Pa082
|
||||
#endif
|
||||
|
||||
// return number of items in fifo, capped to fifo's depth
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_count(const tu_fifo_t *f) {
|
||||
return tu_min16(tu_ff_overflow_count(f->depth, f->wr_idx, f->rd_idx), f->depth);
|
||||
const uint16_t wr_idx = f->wr_idx;
|
||||
const uint16_t rd_idx = f->rd_idx;
|
||||
return tu_min16(tu_ff_overflow_count(f->depth, wr_idx, rd_idx), f->depth);
|
||||
}
|
||||
|
||||
// check if fifo is full
|
||||
TU_ATTR_ALWAYS_INLINE static inline bool tu_fifo_full(const tu_fifo_t *f) {
|
||||
return tu_ff_overflow_count(f->depth, f->wr_idx, f->rd_idx) >= f->depth;
|
||||
const uint16_t wr_idx = f->wr_idx;
|
||||
const uint16_t rd_idx = f->rd_idx;
|
||||
return tu_ff_overflow_count(f->depth, wr_idx, rd_idx) >= f->depth;
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_remaining(const tu_fifo_t *f) {
|
||||
return tu_ff_remaining_local(f->depth, f->wr_idx, f->rd_idx);
|
||||
const uint16_t wr_idx = f->wr_idx;
|
||||
const uint16_t rd_idx = f->rd_idx;
|
||||
return tu_ff_remaining_local(f->depth, wr_idx, rd_idx);
|
||||
}
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#pragma diag_default=Pa082
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -141,11 +141,12 @@ TU_ATTR_ALWAYS_INLINE static inline void osal_spin_init(osal_spinlock_t *ctx) {
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline void osal_spin_lock(osal_spinlock_t *ctx, bool in_isr) {
|
||||
if (in_isr) {
|
||||
if (TUP_MCU_MULTIPLE_CORE == 0) {
|
||||
(void) ctx;
|
||||
return; // single core MCU does not need to lock in ISR
|
||||
}
|
||||
#if TUP_MCU_MULTIPLE_CORE
|
||||
*ctx = taskENTER_CRITICAL_FROM_ISR();
|
||||
#else
|
||||
(void) ctx;
|
||||
return; // single core MCU does not need to lock in ISR
|
||||
#endif
|
||||
} else {
|
||||
taskENTER_CRITICAL();
|
||||
}
|
||||
@ -153,11 +154,12 @@ TU_ATTR_ALWAYS_INLINE static inline void osal_spin_lock(osal_spinlock_t *ctx, bo
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline void osal_spin_unlock(osal_spinlock_t *ctx, bool in_isr) {
|
||||
if (in_isr) {
|
||||
if (TUP_MCU_MULTIPLE_CORE == 0) {
|
||||
(void) ctx;
|
||||
return; // single core MCU does not need to lock in ISR
|
||||
}
|
||||
#if TUP_MCU_MULTIPLE_CORE
|
||||
taskEXIT_CRITICAL_FROM_ISR(*ctx);
|
||||
#else
|
||||
(void) ctx;
|
||||
return; // single core MCU does not need to lock in ISR
|
||||
#endif
|
||||
} else {
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user