summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam D. Jones <[email protected]>2019-09-03 01:19:38 -0400
committerWilliam D. Jones <[email protected]>2019-09-03 01:28:41 -0400
commit4ce8796b2ac098868ade2a13a8f88730b960201e (patch)
treee975b02e74932fae58b0771e86dceffe710d8da4
parentf703a74daa62584b44d162e771cfd31badd0be64 (diff)
board_stm32h743nucleo: Implement user button for mouse/keyboard demo.
-rw-r--r--hw/bsp/stm32h743nucleo/board_stm32h743nucleo.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/hw/bsp/stm32h743nucleo/board_stm32h743nucleo.c b/hw/bsp/stm32h743nucleo/board_stm32h743nucleo.c
index f2d8cecdb..9f4c50692 100644
--- a/hw/bsp/stm32h743nucleo/board_stm32h743nucleo.c
+++ b/hw/bsp/stm32h743nucleo/board_stm32h743nucleo.c
@@ -32,6 +32,8 @@
#define LED_PORT GPIOB
#define LED_PIN GPIO_PIN_0
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
/* PWR, RCC, GPIO (All): AHB4 (D3 domain)
USB{1,2} OTG_{H,F}S: AHB1 (D2 domain)
@@ -164,6 +166,13 @@ void board_init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
// https://community.st.com/s/question/0D50X00009XkYZLSA3/stm32h7-nucleo-usb-fs-cdc
// TODO: Board init actually works fine without this line.
HAL_PWREx_EnableUSBVoltageDetector();
@@ -181,8 +190,7 @@ void board_led_write(bool state)
uint32_t board_button_read(void)
{
- // TODO implement
- return 0;
+ return HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
}
int board_uart_read(uint8_t* buf, int len)