Просмотр исходного кода

change osal_queue_receive() signature

- fix build issue with freertos
hathach 7 лет назад
Родитель
Сommit
10bf41f718

+ 16 - 0
.gitignore

@@ -0,0 +1,16 @@
+/.metadata
+html
+latex
+test_old
+tests/build
+*.d
+*.o
+*.mk
+*.ld
+*.launch
+*.map
+*.axf
+/tests/lpc175x_6x/build/
+/tests/lpc18xx_43xx/build/
+/demos/*/*/Board_*
+/demos/*/*/KeilBuild/

+ 1 - 1
examples/device/nrf52840_freertos/src/msc_flash_qspi.c

@@ -61,7 +61,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
 
 // Callback invoked when received WRITE10 command.
 // Process data in buffer to disk's storage and return number of written bytes
-int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
+int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
 {
   uint32_t addr = lba * CFG_TUD_MSC_BLOCK_SZ + offset;
 

+ 0 - 2
src/device/dcd.h

@@ -125,8 +125,6 @@ void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_
 /*------------------------------------------------------------------*/
 /* Endpoint API
  *------------------------------------------------------------------*/
-
-//------------- Non-control Endpoints -------------//
 bool dcd_edpt_open        (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
 bool dcd_edpt_xfer        (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
 bool dcd_edpt_busy        (uint8_t rhport, uint8_t ep_addr);

+ 12 - 11
src/device/usbd.c

@@ -245,24 +245,25 @@ void usbd_task( void* param)
 {
   (void) param;
 
-  OSAL_TASK_BEGIN
+#if CFG_TUSB_OS != OPT_OS_NONE
+  while (1) {
+#endif
+
   usbd_main_st();
-  OSAL_TASK_END
+
+#if CFG_TUSB_OS != OPT_OS_NONE
+  }
+#endif
 }
 
 static tusb_error_t usbd_main_st(void)
 {
   dcd_event_t event;
-  tusb_error_t err = TUSB_ERROR_NONE;
+
   // Loop until there is no more events in the queue
-  while (_usbd_q->count > 0)
+  while (1)
   {
-    tu_memclr(&event, sizeof(dcd_event_t));
-
-    err = osal_queue_receive(_usbd_q, &event);
-    if (err != TUSB_ERROR_NONE) {
-        break;
-    }
+    if ( !osal_queue_receive(_usbd_q, &event) ) return TUSB_ERROR_NONE;
 
     if ( DCD_EVENT_SETUP_RECEIVED == event.event_id )
     {
@@ -312,7 +313,7 @@ static tusb_error_t usbd_main_st(void)
     }
   }
 
-    return err;
+  return TUSB_ERROR_NONE;
 }
 
 void tud_control_interface_control_complete_cb(uint8_t rhport, uint8_t interface, tusb_control_request_t const * const p_request) {

+ 8 - 2
src/host/usbh.c

@@ -361,9 +361,15 @@ void usbh_enumeration_task(void* param)
 {
   (void) param;
 
-  OSAL_TASK_BEGIN
+#if CFG_TUSB_OS != OPT_OS_NONE
+  while (1) {
+#endif
+
   enumeration_body_subtask();
-  OSAL_TASK_END
+
+#if CFG_TUSB_OS != OPT_OS_NONE
+  }
+#endif
 }
 
 tusb_error_t enumeration_body_subtask(void)

+ 1 - 6
src/osal/osal.h

@@ -62,10 +62,6 @@ typedef void (*osal_task_func_t)( void * );
 
 #if CFG_TUSB_OS == OPT_OS_NONE
   #include "osal_none.h"
-
-  #define OSAL_TASK_BEGIN
-  #define OSAL_TASK_END
-
 #else
   /* RTOS Porting API
    *
@@ -105,8 +101,7 @@ typedef void (*osal_task_func_t)( void * );
     #error CFG_TUSB_OS is not defined or OS is not supported yet
   #endif
 
-  #define OSAL_TASK_BEGIN while(1) {
-  #define OSAL_TASK_END   }
+  // TODO remove subtask related macros later
 
   //------------- Sub Task -------------//
   #define OSAL_SUBTASK_BEGIN

+ 2 - 3
src/osal/osal_freertos.h

@@ -159,10 +159,9 @@ static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef)
   return xQueueCreateStatic(qdef->depth, qdef->item_sz, (uint8_t*) qdef->buf, &qdef->sq);
 }
 
-static inline void osal_queue_receive (osal_queue_t const queue_hdl, void *p_data, uint32_t msec, uint32_t *err)
+static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data)
 {
-  uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec);
-  (*err) = ( xQueueReceive(queue_hdl, p_data, ticks) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT);
+  return xQueueReceive(queue_hdl, data, portMAX_DELAY);
 }
 
 static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)

+ 6 - 5
src/osal/osal_none.h

@@ -89,6 +89,7 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde
 
 static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
 {
+  (void) in_isr;
   sem_hdl->count++;
   return true;
 }
@@ -157,11 +158,11 @@ static inline void osal_queue_reset(osal_queue_t const queue_hdl)
   queue_hdl->count = queue_hdl->rd_idx = queue_hdl->wr_idx = 0;
 }
 
-static inline tusb_error_t osal_queue_receive(osal_queue_t const queue_hdl, void* data) {
-  if (!tu_fifo_read(queue_hdl, data)) {
-    return TUSB_ERROR_OSAL_WAITING;
-  }
-  return TUSB_ERROR_NONE;
+
+static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data)
+{
+  // osal none return immediately without blocking
+  return tu_fifo_read(queue_hdl, data);
 }