summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-03-01 22:25:24 +0700
committerhathach <[email protected]>2018-03-01 22:25:24 +0700
commit04cace7619596377b38914c375b424b9884e4baa (patch)
treec8b5af26d6a2bed1cddd2657fb8bdbfea4a750a2
parent52ed2547cd450ea1a3abd2501553c4c304515c75 (diff)
correct freertos prio issue
-rw-r--r--mcu/lpc43xx/CMSIS_LPC43xx_DriverLib/inc/LPC43xx.h2
-rw-r--r--tinyusb/osal/osal_freeRTOS.h22
-rw-r--r--vendor/freertos/FreeRTOSConfig.h37
3 files changed, 40 insertions, 21 deletions
diff --git a/mcu/lpc43xx/CMSIS_LPC43xx_DriverLib/inc/LPC43xx.h b/mcu/lpc43xx/CMSIS_LPC43xx_DriverLib/inc/LPC43xx.h
index fd4907684..95010d351 100644
--- a/mcu/lpc43xx/CMSIS_LPC43xx_DriverLib/inc/LPC43xx.h
+++ b/mcu/lpc43xx/CMSIS_LPC43xx_DriverLib/inc/LPC43xx.h
@@ -201,7 +201,7 @@ typedef enum {
#ifdef CORE_M4
#define __CM4_REV 0x0000 /*!< Cortex-M4 Core Revision */
#define __MPU_PRESENT 1 /*!< MPU present or not */
-#define __NVIC_PRIO_BITS 4 /*!< Number of Bits used for Priority Levels */
+#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 1 /*!< FPU present or not */
/** @} */ /* End of group Configuration_of_CMSIS */
diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h
index 33be17c04..befad3fd0 100644
--- a/tinyusb/osal/osal_freeRTOS.h
+++ b/tinyusb/osal/osal_freeRTOS.h
@@ -110,7 +110,7 @@ static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * da
static inline void osal_queue_flush(osal_queue_t const queue_hdl)
{
- xQueueReset(queue_hdl);
+// xQueueReset(queue_hdl);
}
//--------------------------------------------------------------------+
@@ -128,22 +128,34 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl)
{
if (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk)
{
- return xSemaphoreGive(sem_hdl);
+ return xSemaphoreGiveFromISR(sem_hdl, NULL);
}else
{
- return xSemaphoreGiveFromISR(sem_hdl, NULL);
+ return xSemaphoreGive(sem_hdl);
}
}
static inline void osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec, tusb_error_t *p_error)
{
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : osal_tick_from_msec(msec);
- (*p_error) = ( xSemaphoreTake(sem_hdl, ticks) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
+
+ BaseType_t result;
+
+ if (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk)
+ {
+ result = xSemaphoreTakeFromISR(sem_hdl, NULL);
+ }else
+ {
+ result = xSemaphoreTake(sem_hdl, ticks);
+ }
+
+ (*p_error) = result ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
}
static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl)
{
- (void) xSemaphoreTake(sem_hdl, 0);
+ tusb_error_t err;
+ osal_semaphore_wait(sem_hdl, 0, &err);
}
//--------------------------------------------------------------------+
diff --git a/vendor/freertos/FreeRTOSConfig.h b/vendor/freertos/FreeRTOSConfig.h
index d494c55a7..f86880ad7 100644
--- a/vendor/freertos/FreeRTOSConfig.h
+++ b/vendor/freertos/FreeRTOSConfig.h
@@ -13,18 +13,25 @@
#define configCPU_CLOCK_HZ SystemCoreClock
#endif
-#define configUSE_PREEMPTION 1
-#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
-#define configMAX_PRIORITIES (8 )
-#define configMINIMAL_STACK_SIZE (128 )
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )
-#define configMAX_TASK_NAME_LEN 32
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_MUTEXES 1
-#define configUSE_RECURSIVE_MUTEXES 0
-#define configUSE_COUNTING_SEMAPHORES 1
-#define configQUEUE_REGISTRY_SIZE 10 // used to name queue/semaphore with debugger
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES (8 )
+#define configMINIMAL_STACK_SIZE (128 )
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )
+#define configMAX_TASK_NAME_LEN 32
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 0
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 10 // used to name queue/semaphore with debugger
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+
+#define configSUPPORT_STATIC_ALLOCATION 0
/* Hook function related definitions. */
#define configUSE_IDLE_HOOK 1
@@ -80,7 +87,7 @@
#ifdef __NVIC_PRIO_BITS
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
- #define configPRIO_BITS 5 // 32 priority levels FIXME IAR Assembler will wrongly get this default value
+ #define configPRIO_BITS 5 // 32 priority levels
#endif
/* The lowest interrupt priority that can be used in a call to a "set priority"
@@ -95,10 +102,10 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
/* Interrupt priorities used by the kernel port layer itself. These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
-#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+#define configKERNEL_INTERRUPT_PRIORITY configLIBRARY_LOWEST_INTERRUPT_PRIORITY // ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
-#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY //( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#endif /* __FREERTOS_CONFIG__H */