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
This commit is contained in:
hathach
2014-03-10 13:13:13 +07:00
parent 1c73d2f923
commit ad72db5aea
26 changed files with 1029 additions and 1020 deletions

View File

@@ -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__)

View File

@@ -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

View File

@@ -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);