#ifndef GPIO_H #define GPIO_H #include "types.h" /* GPIO pins used for the LCD display */ #define PIN_DISPLAY_SPI_CLOCK PIN_2 #define PIN_DISPLAY_SPI_MOSI PIN_3 #define PIN_DISPLAY_COMMAND_DATA PIN_18 #define PIN_DISPLAY_CHIP_SELECT PIN_25 #define PIN_DISPLAY_RESET PIN_26 /* GPIO pins used for the touch panel */ #define PIN_TOUCH_PANEL_RESET PIN_10 #define PIN_TOUCH_PANEL_IRQ PIN_28 #define PIN_TOUCH_PANEL_I2C_SDA PIN_06 #define PIN_TOUCH_PANEL_I2C_SCL PIN_07 /* GPIO pins used for the battery management */ #define PIN_BATTERY_CHARGE_INDICATOR PIN_12 #define PIN_BATTERY_VOLTAGE PIN_31 /* GPIO pins used for the button */ #define PIN_BUTTON_ENABLE PIN_15 #define PIN_BUTTON_PRESS PIN_13 /* GPIO pins used for the accelerometer */ #define PIN_ACCEL_I2C_SDA PIN_06 #define PIN_ACCEL_I2C_SCL PIN_07 #define PIN_ACCEL_IRQ PIN_08 /** * The signal level of a GPIO line. */ enum gpio_level { LOW = 0, HIGH = 1, }; /** * The availables GPIO pins on the NRF82832. */ enum gpio_pin { PIN_0 = 0, PIN_1 = 1, PIN_2 = 2, PIN_3 = 3, PIN_4 = 4, PIN_5 = 5, PIN_6 = 6, PIN_7 = 7, PIN_8 = 8, PIN_9 = 9, PIN_10 = 10, PIN_11 = 11, PIN_12 = 12, PIN_13 = 13, PIN_14 = 14, PIN_15 = 15, PIN_16 = 16, PIN_17 = 17, PIN_18 = 18, PIN_19 = 19, PIN_20 = 20, PIN_21 = 21, PIN_22 = 22, PIN_23 = 23, PIN_24 = 24, PIN_25 = 25, PIN_26 = 26, PIN_27 = 27, PIN_28 = 28, PIN_29 = 29, PIN_30 = 30, PIN_31 = 31, }; /** * Init the given pin. * Note that each pin configuration is hardcoded to fit the peripheral it is connected to. */ void gpio_init_pin(enum gpio_pin pin); /** * Disable a GPIO pin. */ u8 gpio_disable_pin(enum gpio_pin pin); /** * Read the current signal level of the given GPIO pin. */ enum gpio_level gpio_read_pin(enum gpio_pin pin); /** * Set the given GPIO pin to the given level. * Returns 0 if the given pin is not an output pin. * Returns 1 if written successfully */ u8 gpio_write_pin(enum gpio_pin pin, enum gpio_level level); #endif