Add J1-19 pin setting as a button
This commit is contained in:
parent
ecbe8c3376
commit
46bb821753
|
@ -54,6 +54,14 @@ void USB0_IRQHandler(void)
|
||||||
#define LED_PIN_FUNCTION kPORT_MuxAsGpio
|
#define LED_PIN_FUNCTION kPORT_MuxAsGpio
|
||||||
#define LED_STATE_ON 0
|
#define LED_STATE_ON 0
|
||||||
|
|
||||||
|
// Button
|
||||||
|
#define BUTTON_PORT GPIOC
|
||||||
|
#define BUTTON_PIN_CLOCK kCLOCK_PortC
|
||||||
|
#define BUTTON_PIN_PORT PORTC
|
||||||
|
#define BUTTON_PIN 9U
|
||||||
|
#define BUTTON_PIN_FUNCTION kPORT_MuxAsGpio
|
||||||
|
#define BUTTON_STATE_ACTIVE 0
|
||||||
|
|
||||||
// UART
|
// UART
|
||||||
#define UART_PORT UART0
|
#define UART_PORT UART0
|
||||||
#define UART_PIN_CLOCK kCLOCK_PortA
|
#define UART_PIN_CLOCK kCLOCK_PortA
|
||||||
|
@ -86,6 +94,18 @@ void board_init(void)
|
||||||
GPIO_PinInit(LED_PORT, LED_PIN, &led_config);
|
GPIO_PinInit(LED_PORT, LED_PIN, &led_config);
|
||||||
board_led_write(false);
|
board_led_write(false);
|
||||||
|
|
||||||
|
#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
|
||||||
|
// Button
|
||||||
|
CLOCK_EnableClock(BUTTON_PIN_CLOCK);
|
||||||
|
port_pin_config_t button_port = {
|
||||||
|
.pullSelect = kPORT_PullUp,
|
||||||
|
.mux = BUTTON_PIN_FUNCTION,
|
||||||
|
};
|
||||||
|
PORT_SetPinConfig(BUTTON_PIN_PORT, BUTTON_PIN, &button_port);
|
||||||
|
gpio_pin_config_t button_config = { kGPIO_DigitalInput, 0 };
|
||||||
|
GPIO_PinInit(BUTTON_PORT, BUTTON_PIN, &button_config);
|
||||||
|
#endif
|
||||||
|
|
||||||
// UART
|
// UART
|
||||||
CLOCK_EnableClock(UART_PIN_CLOCK);
|
CLOCK_EnableClock(UART_PIN_CLOCK);
|
||||||
PORT_SetPinMux(UART_PIN_PORT, UART_PIN_RX, UART_PIN_FUNCTION);
|
PORT_SetPinMux(UART_PIN_PORT, UART_PIN_RX, UART_PIN_FUNCTION);
|
||||||
|
@ -119,6 +139,9 @@ void board_led_write(bool state)
|
||||||
|
|
||||||
uint32_t board_button_read(void)
|
uint32_t board_button_read(void)
|
||||||
{
|
{
|
||||||
|
#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
|
||||||
|
return BUTTON_STATE_ACTIVE == GPIO_ReadPinInput(BUTTON_PORT, BUTTON_PIN);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue