Added batch file to create LPC11xx demo. Tidied up the M0 port layer files.

This is a baseline taken before moving the M0 port files to their proper location.
pull/1/head
Richard Barry 13 years ago
parent 7298ffd3f2
commit de570548f0

@ -0,0 +1,51 @@
REM This file should be executed from the command line prior to the first
REM build. It will be necessary to refresh the Eclipse project once the
REM .bat file has been executed (normally just press F5 to refresh).
REM Copies all the required files from their location within the standard
REM FreeRTOS directory structure to under the Eclipse project directory.
REM This permits the Eclipse project to be used in 'managed' mode and without
REM having to setup any linked resources.
REM Have the files already been copied?
IF EXIST Source\FreeRTOS_Source Goto END
REM Create the required directory structure.
MD Source\FreeRTOS_Source
MD Source\FreeRTOS_Source\include
MD Source\FreeRTOS_Source\portable
MD Source\FreeRTOS_Source\portable\GCC
MD Source\FreeRTOS_Source\portable\GCC\ARM_CM0
MD Source\FreeRTOS_Source\portable\MemMang
MD Source\Common_Demo_Tasks
MD Source\Common_Demo_Tasks\include
REM Copy the core kernel files.
copy ..\..\..\Source\tasks.c Source\FreeRTOS_Source
copy ..\..\..\Source\queue.c Source\FreeRTOS_Source
copy ..\..\..\Source\list.c Source\FreeRTOS_Source
copy ..\..\..\Source\timers.c Source\FreeRTOS_Source
REM Copy the common header files
copy ..\..\..\Source\include\*.* Source\FreeRTOS_Source\include
REM Copy the portable layer files
copy ..\..\..\Source\portable\GCC\ARM_CM3\*.* Source\FreeRTOS_Source\portable\GCC\ARM_CM0
REM Copy the basic memory allocation files
copy ..\..\..\Source\portable\MemMang\heap_1.c Source\FreeRTOS_Source\portable\MemMang
REM Copy the files that define the common demo tasks.
copy ..\..\Common\minimal\blocktim.c Source\Common_Demo_Tasks
copy ..\..\Common\minimal\recmutex.c Source\Common_Demo_Tasks
copy ..\..\Common\minimal\countsem.c Source\Common_Demo_Tasks
copy ..\..\Common\minimal\IntQueue.c Source\Common_Demo_Tasks
REM Copy the common demo file headers.
copy ..\..\Common\include\blocktim.h Source\Common_Demo_Tasks\include
copy ..\..\Common\include\recmutex.h Source\Common_Demo_Tasks\include
copy ..\..\Common\include\countsem.h Source\Common_Demo_Tasks\include
copy ..\..\Common\include\IntQueue.h Source\Common_Demo_Tasks\include
: END

@ -103,60 +103,16 @@ static void vPortStartFirstTask( void ) __attribute__ (( naked ));
*/ */
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ) portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{ {
/* Ordering the registers in numerical order on the stack allows a context
switch using 4 ldmia and 2 arithmetic instructions. The alternative, of
having a group of four high registers and a group of four low registers,
and then placing the group of low before the group of high, would require
4 ldmia and 4 arithmetic instructions. Therefore a numerical ordering is
preferred. */
#if 0
/* Simulate the stack frame as it would be created by a context switch /* Simulate the stack frame as it would be created by a context switch
interrupt. */ interrupt. */
pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */
*pxTopOfStack = portINITIAL_XPSR; /* xPSR */ *pxTopOfStack = portINITIAL_XPSR; /* xPSR */
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */ *pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
pxTopOfStack--; pxTopOfStack -= 6; /* LR, R12, R3..R1 */
*pxTopOfStack = 0; /* LR */
pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
pxTopOfStack -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */ pxTopOfStack -= 8; /* R11..R4. */
#else
/* Simulate the stack frame as it would be created by a context switch
interrupt. */
pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */
*pxTopOfStack = portINITIAL_XPSR; /* xPSR */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
pxTopOfStack--;
*pxTopOfStack = 0x14; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x12; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x3; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x2; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x1; /* LR */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
pxTopOfStack--;
*pxTopOfStack = 0x11; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x10; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x09; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x08; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x07; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x06; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x05; /* LR */
pxTopOfStack--;
*pxTopOfStack = 0x04;
#endif
return pxTopOfStack; return pxTopOfStack;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -277,7 +233,7 @@ void PendSV_Handler( void )
" mov r7, r11 \n" " mov r7, r11 \n"
" stmia r0!, {r4-r7} \n" " stmia r0!, {r4-r7} \n"
" \n" " \n"
" push {r3, r14} \n" " push {r3, r14} \n"
" cpsid i \n" " cpsid i \n"
" bl vTaskSwitchContext \n" " bl vTaskSwitchContext \n"
" cpsie i \n" " cpsie i \n"

@ -97,28 +97,23 @@ extern "C" {
/* Scheduler utilities. */ /* Scheduler utilities. */
extern void vPortYieldFromISR( void ); extern void vPortYieldFromISR( void );
#define portYIELD() vPortYieldFromISR()
#define portYIELD() vPortYieldFromISR() #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYieldFromISR()
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYieldFromISR()
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Critical section management. */ /* Critical section management. */
#define portSET_INTERRUPT_MASK() __asm volatile ( " cpsid i " )
#define portCLEAR_INTERRUPT_MASK() __asm volatile ( " cpsie i " )
#define portSET_INTERRUPT_MASK_FROM_ISR() 0;portSET_INTERRUPT_MASK()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) portCLEAR_INTERRUPT_MASK();(void)x
extern void vPortEnterCritical( void ); extern void vPortEnterCritical( void );
extern void vPortExitCritical( void ); extern void vPortExitCritical( void );
#define portSET_INTERRUPT_MASK() __asm volatile ( " cpsid i " )
#define portCLEAR_INTERRUPT_MASK() __asm volatile ( " cpsie i " )
#define portSET_INTERRUPT_MASK_FROM_ISR() 0;portSET_INTERRUPT_MASK()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) portCLEAR_INTERRUPT_MASK();(void)x
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
#define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK()
#define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK()
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. */ /* Task function macros as described on the FreeRTOS.org WEB site. */
@ -132,3 +127,4 @@ extern void vPortExitCritical( void );
#endif #endif
#endif /* PORTMACRO_H */ #endif /* PORTMACRO_H */

@ -67,6 +67,8 @@
* *
*****************************************************************************/ *****************************************************************************/
//#error The batch file Demo\CORTEX_M0_LPC1114_LPCXpresso\RTOSDemo\CreateProjectDirectoryStructure.bat must be executed before the first build. After executing the batch file hit F5 to refrech the Eclipse project, then delete this line.
/* Standard includes. */ /* Standard includes. */
#include "string.h" #include "string.h"
@ -79,7 +81,7 @@
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo, /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
or 0 to run the more comprehensive test and demo application. */ or 0 to run the more comprehensive test and demo application. */
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
/* The bit on port 0 to which the LED is wired. */ /* The bit on port 0 to which the LED is wired. */
#define mainLED_BIT ( 1UL << 7UL ) #define mainLED_BIT ( 1UL << 7UL )
@ -136,6 +138,8 @@ int main( void )
main_full(); main_full();
} }
#endif #endif
return 0;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

Loading…
Cancel
Save