add makefile support for lpcxpresso1347

This commit is contained in:
hathach
2019-05-14 18:34:57 +07:00
parent b55c34564e
commit 2e07a09b0d
7 changed files with 772 additions and 77 deletions
+27 -57
View File
@@ -27,26 +27,25 @@
#include "chip.h"
#include "../board.h"
#define LED_PORT 0
#define LED_PIN 7
#define LED_PORT 0
#define LED_PIN 7
static const struct {
uint8_t port;
uint8_t pin;
} buttons[] =
{
{1, 22 }, // Joystick up
{1, 20 }, // Joystick down
{1, 23 }, // Joystick left
{1, 21 }, // Joystick right
{1, 19 }, // Joystick press
{0, 1 }, // SW3
// {1, 4 }, // SW4 (require to remove J28)
};
// Joytick UP if connected to LPCXpresso Base board
#define BUTTON_PORT 1
#define BUTTON_PIN 22
enum {
BOARD_BUTTON_COUNT = sizeof(buttons) / sizeof(buttons[0])
};
//static const struct {
// uint8_t port;
// uint8_t pin;
//} buttons[] =
//{
// {1, 22 }, // Joystick up
// {1, 20 }, // Joystick down
// {1, 23 }, // Joystick left
// {1, 21 }, // Joystick right
// {1, 19 }, // Joystick press
// {0, 1 }, // SW3
//};
/* System oscillator rate and RTC oscillator rate */
const uint32_t OscRateIn = 12000000;
@@ -91,26 +90,21 @@ void board_init(void)
Chip_GPIO_Init(LPC_GPIO_PORT);
//------------- LED -------------//
// LED
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED_PORT, LED_PIN);
//------------- BUTTON -------------//
// for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++) GPIOSetDir(buttons[i].port, TU_BIT(buttons[i].pin), 0);
// Button
Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
//------------- UART -------------//
//UARTInit(CFG_UART_BAUDRATE);
// USB
Chip_USB_Init(); // Setup PLL clock, and power
// USB: Setup PLL clock, and power
Chip_USB_Init();
}
/*------------------------------------------------------------------*/
/* TUSB HAL MILLISECOND
*------------------------------------------------------------------*/
//--------------------------------------------------------------------+
// Board porting API
//--------------------------------------------------------------------+
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
void SysTick_Handler (void)
{
system_ticks++;
@@ -120,42 +114,19 @@ uint32_t board_millis(void)
{
return system_ticks;
}
#endif
//--------------------------------------------------------------------+
// LEDS
//--------------------------------------------------------------------+
void board_led_write(bool state)
{
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state);
}
//--------------------------------------------------------------------+
// BUTTONS
//--------------------------------------------------------------------+
#if 0
static bool button_read(uint8_t id)
{
(void) id;
// return !GPIOGetPinValue(buttons[id].port, buttons[id].pin); // button is active low
return 0;
}
#endif
uint32_t board_button_read(void)
{
uint32_t result = 0;
// for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++) result |= (button_read(i) ? TU_BIT(i) : 0);
return result;
// active low
return Chip_GPIO_GetPinState(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN) ? 0 : 1;
}
//--------------------------------------------------------------------+
// UART
//--------------------------------------------------------------------+
int board_uart_read(uint8_t* buf, int len)
{
(void) buf;
@@ -165,7 +136,6 @@ int board_uart_read(uint8_t* buf, int len)
int board_uart_write(void const * buf, int len)
{
// UARTSend(&c, 1);
(void) buf;
(void) len;
return 0;