From ad72db5aeacf7d969f5c091c59a2f279eaf1c19c Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 10 Mar 2014 13:13:13 +0700 Subject: change IAR TUSB_CFG_ATTR_USBRAM to _Pragma("location=\".ahb_sram1\"") instead of @ .ahb_sram1 so that we can place it before the variable for a cleaner code change pipe xfer API buffer from void* to uint8_t* change FIFO_DEF to have a separated buffer to be compatible with IAR\ refractor IAR data alignment pragma --- tinyusb/common/compiler/compiler.h | 4 +++- tinyusb/common/compiler/compiler_iar.h | 12 ++---------- tinyusb/common/fifo.h | 5 +++-- 3 files changed, 8 insertions(+), 13 deletions(-) (limited to 'tinyusb/common') diff --git a/tinyusb/common/compiler/compiler.h b/tinyusb/common/compiler/compiler.h index 738711416..4c81047c7 100644 --- a/tinyusb/common/compiler/compiler.h +++ b/tinyusb/common/compiler/compiler.h @@ -49,6 +49,7 @@ #ifndef _TEST_ #define STATIC_ static #define INLINE_ inline + #define ATTR_TEST_WEAK #if TUSB_CFG_DEBUG == 3 #define ATTR_ALWAYS_INLINE // no inline for debug = 3 @@ -56,12 +57,13 @@ #else #define STATIC_VAR static #endif - #define ATTR_TEST_WEAK + #else #define ATTR_ALWAYS_INLINE #define STATIC_ #define STATIC_VAR #define INLINE_ + #endif #if defined(__GNUC__) diff --git a/tinyusb/common/compiler/compiler_iar.h b/tinyusb/common/compiler/compiler_iar.h index cd94f5b2f..7103ee092 100644 --- a/tinyusb/common/compiler/compiler_iar.h +++ b/tinyusb/common/compiler/compiler_iar.h @@ -57,17 +57,9 @@ #define ATTR_PACKED_STRUCT(x) __packed x #define ATTR_PREPACKED __packed #define ATTR_PACKED +//#define ATTR_SECTION(section) _Pragma((#section)) -#define ATTR_ALIGNED(Bytes) ATTR_ALIGNED_##Bytes -#define ATTR_ALIGNED_4096 _Pragma("data_alignment=4096") -#define ATTR_ALIGNED_2048 _Pragma("data_alignment=2048") -#define ATTR_ALIGNED_256 _Pragma("data_alignment=256") -#define ATTR_ALIGNED_128 _Pragma("data_alignment=128") -#define ATTR_ALIGNED_64 _Pragma("data_alignment=64") -#define ATTR_ALIGNED_48 _Pragma("data_alignment=48") -#define ATTR_ALIGNED_32 _Pragma("data_alignment=32") -#define ATTR_ALIGNED_16 _Pragma("data_alignment=16") -#define ATTR_ALIGNED_4 _Pragma("data_alignment=4") +#define ATTR_ALIGNED(bytes) _Pragma(XSTRING_(data_alignment=##bytes)) #ifndef ATTR_ALWAYS_INLINE /// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified diff --git a/tinyusb/common/fifo.h b/tinyusb/common/fifo.h index daef4a84a..4a518ca0c 100644 --- a/tinyusb/common/fifo.h +++ b/tinyusb/common/fifo.h @@ -55,23 +55,24 @@ */ typedef struct { + uint8_t* const buffer ; ///< buffer pointer uint16_t const depth ; ///< max items uint16_t const item_size ; ///< size of each item volatile uint16_t count ; ///< number of items in queue volatile uint16_t wr_idx ; ///< write pointer volatile uint16_t rd_idx ; ///< read pointer bool overwritable ; - uint8_t buffer[] ; ///< buffer pointer // IRQn_Type irq; } fifo_t; #define FIFO_DEF(name, ff_depth, type, is_overwritable) /*, irq_mutex)*/ \ + uint8_t name##_buffer[ff_depth*sizeof(type)];\ fifo_t name = {\ + .buffer = name##_buffer,\ .depth = ff_depth,\ .item_size = sizeof(type),\ .overwritable = is_overwritable,\ /*.irq = irq_mutex*/\ - .buffer = { [ff_depth*sizeof(type) - 1] = 0 },\ } bool fifo_write(fifo_t* f, void const * p_data); -- cgit v1.3.1