1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <zircon/types.h> 8 9 // TODO(andresoportus): Move to C++/ddktl once astro board driver is converted to C++. 10 11 // clang-format off 12 #define BUTTONS_ID_VOLUME_UP 0x00 13 #define BUTTONS_ID_VOLUME_DOWN 0x01 14 #define BUTTONS_ID_FDR 0x02 15 #define BUTTONS_ID_MIC_MUTE 0x03 16 #define BUTTONS_ID_PLAY_PAUSE 0x04 17 #define BUTTONS_ID_KEY_A 0x05 18 #define BUTTONS_ID_KEY_M 0x06 19 #define BUTTONS_ID_MAX 0x07 20 21 #define BUTTONS_TYPE_DIRECT 0x00 22 #define BUTTONS_TYPE_MATRIX 0x01 23 24 #define BUTTONS_GPIO_TYPE_INTERRUPT 0x01 25 #define BUTTONS_GPIO_TYPE_MATRIX_OUTPUT 0x02 26 27 #define BUTTONS_GPIO_FLAG_INVERTED 0x80 28 // clang-format on 29 30 typedef struct ButtonConfig { 31 uint8_t type; // e.g. BUTTONS_TYPE_DIRECT. 32 uint8_t id; // e.g. BUTTONS_ID_VOLUME_UP. 33 uint8_t gpioA_idx; // For BUTTONS_TYPE_DIRECT only gpioA used and must be 34 // BUTTONS_GPIO_TYPE_INTERRUPT. 35 uint8_t gpioB_idx; // For BUTTONS_TYPE_MATRIX gpioB (column) must be 36 // BUTTONS_GPIO_TYPE_MATRIX_OUTPUT (is driven most of the time) and 37 // gpioA (row) must be BUTTONS_GPIO_TYPE_INTERRUPT (triggers an 38 // interrupt most of the time). 39 // During matrix scans columns are floated and rows are read. 40 zx_duration_t gpio_delay; // For settling during matrix scan. 41 } buttons_button_config_t; 42 43 typedef struct GpioConfig { 44 uint8_t type; // e.g. BUTTONS_GPIO_TYPE_INTERRUPT. 45 uint8_t flags; // e.g. BUTTONS_GPIO_FLAG_INVERTED. 46 union { 47 uint32_t internal_pull; // Only applicable to BUTTONS_GPIO_TYPE_INTERRUPT. 48 uint8_t output_value; // Only applicable to BUTTONS_GPIO_TYPE_MATRIX_OUTPUT. 49 }; 50 } buttons_gpio_config_t; 51