mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-15 03:40:19 +00:00
integrate & able to run cmsis-rtx with current code base
This commit is contained in:
parent
1f573eecf2
commit
c71f5c6f1b
@ -88,7 +88,7 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="bsp/boards/embedded_artists/oem_base_board|freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="cmsis_rtos_rtx/SRC/IAR|bsp/boards/embedded_artists/oem_base_board|freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
@ -693,12 +693,15 @@
|
||||
<option id="com.crt.advproject.gcc.thumb.1149795974" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.510918973" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="__REDLIB__"/>
|
||||
<listOptionValue builtIn="false" value="__CORTEX_M4F"/>
|
||||
<listOptionValue builtIn="false" value="__CMSIS_RTOS "/>
|
||||
<listOptionValue builtIn="false" value="__FPU_PRESENT"/>
|
||||
<listOptionValue builtIn="false" value="__USE_CMSIS=CMSIS_LPC43xx_DriverLib"/>
|
||||
<listOptionValue builtIn="false" value="CORE_M4"/>
|
||||
<listOptionValue builtIn="false" value="MCU=MCU_LPC43XX"/>
|
||||
<listOptionValue builtIn="false" value="BOARD=BOARD_EA4357"/>
|
||||
<listOptionValue builtIn="false" value="TUSB_CFG_OS=TUSB_OS_FREERTOS"/>
|
||||
<listOptionValue builtIn="false" value="TUSB_CFG_OS_TASK_PRIO=(configMAX_PRIORITIES-5)"/>
|
||||
<listOptionValue builtIn="false" value="TUSB_CFG_OS=TUSB_OS_CMSIS_RTX"/>
|
||||
<listOptionValue builtIn="false" value="TUSB_CFG_OS_TASK_PRIO=osPriorityRealtime"/>
|
||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="__CODE_RED"/>
|
||||
</option>
|
||||
@ -707,8 +710,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/bsp/lpc43xx/CMSIS_LPC43xx_DriverLib/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/bsp}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freertos}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freertos/freertos/Source/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/cmsis_rtos_rtx/INC}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/tinyusb}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src}""/>
|
||||
</option>
|
||||
@ -747,7 +749,7 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="cmsis_rtos_rtx/SRC/IAR|freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
@ -57,9 +57,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KEYBOARD_APP_TASK_PRIO (TUSB_CFG_OS_TASK_PRIO-1)
|
||||
#define MOUSE_APP_TASK_PRIO (KEYBOARD_APP_TASK_PRIO-1)
|
||||
#define LED_BLINKING_APP_TASK_PRIO (tskIDLE_PRIORITY+1)
|
||||
#define KEYBOARD_APP_TASK_PRIO osPriorityNormal
|
||||
#define MOUSE_APP_TASK_PRIO osPriorityNormal
|
||||
#define LED_BLINKING_APP_TASK_PRIO osPriorityNormal
|
||||
#define CDC_SERIAL_APP_TASK_PRIO osPriorityNormal
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
1075
demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
Normal file
1075
demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
Normal file
File diff suppressed because it is too large
Load Diff
1269
demos/host/host_cmsis_rtx/host_cmsis_rtx.uvproj
Normal file
1269
demos/host/host_cmsis_rtx/host_cmsis_rtx.uvproj
Normal file
File diff suppressed because it is too large
Load Diff
@ -695,6 +695,7 @@
|
||||
<option id="com.crt.advproject.gcc.thumb.1149795974" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.510918973" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="__REDLIB__"/>
|
||||
<listOptionValue builtIn="false" value="__FPU_PRESENT"/>
|
||||
<listOptionValue builtIn="false" value="__USE_CMSIS=CMSIS_LPC43xx_DriverLib"/>
|
||||
<listOptionValue builtIn="false" value="CORE_M4"/>
|
||||
<listOptionValue builtIn="false" value="MCU=MCU_LPC43XX"/>
|
||||
|
@ -331,7 +331,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>91</TopLine>
|
||||
<TopLine>94</TopLine>
|
||||
<CurrentLine>102</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\main.c</PathWithFileName>
|
||||
@ -379,7 +379,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>31</TopLine>
|
||||
<TopLine>39</TopLine>
|
||||
<CurrentLine>47</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\mouse_app.c</PathWithFileName>
|
||||
@ -431,12 +431,12 @@
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>50</TopLine>
|
||||
<CurrentLine>86</CurrentLine>
|
||||
<TopLine>75</TopLine>
|
||||
<CurrentLine>80</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName>
|
||||
<FilenameWithoutPath>board_ea4357.c</FilenameWithoutPath>
|
||||
@ -833,10 +833,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>17</ColumnNumber>
|
||||
<ColumnNumber>49</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>342</TopLine>
|
||||
<CurrentLine>349</CurrentLine>
|
||||
<TopLine>343</TopLine>
|
||||
<CurrentLine>355</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>lpc43xx_uart.c</FilenameWithoutPath>
|
||||
@ -939,7 +939,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>145</TopLine>
|
||||
<TopLine>147</TopLine>
|
||||
<CurrentLine>151</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
|
||||
@ -961,10 +961,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>34</ColumnNumber>
|
||||
<ColumnNumber>70</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>68</TopLine>
|
||||
<CurrentLine>71</CurrentLine>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>9</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\vendor\freertos\freertoslpc\FreeRTOSCommonHooks.c</PathWithFileName>
|
||||
<FilenameWithoutPath>FreeRTOSCommonHooks.c</FilenameWithoutPath>
|
||||
@ -1071,12 +1071,12 @@
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>32</ColumnNumber>
|
||||
<ColumnNumber>68</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>127</TopLine>
|
||||
<CurrentLine>172</CurrentLine>
|
||||
<TopLine>5</TopLine>
|
||||
<CurrentLine>31</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\vendor\freertos\freertos\Source\portable\RVDS\ARM_CM4F\port.c</PathWithFileName>
|
||||
<FilenameWithoutPath>port.c</FilenameWithoutPath>
|
||||
|
@ -387,9 +387,9 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>22</ColumnNumber>
|
||||
<ColumnNumber>25</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>61</TopLine>
|
||||
<TopLine>62</TopLine>
|
||||
<CurrentLine>68</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\main.c</PathWithFileName>
|
||||
|
@ -49,7 +49,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
OSAL_TASK_DEF(cdc_serial_task_def, "cdc serial app", cdc_serial_app_task, 128, CDC_SERIAL_APP_TASK_PRIO);
|
||||
OSAL_TASK_DEF("cdc serial app", cdc_serial_app_task, 128, CDC_SERIAL_APP_TASK_PRIO);
|
||||
OSAL_QUEUE_DEF(queue_def, QUEUE_SERIAL_DEPTH, uint8_t);
|
||||
|
||||
static osal_queue_handle_t queue_hdl;
|
||||
@ -112,9 +112,10 @@ void cdc_serial_app_init(void)
|
||||
{
|
||||
memclr_(buffer_in, sizeof(buffer_in));
|
||||
|
||||
ASSERT( TUSB_ERROR_NONE == osal_task_create(&cdc_serial_task_def), (void) 0 );
|
||||
queue_hdl = osal_queue_create(&queue_def);
|
||||
queue_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_def) );
|
||||
ASSERT_PTR( queue_hdl, (void) 0 );
|
||||
|
||||
ASSERT( TUSB_ERROR_NONE == osal_task_create(OSAL_TASK_REF(cdc_serial_app_task)), (void) 0 );
|
||||
}
|
||||
|
||||
//------------- main task -------------//
|
||||
|
@ -55,7 +55,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
OSAL_TASK_DEF(keyboard_task_def, "keyboard app", keyboard_app_task, 128, KEYBOARD_APP_TASK_PRIO);
|
||||
OSAL_TASK_DEF("keyboard app", keyboard_app_task, 128, KEYBOARD_APP_TASK_PRIO);
|
||||
OSAL_QUEUE_DEF(queue_kbd_def, QUEUE_KEYBOARD_REPORT_DEPTH, tusb_keyboard_report_t);
|
||||
|
||||
static osal_queue_handle_t queue_kbd_hdl;
|
||||
@ -107,9 +107,11 @@ void keyboard_app_init(void)
|
||||
{
|
||||
memclr_(&usb_keyboard_report, sizeof(tusb_keyboard_report_t));
|
||||
|
||||
ASSERT( TUSB_ERROR_NONE == osal_task_create(&keyboard_task_def), (void) 0 );
|
||||
queue_kbd_hdl = osal_queue_create(&queue_kbd_def);
|
||||
queue_kbd_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_kbd_def) );
|
||||
ASSERT_PTR( queue_kbd_hdl, (void) 0 );
|
||||
|
||||
ASSERT( TUSB_ERROR_NONE == osal_task_create( OSAL_TASK_REF(keyboard_app_task) ) ,
|
||||
(void) 0 );
|
||||
}
|
||||
|
||||
//------------- main task -------------//
|
||||
|
@ -72,7 +72,7 @@
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
OSAL_TASK_FUNCTION( led_blinking_task ) (void* p_task_para);
|
||||
OSAL_TASK_DEF(led_blinking_task_def, "led blinking", led_blinking_task, 128, LED_BLINKING_APP_TASK_PRIO);
|
||||
OSAL_TASK_DEF("led blinking", led_blinking_task, 128, LED_BLINKING_APP_TASK_PRIO);
|
||||
|
||||
void print_greeting(void);
|
||||
static inline void wait_blocking_ms(uint32_t ms);
|
||||
@ -110,7 +110,7 @@ int main(void)
|
||||
tusb_init();
|
||||
|
||||
//------------- application task init -------------//
|
||||
(void) osal_task_create(&led_blinking_task_def);
|
||||
(void) osal_task_create( OSAL_TASK_REF(led_blinking_task) );
|
||||
|
||||
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||
keyboard_app_init();
|
||||
@ -131,9 +131,13 @@ int main(void)
|
||||
//------------- start OS scheduler (never return) -------------//
|
||||
#if TUSB_CFG_OS == TUSB_OS_FREERTOS
|
||||
vTaskStartScheduler();
|
||||
|
||||
#elif TUSB_CFG_OS == TUSB_OS_NONE
|
||||
os_none_start_scheduler();
|
||||
#elif TUSB_CFG_OS == TUSB_OS_CMSIS_RTX
|
||||
while(1)
|
||||
{
|
||||
osDelay(osWaitForever); // CMSIS RTX osKernelStart already started, main() is a task
|
||||
}
|
||||
#else
|
||||
#error need to start RTOS schduler
|
||||
#endif
|
||||
|
@ -56,7 +56,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
OSAL_TASK_DEF(mouse_task_def, "mouse app", mouse_app_task, 128, MOUSE_APP_TASK_PRIO);
|
||||
OSAL_TASK_DEF("mouse app", mouse_app_task, 128, MOUSE_APP_TASK_PRIO);
|
||||
OSAL_QUEUE_DEF(queue_mouse_def, QUEUE_MOUSE_REPORT_DEPTH, tusb_mouse_report_t);
|
||||
|
||||
static osal_queue_handle_t queue_mouse_hdl;
|
||||
@ -109,10 +109,11 @@ void mouse_app_init(void)
|
||||
{
|
||||
memclr_(&usb_mouse_report, sizeof(tusb_mouse_report_t));
|
||||
|
||||
ASSERT( TUSB_ERROR_NONE == osal_task_create(&mouse_task_def), (void) 0 );
|
||||
|
||||
queue_mouse_hdl = osal_queue_create(&queue_mouse_def);
|
||||
queue_mouse_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_mouse_def) );
|
||||
ASSERT_PTR( queue_mouse_hdl, (void) 0 );
|
||||
|
||||
ASSERT( TUSB_ERROR_NONE == osal_task_create( OSAL_TASK_REF(mouse_app_task) ),
|
||||
(void) 0 );
|
||||
}
|
||||
|
||||
//------------- main task -------------//
|
||||
|
@ -57,7 +57,7 @@
|
||||
#endif
|
||||
|
||||
/// n-th Bit
|
||||
#define BIT_(n) (1 << (n))
|
||||
#define BIT_(n) (1U << (n))
|
||||
|
||||
/// set n-th bit of x to 1
|
||||
#define BIT_SET_(x, n) ( (x) | BIT_(n) )
|
||||
|
@ -155,7 +155,7 @@ bool hcd_port_connect_status(uint8_t hostid)
|
||||
|
||||
tusb_speed_t hcd_port_speed_get(uint8_t hostid)
|
||||
{
|
||||
return get_operational_register(hostid)->portsc_bit.nxp_port_speed; // NXP specific port speed
|
||||
return (tusb_speed_t) get_operational_register(hostid)->portsc_bit.nxp_port_speed; // NXP specific port speed
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -58,6 +58,12 @@
|
||||
|
||||
// CAP is abbreviation for Capacity
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// ARCHTECTURE
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Controller
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -58,11 +58,11 @@
|
||||
|
||||
#include "tusb_option.h"
|
||||
|
||||
#define TUSB_OS_NONE 1
|
||||
#define TUSB_OS_FREERTOS 2
|
||||
#define TUSB_OS_CMSIS 3
|
||||
#define TUSB_OS_UCOS2 4
|
||||
#define TUSB_OS_UCOS3 5
|
||||
#define TUSB_OS_NONE 1
|
||||
#define TUSB_OS_FREERTOS 2
|
||||
#define TUSB_OS_CMSIS_RTX 3
|
||||
#define TUSB_OS_UCOS2 4
|
||||
#define TUSB_OS_UCOS3 5
|
||||
|
||||
#ifndef _TEST_
|
||||
|
||||
@ -70,6 +70,8 @@
|
||||
#include "osal_none.h"
|
||||
#elif TUSB_CFG_OS == TUSB_OS_FREERTOS
|
||||
#include "osal_freeRTOS.h"
|
||||
#elif TUSB_CFG_OS == TUSB_OS_CMSIS_RTX
|
||||
#include "osal_cmsis_rtx.h"
|
||||
#else
|
||||
#error TUSB_CFG_OS is not defined or OS is not supported yet
|
||||
#endif
|
||||
|
248
tinyusb/osal/osal_cmsis_rtx.h
Normal file
248
tinyusb/osal/osal_cmsis_rtx.h
Normal file
@ -0,0 +1,248 @@
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@file osal_cmsis_rtx.h
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, hathach (tinyusb.org)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This file is part of the tinyusb stack.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \ingroup TBD
|
||||
* \defgroup TBD
|
||||
* \brief TBD
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_OSAL_CMSIS_RTX_H_
|
||||
#define _TUSB_OSAL_CMSIS_RTX_H_
|
||||
|
||||
#include "osal_common.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TICK API
|
||||
//--------------------------------------------------------------------+
|
||||
#define osal_tick_get osKernelSysTick
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TASK API
|
||||
//--------------------------------------------------------------------+
|
||||
#define OSAL_TASK_FUNCTION(task_func) \
|
||||
void task_func
|
||||
|
||||
typedef osThreadDef_t osal_task_t;
|
||||
|
||||
#define OSAL_TASK_DEF(task_name, task_code, task_stack_depth, task_prio) \
|
||||
osThreadDef(task_code, task_prio, 1, task_stack_depth*4) // stack depth is in bytes
|
||||
|
||||
#define OSAL_TASK_REF(task_name) osThread(task_name)
|
||||
|
||||
static inline tusb_error_t osal_task_create(const osal_task_t *task) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_task_create(const osal_task_t *task)
|
||||
{
|
||||
return ( osThreadCreate(task, NULL) != NULL ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TASK_CREATE_FAILED;
|
||||
}
|
||||
|
||||
#define osal_task_delay(msec) osDelay(msec)
|
||||
|
||||
#define OSAL_TASK_LOOP_BEGIN \
|
||||
while(1) {
|
||||
|
||||
#define OSAL_TASK_LOOP_END \
|
||||
}
|
||||
|
||||
//------------- Sub Task -------------//
|
||||
#define OSAL_SUBTASK_BEGIN // TODO refractor move
|
||||
#define OSAL_SUBTASK_END \
|
||||
return TUSB_ERROR_NONE;
|
||||
|
||||
#define SUBTASK_EXIT(error) return error;
|
||||
|
||||
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \
|
||||
status = subtask
|
||||
|
||||
//------------- Sub Task Assert -------------//
|
||||
#define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
|
||||
#define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||
|
||||
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\
|
||||
func_call; return error
|
||||
|
||||
#define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
|
||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
|
||||
TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
|
||||
|
||||
#define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \
|
||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
|
||||
condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Semaphore API
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct {
|
||||
uint32_t sem_cb[2];
|
||||
}osal_semaphore_t;
|
||||
|
||||
typedef osSemaphoreId osal_semaphore_handle_t;
|
||||
|
||||
#define OSAL_SEM_DEF(name) osal_semaphore_t name
|
||||
#define OSAL_SEM_REF(name) (&name)
|
||||
|
||||
static inline osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem)
|
||||
{
|
||||
return osSemaphoreCreate( &(osSemaphoreDef_t) { p_sem }, 0 );
|
||||
}
|
||||
|
||||
// TODO add timeout (with instant return from ISR option) for semaphore post & queue send
|
||||
static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl)
|
||||
{
|
||||
return (osSemaphoreRelease(sem_hdl) == osOK) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_SEMAPHORE_FAILED;
|
||||
}
|
||||
|
||||
static inline void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
(*p_error) = ( osSemaphoreWait(sem_hdl, msec) > 0 ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}
|
||||
|
||||
static inline void osal_semaphore_reset(osal_semaphore_handle_t const sem_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_semaphore_reset(osal_semaphore_handle_t const sem_hdl)
|
||||
{
|
||||
osSemaphoreWait(sem_hdl, 0); // instant return without putting caller to suspend
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MUTEX API (priority inheritance)
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct {
|
||||
uint32_t mutex_cb[3];
|
||||
}osal_mutex_t;
|
||||
|
||||
typedef osMutexId osal_mutex_handle_t;
|
||||
|
||||
#define OSAL_MUTEX_DEF(name) osal_mutex_t name
|
||||
#define OSAL_MUTEX_REF(name) (&name)
|
||||
|
||||
static inline osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex)
|
||||
{
|
||||
return osMutexCreate( &(osMutexDef_t) {p_mutex} );
|
||||
}
|
||||
|
||||
static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl)
|
||||
{
|
||||
return (osMutexRelease(mutex_hdl) == osOK) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_MUTEX_FAILED;
|
||||
}
|
||||
|
||||
static inline void osal_mutex_wait(osal_mutex_handle_t const mutex_hdl, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_mutex_wait(osal_mutex_handle_t const mutex_hdl, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
(*p_error) = ( osMutexWait(mutex_hdl, msec) == osOK ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}
|
||||
|
||||
static inline void osal_mutex_reset(osal_mutex_handle_t const mutex_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_mutex_reset(osal_mutex_handle_t const mutex_hdl)
|
||||
{
|
||||
osMutexRelease(mutex_hdl);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// QUEUE API (for RTX: osMailQId is osMessageQDef_t.pool)
|
||||
//--------------------------------------------------------------------+
|
||||
typedef osMailQDef_t osal_queue_t;
|
||||
typedef osal_queue_t * osal_queue_handle_t;
|
||||
|
||||
#define OSAL_QUEUE_DEF(name, queue_depth, type)\
|
||||
osMailQDef(name, queue_depth, type);
|
||||
|
||||
#define OSAL_QUEUE_REF(name) osMailQ(name)
|
||||
|
||||
static inline osal_queue_handle_t osal_queue_create(osal_queue_t * const p_queue) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline osal_queue_handle_t osal_queue_create(osal_queue_t * const p_queue)
|
||||
{
|
||||
return (NULL != osMailCreate(p_queue, NULL)) ? p_queue : NULL;
|
||||
}
|
||||
|
||||
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
osEvent evt = osMailGet(queue_hdl->pool, msec);
|
||||
|
||||
if (evt.status != osEventMail)
|
||||
{
|
||||
(*p_error) = TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}else
|
||||
{
|
||||
memcpy(p_data, evt.value.p, queue_hdl->item_sz);
|
||||
osMailFree(queue_hdl->pool, evt.value.p);
|
||||
(*p_error) = TUSB_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data)
|
||||
{
|
||||
void *p_buf = osMailAlloc(queue_hdl->pool, 0); // instantly return in case of sending within ISR (mostly used)
|
||||
if (p_buf == NULL) return TUSB_ERROR_OSAL_QUEUE_FAILED;
|
||||
|
||||
memcpy(p_buf, data, queue_hdl->item_sz);
|
||||
osMailPut(queue_hdl->pool, p_buf);
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
static inline void osal_queue_flush(osal_queue_handle_t const queue_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_queue_flush(osal_queue_handle_t const queue_hdl)
|
||||
{
|
||||
osEvent evt;
|
||||
|
||||
while( (evt = osMailGet(queue_hdl->pool, 0) ).status == osEventMail )
|
||||
{
|
||||
osMailFree(queue_hdl->pool, evt.value.p);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_OSAL_CMSIS_RTX_H_ */
|
||||
|
||||
/** @} */
|
@ -120,7 +120,6 @@ static inline void osal_task_delay(uint32_t msec)
|
||||
status = subtask
|
||||
|
||||
//------------- Sub Task Assert -------------//
|
||||
|
||||
#define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
|
||||
#define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||
|
||||
@ -178,7 +177,7 @@ typedef xSemaphoreHandle osal_mutex_handle_t;
|
||||
static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl)
|
||||
{
|
||||
return (xSemaphoreGive(mutex_hdl) == pdPASS) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_SEMAPHORE_FAILED;
|
||||
return (xSemaphoreGive(mutex_hdl) == pdPASS) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_MUTEX_FAILED;
|
||||
}
|
||||
|
||||
static inline void osal_mutex_wait(osal_mutex_handle_t const mutex_hdl, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
|
2
vendor/cmsis_rtos_rtx/INC/cmsis_os.h
vendored
2
vendor/cmsis_rtos_rtx/INC/cmsis_os.h
vendored
@ -147,7 +147,7 @@ used throughout the whole project.
|
||||
#define osFeature_MessageQ 1 ///< Message Queues: 1=available, 0=not available
|
||||
#define osFeature_Signals 16 ///< maximum number of Signal Flags available per thread
|
||||
#define osFeature_Semaphore 65535 ///< maximum count for \ref osSemaphoreCreate function
|
||||
#define osFeature_Wait 1 ///< osWait function: 1=available, 0=not available
|
||||
#define osFeature_Wait 0 ///< osWait function: 1=available, 0=not available
|
||||
#define osFeature_SysTick 1 ///< osKernelSysTick functions: 1=available, 0=not available
|
||||
|
||||
#if defined (__CC_ARM)
|
||||
|
BIN
vendor/cmsis_rtos_rtx/LIB/ARM/RTX_CM4.lib
vendored
BIN
vendor/cmsis_rtos_rtx/LIB/ARM/RTX_CM4.lib
vendored
Binary file not shown.
6
vendor/cmsis_rtos_rtx/RTX_Conf_CM.c
vendored
6
vendor/cmsis_rtos_rtx/RTX_Conf_CM.c
vendored
@ -76,7 +76,7 @@
|
||||
// <i> Defines the combined stack size for threads with user-provided stack size.
|
||||
// <i> Default: 0
|
||||
#ifndef OS_PRIVSTKSIZE
|
||||
#define OS_PRIVSTKSIZE 0
|
||||
#define OS_PRIVSTKSIZE 1024
|
||||
#endif
|
||||
|
||||
// <q>Check for stack overflow
|
||||
@ -91,7 +91,7 @@
|
||||
// <1=> Privileged mode
|
||||
// <i> Default: Privileged mode
|
||||
#ifndef OS_RUNPRIV
|
||||
#define OS_RUNPRIV 0
|
||||
#define OS_RUNPRIV 1
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
@ -108,7 +108,7 @@
|
||||
// <i> Defines the timer clock value.
|
||||
// <i> Default: 12000000 (12MHz)
|
||||
#ifndef OS_CLOCK
|
||||
#define OS_CLOCK 100000000
|
||||
#define OS_CLOCK 72000000
|
||||
#endif
|
||||
|
||||
// <o>Timer tick value [us] <1-1000000>
|
||||
|
10
vendor/cmsis_rtos_rtx/SRC/ARM/RTX_Lib_CM.uvopt
vendored
10
vendor/cmsis_rtos_rtx/SRC/ARM/RTX_Lib_CM.uvopt
vendored
@ -73,7 +73,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>255</CpuCode>
|
||||
<DllOpt>
|
||||
@ -919,7 +919,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>255</CpuCode>
|
||||
<DllOpt>
|
||||
@ -1381,10 +1381,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>5</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<TopLine>265</TopLine>
|
||||
<CurrentLine>285</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\rt_Mailbox.c</PathWithFileName>
|
||||
<FilenameWithoutPath>rt_Mailbox.c</FilenameWithoutPath>
|
||||
|
@ -4198,7 +4198,7 @@
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>4</Optim>
|
||||
<Optim>1</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
|
Loading…
x
Reference in New Issue
Block a user