FreeRTOS移植笔记
本次移植的目标板是:easyARM2104. 用ADS1.2作为调试平台。
移植前,看了一下官方的一些参考治疗,我摘抄了一些:
1、configuration the Time tick interrupt. configuration in a function called prvSetupTimerInterrupt(), which located in Port.c
2. set the direction of the stack grown.
How do I create a new port?
First, read the "How FreeRTOS works" section - a link to which can be found on the left menu frame - then ...
- Create a path to your new port under Source/portable. To be consistent, this should take the form ofSource/portable/[compiler_name]/[architecture].
- Create a new file called port.c and place it in the new directory.
- Source/include/portable.h contains prototypes for all the C functions your new port.c file must implement. Each existing port contains a port.c file that can be used as an example. I generally place the code to setup the RTOS tick ISR within sPortStartScheduler().
- Copy Source/portable/GCC/ATMega323/portmacro.h into the new directory - it is easier to start with an existing file than to create it from scratch. Examine the portmacro.h file and edit where necessary - in particular the portENTER_CRITICAL(), portEXIT_CRITICAL(), portENABLE_INTERRUPTS() and portDISABLE_INTERRUPT() definitions will require some consideration.
- Edit Source/include/portable.h so your new portmacro.h file gets included when the new port gets built. You will see how this is done for the existing ports.
- Use the RTOS tasks defined in the demo application files to test your new port - as easy as that ...
这次的移植过程还是很顺利的,因为FreeRTOS源码里面带有很多的demo,我们可以参考相关的demo进行一定的修改就可以了。很快,板上的LED就开始闪烁了。
要移植的函数有:
1、port.c
- portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
- portBASE_TYPE xPortStartScheduler( void )
- void vPortEndScheduler( void )
- static void prvSetupTimerInterrupt( void )
- void vPortEnterCritical( void )
- void vPortExitCritical( void )
- void vTickISR( void )
2、port.s
- void vPortISRStartFirstTask( void )
- void vPortYieldProcessor( void )
- void portDISABLE_INTERRUPTS( void )
- void portENABLE_INTERRUPTS( void )
- portRESTORE_CONTEXT()
- portSAVE_CONTEXT()
3、portMACRO.h
本次移植,基本上都是修改别人的代码,自己编写的不是很多,就不贴代码了。如果有需要的,给我发邮件:chengzi31#gmail.com
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。