LPC17xx platform for Cortex M port

This commit is contained in:
Natie van Rooyen
2012-10-25 10:41:23 +02:00
parent 9d18dafd72
commit 356685005a
9 changed files with 77 additions and 39 deletions
+3 -4
View File
@@ -8,8 +8,6 @@ ifeq ($(TEST_NAME),)
TEST_NAME = kern1 TEST_NAME = kern1
endif endif
CC = arm-none-eabi-gcc CC = arm-none-eabi-gcc
LN = arm-none-eabi-gcc LN = arm-none-eabi-gcc
AS = arm-none-eabi-gcc AS = arm-none-eabi-gcc
@@ -18,7 +16,7 @@ CFLAGS := $(CFLAGS) -O3 -Os -g3 -Wall -c -mcpu=cortex-m3 -mthumb
AFLAGS := $(AFLAGS) -O3 -Os -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m3 -mthumb AFLAGS := $(AFLAGS) -O3 -Os -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m3 -mthumb
LFLAGS := $(LFLAGS) -O3 -Os -Wall -mcpu=cortex-m3 -mthumb -Wl,-Map=system.map -Tsystem.ld LFLAGS := $(LFLAGS) -O3 -Os -Wall -mcpu=cortex-m3 -mthumb -Wl,-Map=system.map -Tsystem.ld
CDEFS := $(CDEFS) -DATOMTHREADS_TEST='"$(TEST_NAME)"' CDEFS := $(CDEFS) -DATOMTHREADS_TEST='"$(TEST_NAME)"' -DBOARD_MBED_LP1768
ADEFS := $(ADEFS) -D__thumb2__ -DARM_RDI_MONITOR ADEFS := $(ADEFS) -D__thumb2__ -DARM_RDI_MONITOR
LLIBS := $(LLIBS) LLIBS := $(LLIBS)
@@ -39,7 +37,8 @@ ASMS := $(ASMS) \
INCLUDES := $(INCLUDES) \ INCLUDES := $(INCLUDES) \
-I./CMSISv2p00_LPC17xx/inc \ -I$(ATOMTHREADS)/platforms/lpc17xx/CMSISv2p00_LPC17xx/inc \
-I$(ATOMTHREADS)/platforms/lpc17xx \
-I$(ATOMTHREADS) -I$(ATOMTHREADS)
include $(ATOMTHREADS)/ports/cortex_m/Makefile include $(ATOMTHREADS)/ports/cortex_m/Makefile
+10 -3
View File
@@ -11,7 +11,14 @@ NXP LPC17xx Platform
The "lpc17xx" platform contains sources for building the Atomthreads test The "lpc17xx" platform contains sources for building the Atomthreads test
suite for the NXP LPC17xx microcontroller. suite for the NXP LPC17xx microcontroller.
The build was tested on the "mbed NXP LPC1768" board (http://www.mbed.org) The build was tested on the "mbed NXP LPC1768" board (http://www.mbed.org)
and the sources were compiled on Ubuntu 12.0.4 with the GNU ARM tool chain but it should work on any LPC17xx development board where UART0 can be used
using Newlib. to monitor the output of the test.
The NXP LPC17xx microcontrollers use the ARM Cortex M3 processor core. The
source code in this example uses the ARM CMSIS Cortex-M Access Library V2.01
to initialize the platform and Newlib as the runtime library. Also it uses a
driver provided by NXP for the UART. The CMSIS library and the UART driver
are provided as source with the sample and Newlib is expected to be installed
together with the GNU ARM tool chain.
+13
View File
@@ -143,6 +143,19 @@ void LPC17xx_UART_PutString (uint8_t *str)
#endif #endif
} }
/**
* @brief Write a buffer to UART0.
*
* @param buffer: buffer to be written
* @retval None
*/
void LPC17xx_UART_WriteBuffer (uint8_t *buffer, uint32_t len)
{
while (len-- != 0) {
LPC17xx_UART_PutChar(*buffer++);
}
}
/** /**
* @brief Print formatted string. This function takes variable length arguments. * @brief Print formatted string. This function takes variable length arguments.
* *
+1 -1
View File
@@ -29,8 +29,8 @@
void LPC17xx_UART_PutChar (uint8_t); void LPC17xx_UART_PutChar (uint8_t);
uint8_t LPC17xx_UART_GetChar (void); uint8_t LPC17xx_UART_GetChar (void);
void LPC17xx_UART_Init(uint32_t baudrate); void LPC17xx_UART_Init(uint32_t baudrate);
//void LPC17xx_UART_Printf (const uint8_t *format, ...);
void LPC17xx_UART_PutString (uint8_t *str) ; void LPC17xx_UART_PutString (uint8_t *str) ;
void LPC17xx_UART_WriteBuffer (uint8_t *buffer, uint32_t len) ;
#endif // __LPC17xx_UART_H_ #endif // __LPC17xx_UART_H_
+36 -30
View File
@@ -27,31 +27,34 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h>
#include "LPC17xx.h" #include "LPC17xx.h"
#include "drivers/lpc17xx_uart.h" #include "drivers/lpc17xx_uart.h"
#include <stdio.h>
#include "modules.h" #include "modules.h"
#include "atom.h" #include "atom.h"
#include "tests/atomtests.h" #include "tests/atomtests.h"
// for mbed board
#define LED1_GPIO (1 << 18)
#define LED2_GPIO (1 << 20)
#define LED3_GPIO (1 << 21)
#define LED4_GPIO (1 << 23)
#define LED_GET(led) (LPC_GPIO1->FIOSET & led)
#define LED_SET(led, on) { if (on) LPC_GPIO1->FIOSET = led ; else LPC_GPIO1->FIOCLR = led ; }
#define LED_TOGGLE(led) LED_SET(led, !LED_GET(led))
#ifndef ATOMTHREADS_TEST #ifndef ATOMTHREADS_TEST
#define ATOMTHREADS_TEST "kern1" #define ATOMTHREADS_TEST "kern1"
#endif #endif
#define TEST_STACK_BYTE_SIZE 1024 // for mbed board
#define IDLE_STACK_BYTE_SIZE 512 #define MBED_LED1_GPIO (1 << 18)
#define MBED_LED2_GPIO (1 << 20)
#define MBED_LED3_GPIO (1 << 21)
#define MBED_LED4_GPIO (1 << 23)
#define MBED_LED_GET(led) (LPC_GPIO1->FIOSET & led)
#define MBED_LED_SET(led, on) { if (on) LPC_GPIO1->FIOSET = led ; else LPC_GPIO1->FIOCLR = led ; }
#define MBED_LED_TOGGLE(led) MBED_LED_SET(led, !MBED_LED_GET(led))
#define MBED_LED_COUNT(count) MBED_LED_SET(MBED_LED1_GPIO, count & 1) ; MBED_LED_SET(MBED_LED2_GPIO, count & 2) ; \
MBED_LED_SET(MBED_LED3_GPIO, count & 4) ; MBED_LED_SET(MBED_LED4_GPIO, count & 8) ;
#define TEST_STACK_BYTE_SIZE 512
#define IDLE_STACK_BYTE_SIZE 128
static unsigned char test_stack[TEST_STACK_BYTE_SIZE] ; static unsigned char test_stack[TEST_STACK_BYTE_SIZE] ;
static unsigned char idle_stack[IDLE_STACK_BYTE_SIZE] ; static unsigned char idle_stack[IDLE_STACK_BYTE_SIZE] ;
@@ -68,7 +71,6 @@ void
test_thread (uint32_t param) test_thread (uint32_t param)
{ {
uint32_t failures ; uint32_t failures ;
static volatile unsigned int i ;
CRITICAL_STORE ; CRITICAL_STORE ;
failures = test_start () ; failures = test_start () ;
@@ -79,18 +81,28 @@ test_thread (uint32_t param)
CRITICAL_END() ; CRITICAL_END() ;
while(1) { while(1) {
LED_TOGGLE(LED1_GPIO) ; #ifdef BOARD_MBED_LP1768
for (i=0; i<1000000; i++) ; MBED_LED_TOGGLE(MBED_LED1_GPIO) ;
#endif
atomTimerDelay (65) ;
} }
} }
int main(void) { /**
* \b main
*
* Initialize atomthreads and start a test_thread to run the Atomthreads test suite.
*
*/
int
main(void)
{
static volatile unsigned int i ; #ifdef BOARD_MBED_LP1768
LPC_GPIO1->FIODIR |= MBED_LED1_GPIO | MBED_LED2_GPIO | MBED_LED3_GPIO | MBED_LED4_GPIO ;
// mbed board MBED_LED_SET(MBED_LED1_GPIO | MBED_LED2_GPIO | MBED_LED3_GPIO | MBED_LED4_GPIO, 1);
LPC_GPIO1->FIODIR |= LED1_GPIO | LED2_GPIO | LED3_GPIO | LED4_GPIO ; #endif
dbg_format_msg ("\r\nLPC17xx SystemCoreClock = %d\r\n",SystemCoreClock) ; dbg_format_msg ("\r\nLPC17xx SystemCoreClock = %d\r\n",SystemCoreClock) ;
@@ -99,18 +111,12 @@ int main(void) {
dbg_format_msg ("Atomthreads starting %s... \r\n", ATOMTHREADS_TEST) ; dbg_format_msg ("Atomthreads starting %s... \r\n", ATOMTHREADS_TEST) ;
atomOSInit(&idle_stack[0], IDLE_STACK_BYTE_SIZE, TRUE) ; atomOSInit(&idle_stack[0], IDLE_STACK_BYTE_SIZE, TRUE) ;
atomThreadCreate ((ATOM_TCB *)&test_tcb, TEST_THREAD_PRIO, test_thread, 0, &test_stack[0], TEST_STACK_BYTE_SIZE, TRUE); atomThreadCreate ((ATOM_TCB *)&test_tcb, TEST_THREAD_PRIO, test_thread, 0,
&test_stack[0], TEST_STACK_BYTE_SIZE, TRUE);
atomOSStart() ; atomOSStart() ;
while(1) ;
while(1) {
LED_TOGGLE(LED1_GPIO) ;
for (i=0; i<1000000; i++) ;
}
return 0 ; return 0 ;
} }
+2 -1
View File
@@ -50,7 +50,8 @@ dbg_format_msg (char *format, ...)
va_start (args, format) ; va_start (args, format) ;
//CRITICAL_START() ; //CRITICAL_START() ;
vsnprintf ((char*)msg, 256, (char*)format, args) ;
vsniprintf ((char*)msg, 256, (char*)format, args) ;
LPC17xx_UART_PutString (msg) ; LPC17xx_UART_PutString (msg) ;
//CRITICAL_END() ; //CRITICAL_END() ;
+2
View File
@@ -51,6 +51,8 @@ WEAK void IntDefault_Handler(void);
//***************************************************************************** //*****************************************************************************
extern int main(void); extern int main(void);
extern void low_level_init(void);
//***************************************************************************** //*****************************************************************************
// //
// External declaration for the pointer to the stack top from the Linker Script // External declaration for the pointer to the stack top from the Linker Script
+4
View File
@@ -39,7 +39,9 @@
* If stddef.h is available on the platform it is simplest to include it * If stddef.h is available on the platform it is simplest to include it
* from this header, otherwise define below. * from this header, otherwise define below.
*/ */
#ifndef NULL
#define NULL ((void *)(0)) #define NULL ((void *)(0))
#endif
/* Size of each stack entry / stack alignment size (e.g. 32 bits) */ /* Size of each stack entry / stack alignment size (e.g. 32 bits) */
#define STACK_ALIGN_SIZE sizeof(unsigned int) #define STACK_ALIGN_SIZE sizeof(unsigned int)
@@ -56,7 +58,9 @@
* Most of these are available from types.h on this platform, which is * Most of these are available from types.h on this platform, which is
* included above. * included above.
*/ */
#ifndef POINTER
#define POINTER void * #define POINTER void *
#endif
/* * /* *
* *
+6
View File
@@ -51,9 +51,15 @@ typedef char int8_t ;
#endif #endif
/* IO definitions (access restrictions to peripheral registers) */ /* IO definitions (access restrictions to peripheral registers) */
#ifndef __I
#define __I volatile /*!< defines 'read only' permissions */ #define __I volatile /*!< defines 'read only' permissions */
#endif
#ifndef __O
#define __O volatile /*!< defines 'write only' permissions */ #define __O volatile /*!< defines 'write only' permissions */
#endif
#ifndef __IO
#define __IO volatile /*!< defines 'read / write' permissions */ #define __IO volatile /*!< defines 'read / write' permissions */
#endif
#endif /* __TYPES_H__ */ #endif /* __TYPES_H__ */