This commit is contained in:
hathach 2021-05-27 00:13:07 +07:00
parent 814edec89f
commit c7cecf28c8
No known key found for this signature in database
GPG Key ID: 2FA891220FBFD581
4 changed files with 10 additions and 11 deletions

View File

@ -77,7 +77,7 @@ Supports multiple device configurations by dynamically changing usb descriptors.
TinyUSB is completely thread-safe by pushing all ISR events into a central queue, then process it later in the non-ISR context task function. It also uses semaphore/mutex to access shared resources such as CDC FIFO. Therefore the stack needs to use some of OS's basic APIs. Following OSes are already supported out of the box. TinyUSB is completely thread-safe by pushing all ISR events into a central queue, then process it later in the non-ISR context task function. It also uses semaphore/mutex to access shared resources such as CDC FIFO. Therefore the stack needs to use some of OS's basic APIs. Following OSes are already supported out of the box.
- **No OS** : Disabling USB IRQ is used as way to provide mutex - **No OS**
- **FreeRTOS** - **FreeRTOS**
- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its [own repo](https://github.com/hathach/mynewt-tinyusb-example) - **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its [own repo](https://github.com/hathach/mynewt-tinyusb-example)

View File

@ -53,9 +53,6 @@ extern "C" {
#define tu_fifo_mutex_t osal_mutex_t #define tu_fifo_mutex_t osal_mutex_t
#endif #endif
/** \struct tu_fifo_t
* \brief Simple Circular FIFO
*/
typedef struct typedef struct
{ {
uint8_t* buffer ; ///< buffer pointer uint8_t* buffer ; ///< buffer pointer
@ -104,7 +101,8 @@ bool tu_fifo_clear(tu_fifo_t *f);
bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable); bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable);
#if CFG_FIFO_MUTEX #if CFG_FIFO_MUTEX
static inline void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t write_mutex_hdl, tu_fifo_mutex_t read_mutex_hdl) TU_ATTR_ALWAYS_INLINE static inline
void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t write_mutex_hdl, tu_fifo_mutex_t read_mutex_hdl)
{ {
f->mutex_wr = write_mutex_hdl; f->mutex_wr = write_mutex_hdl;
f->mutex_rd = read_mutex_hdl; f->mutex_rd = read_mutex_hdl;
@ -129,14 +127,15 @@ uint16_t tu_fifo_remaining (tu_fifo_t* f);
bool tu_fifo_overflowed (tu_fifo_t* f); bool tu_fifo_overflowed (tu_fifo_t* f);
void tu_fifo_correct_read_pointer (tu_fifo_t* f); void tu_fifo_correct_read_pointer (tu_fifo_t* f);
static inline uint16_t tu_fifo_depth(tu_fifo_t* f) static inline
uint16_t tu_fifo_depth(tu_fifo_t* f)
{ {
return f->depth; return f->depth;
} }
// Pointer modifications intended to be used in combinations with DMAs. // Pointer modifications intended to be used in combinations with DMAs.
// USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED! // USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED!
void tu_fifo_advance_write_pointer (tu_fifo_t *f, uint16_t n); void tu_fifo_advance_write_pointer(tu_fifo_t *f, uint16_t n);
void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n); void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n);
// If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies // If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies

View File

@ -70,8 +70,8 @@ bool tud_mounted(void);
bool tud_suspended(void); bool tud_suspended(void);
// Check if device is ready to transfer // Check if device is ready to transfer
TU_ATTR_ALWAYS_INLINE TU_ATTR_ALWAYS_INLINE static inline
static inline bool tud_ready(void) bool tud_ready(void)
{ {
return tud_mounted() && !tud_suspended(); return tud_mounted() && !tud_suspended();
} }

View File

@ -94,7 +94,7 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr);
// Check if endpoint is stalled // Check if endpoint is stalled
bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr);
static inline TU_ATTR_ALWAYS_INLINE static inline
bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr) bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr)
{ {
return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr); return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr);