summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-04-07 13:42:48 +0700
committerhathach <[email protected]>2020-04-07 13:42:48 +0700
commit6a9f9718821138ca0f667246406444bc957c2424 (patch)
tree35aa8fcf5392080b74d8938c5bcf565de5b28885 /hw
parent51944f0dc9921660129283effc794b9800d04fbb (diff)
add saola button pin support, esp32 build with board_test
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/esp32s2_saola/esp32s2_saola.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/hw/bsp/esp32s2_saola/esp32s2_saola.c b/hw/bsp/esp32s2_saola/esp32s2_saola.c
index 06590c684..16d054f75 100644
--- a/hw/bsp/esp32s2_saola/esp32s2_saola.c
+++ b/hw/bsp/esp32s2_saola/esp32s2_saola.c
@@ -32,7 +32,10 @@
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
-#define LED_PIN 21
+#define LED_PIN 21
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
// Initialize on-board peripherals : led, button, uart and USB
void board_init(void)
@@ -41,6 +44,11 @@ void board_init(void)
gpio_pad_select_gpio(LED_PIN);
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
+ // Button
+ gpio_pad_select_gpio(BUTTON_PIN);
+ gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
+ gpio_set_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN_ONLY : GPIO_PULLUP_ONLY);
+
// USB Controller Hal init
usb_hal_context_t hal = {
.use_external_phy = false // use built-in PHY
@@ -58,7 +66,7 @@ void board_led_write(bool state)
// a '1' means active (pressed), a '0' means inactive.
uint32_t board_button_read(void)
{
- return 0;
+ return gpio_get_level(BUTTON_PIN) == BUTTON_STATE_ACTIVE;
}
// Get characters from UART