added mbed lpc1768 board

This commit is contained in:
hathach
2019-09-05 14:29:17 +07:00
parent 2e00019aae
commit dd07e743d8
8 changed files with 435 additions and 395 deletions

View File

@@ -27,12 +27,14 @@
#include "chip.h"
#include "../board.h"
#define LED_PORT 0
#define LED_PIN 22
#define LED_PORT 0
#define LED_PIN 22
#define LED_STATE_ON 1
// Joytick Down if connected to LPCXpresso Base board
#define BUTTON_PORT 0
#define BUTTON_PIN 15
// JOYSTICK_DOWN if using LPCXpresso Base Board
#define BUTTON_PORT 0
#define BUTTON_PIN 15
#define BUTTON_STATE_ACTIVE 0
#define BOARD_UART_PORT LPC_UART3
@@ -45,14 +47,14 @@ static const PINMUX_GRP_T pinmuxing[] =
{
{0, 0, IOCON_MODE_INACT | IOCON_FUNC2}, /* TXD3 */
{0, 1, IOCON_MODE_INACT | IOCON_FUNC2}, /* RXD3 */
{0, 22, IOCON_MODE_INACT | IOCON_FUNC0}, /* Led 0 */
{LED_PORT, LED_PIN, IOCON_MODE_INACT | IOCON_FUNC0}, /* Led 0 */
/* Joystick buttons. */
{2, 3, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_UP */
{0, 15, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_DOWN */
{2, 4, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_LEFT */
{0, 16, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_RIGHT */
{0, 17, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_PRESS */
// {2, 3, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_UP */
{BUTTON_PORT, BUTTON_PIN, IOCON_FUNC0 | IOCON_MODE_PULLUP}, /* JOYSTICK_DOWN */
// {2, 4, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_LEFT */
// {0, 16, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_RIGHT */
// {0, 17, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_PRESS */
};
static const PINMUX_GRP_T pin_usb_mux[] =
@@ -147,13 +149,12 @@ void board_init(void)
void board_led_write(bool state)
{
Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state);
Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
}
uint32_t board_button_read(void)
{
// active low
return Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN) ? 0 : 1;
return BUTTON_STATE_ACTIVE == Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
}
int board_uart_read(uint8_t* buf, int len)