add uart for lpc11uxx and retarget successfully

This commit is contained in:
hathach
2013-01-16 12:43:17 +07:00
parent 54a7668177
commit c004cd4387
12 changed files with 355 additions and 23 deletions
+7 -6
View File
@@ -58,9 +58,8 @@
#include <stdint.h>
#define BSP_TICKS_PER_SECOND 1000
#define BSP_UART_ENABLE 1
#define BSP_UART_BAUDRATE 115200
#define BSP_UART_ENABLE 1
#define BSP_UART_BAUDRATE 115200
/// n-th Bit
@@ -68,9 +67,9 @@
#define BIT_(n) (1 << (n))
#endif
#define BOARD_NGX4330 1
#define BOARD_LPCXPRESSO1347 2
#define BOARD_AT86RF2XX 3
#define BOARD_AT86RF2XX 0
#define BOARD_LPCXPRESSO1347 1
#define BOARD_NGX4330 2
#if BOARD == BOARD_NGX4330
@@ -85,6 +84,8 @@
/// Init board peripherals : Clock, UART, LEDs, Buttons
void board_init(void);
void board_leds(uint32_t mask, uint32_t state);
uint32_t board_uart_send(uint8_t *buffer, uint32_t length);
uint32_t board_uart_recv(uint8_t *buffer, uint32_t length);
extern volatile uint32_t system_ticks;
+25
View File
@@ -41,6 +41,7 @@
#include "LPC11Uxx.h"
#include "lpc11uxx/gpio.h"
#include "lpc11uxx/uart.h"
#define CFG_LED_PORT (1)
#define CFG_LED_PIN (31)
@@ -55,12 +56,36 @@ void board_init(void)
GPIOSetDir(CFG_LED_PORT, CFG_LED_PIN, 1);
board_leds(0x01, 0); // turn off the led first
#if BSP_UART_ENABLE
UARTInit(BSP_UART_BAUDRATE);
#endif
}
//--------------------------------------------------------------------+
// LEDS
//--------------------------------------------------------------------+
void board_leds(uint32_t mask, uint32_t state)
{
if (mask)
GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, mask & state ? CFG_LED_ON : CFG_LED_OFF);
}
//--------------------------------------------------------------------+
// UART
//--------------------------------------------------------------------+
#if BSP_UART_ENABLE
uint32_t board_uart_send(uint8_t *buffer, uint32_t length)
{
UARTSend(buffer, length);
return length;
}
uint32_t board_uart_recv(uint8_t *buffer, uint32_t length)
{
// *buffer = get_key(); TODO cannot find available code for uart getchar
return 0;
}
#endif
#endif
+14 -5
View File
@@ -58,10 +58,14 @@ void board_init(void)
GPIOSetDir(CFG_LED_PORT, CFG_LED_PIN, 1);
LPC_GPIO->CLR[CFG_LED_PORT] = (1 << CFG_LED_PIN);
// Uart Init
#if BSP_UART_ENABLE
UARTInit(BSP_UART_BAUDRATE);
#endif
}
//--------------------------------------------------------------------+
// LEDS
//--------------------------------------------------------------------+
void board_leds(uint32_t mask, uint32_t state)
{
if (mask)
@@ -70,16 +74,21 @@ void board_leds(uint32_t mask, uint32_t state)
}
}
uint32_t board_uart_send(uint8_t *p_buffer, uint32_t length)
//--------------------------------------------------------------------+
// UART
//--------------------------------------------------------------------+
#if BSP_UART_ENABLE
uint32_t board_uart_send(uint8_t *buffer, uint32_t length)
{
UARTSend(p_buffer, length);
UARTSend(buffer, length);
return length;
}
uint32_t board_uart_recv(uint8_t *p_buffer, uint32_t length)
uint32_t board_uart_recv(uint8_t *buffer, uint32_t length)
{
*p_buffer = get_key();
*buffer = get_key();
return 1;
}
#endif
#endif
+1 -1
View File
@@ -48,7 +48,7 @@
int __sys_write (int iFileHandle, char *pcBuffer, int iLength)
{
(void) iFileHandle;
return board_uart_send(pcBuffer, iLength);
return board_uart_send((uint8_t*)pcBuffer, iLength);
}
// Called by bottom level of scanf routine within RedLib C library to read