From 6e6f470b588be96ed23d0d1670e7a1dea40605bc Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 15 May 2019 17:14:15 +0700 Subject: [PATCH] board clean up, add button for ea4088 --- hw/bsp/ea4088qs/board_ea4088qs.c | 52 +++++++------------ .../board_feather_nrf52840_express.c | 39 ++++++-------- .../lpcxpresso11u68/board_lpcxpresso11u68.c | 26 +++++----- hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c | 26 +++++----- hw/bsp/mcb1800/board_mcb1800.c | 25 ++++----- .../metro_m0_express/board_metro_m0_express.c | 6 ++- .../metro_m4_express/board_metro_m4_express.c | 7 +-- hw/bsp/pca10056/board_pca10056.c | 39 ++++++-------- hw/bsp/stm32f303disc/board_stm32f303disc.c | 6 +-- .../stm32f407g_disc1/board_stm32f407g_disc1.c | 7 ++- 10 files changed, 103 insertions(+), 130 deletions(-) diff --git a/hw/bsp/ea4088qs/board_ea4088qs.c b/hw/bsp/ea4088qs/board_ea4088qs.c index 35baa1a03..4e9f930d2 100644 --- a/hw/bsp/ea4088qs/board_ea4088qs.c +++ b/hw/bsp/ea4088qs/board_ea4088qs.c @@ -30,9 +30,8 @@ #define LED_PORT 2 #define LED_PIN 19 -//--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM DECLARATION -//--------------------------------------------------------------------+ +#define BUTTON_PORT 2 +#define BUTTON_PIN 10 /* System oscillator rate and RTC oscillator rate */ const uint32_t OscRateIn = 12000000; @@ -41,8 +40,11 @@ const uint32_t RTCOscRateIn = 32768; /* Pin muxing configuration */ static const PINMUX_GRP_T pinmuxing[] = { - /* LEDs */ + // LED {2, 19, (IOCON_FUNC0 | IOCON_MODE_INACT)}, + + // Button + {2, 10, (IOCON_FUNC0 | IOCON_MODE_INACT | IOCON_MODE_PULLUP)}, }; static const PINMUX_GRP_T pin_usb_mux[] = @@ -67,7 +69,7 @@ static const PINMUX_GRP_T pin_usb_mux[] = // Invoked by startup code void SystemInit(void) { - /* Enable IOCON clock */ + Chip_IOCON_Init(LPC_IOCON); Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T)); Chip_SetupXtalClocking(); } @@ -86,16 +88,17 @@ void board_init(void) Chip_GPIO_Init(LPC_GPIO); - //------------- LED -------------// + // LED Chip_GPIO_SetPinDIROutput(LPC_GPIO, LED_PORT, LED_PIN); - //------------- BUTTON -------------// -// for(uint8_t i=0; iStCtrl = 0x3; - - Chip_IOCON_SetPinMuxing(LPC_IOCON, pin_usb_mux, sizeof(pin_usb_mux) / sizeof(PINMUX_GRP_T)); } +//--------------------------------------------------------------------+ +// Board porting API +//--------------------------------------------------------------------+ -//------------- LED -------------// void board_led_write(bool state) { Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state); } -//------------- Buttons -------------// -#if 0 -static bool button_read(uint8_t id) -{ -// return !tu_bit_test( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low -} -#endif - uint32_t board_button_read(void) { - uint32_t result = 0; - -// for(uint8_t i=0; iPUPDR |= GPIO_PUPDR_PUPD10_0; } +//--------------------------------------------------------------------+ +// Board porting API +//--------------------------------------------------------------------+ void board_led_write(bool state) { @@ -98,12 +101,8 @@ uint32_t board_button_read(void) } -/*------------------------------------------------------------------*/ -/* TUSB HAL MILLISECOND - *------------------------------------------------------------------*/ #if CFG_TUSB_OS == OPT_OS_NONE volatile uint32_t system_ticks = 0; - void SysTick_Handler (void) { system_ticks++;