This is a simple driver for manipulating LEDs and reading buttons on any number of OLED1 Xplained Pro wing boards.
The display is not supported by this driver. To operate the display, see Monochrome graphical display system.
Data Structures | |
struct | oled1_instance |
Driver instance struct. More... | |
Macros | |
#define | _OLED1_CREATE_INSTANCE(name, ext_header) |
#define | OLED1_CREATE_INSTANCE(name, ext_header) _OLED1_CREATE_INSTANCE(name, ext_header) |
Create a driver instance. More... | |
Enumerations | |
enum | oled1_button_id { OLED1_BUTTON1_ID, OLED1_BUTTON2_ID, OLED1_BUTTON3_ID } |
IDs for each of the on-board buttons. More... | |
enum | oled1_led_id { OLED1_LED1_ID, OLED1_LED2_ID, OLED1_LED3_ID } |
IDs for each of the on-board LEDs. More... | |
Functions | |
static void | oled1_init (const struct oled1_instance *const oled1) |
Initialize hardware for driver instance. More... | |
Constants | |
#define | OLED1_LED_ACTIVE false |
Active level for LEDs. More... | |
#define | OLED1_BUTTON_ACTIVE false |
Active level for buttons. More... | |
LED manipulation | |
static uint8_t | _oled1_get_led_pin (const struct oled1_instance *const oled1, const enum oled1_led_id led_id) |
Get the pin identifier for a given LED number in instance. More... | |
static bool | oled1_get_led_state (const struct oled1_instance *const oled1, const enum oled1_led_id led_id) |
Get the state of a LED. More... | |
static void | oled1_set_led_state (const struct oled1_instance *const oled1, const enum oled1_led_id led_id, const bool state) |
Set the state of a LED. More... | |
static void | oled1_toggle_led_state (const struct oled1_instance *const oled1, const enum oled1_led_id led_id) |
Set the state of a LED. More... | |
Button manipulation | |
static uint8_t | _oled1_get_button_pin (const struct oled1_instance *const oled1, const enum oled1_button_id button_id) |
Get the pin identifier for a given button number in instance. More... | |
static bool | oled1_get_button_state (const struct oled1_instance *const oled1, const enum oled1_button_id button_id) |
Get the state of a button. More... | |
#define _OLED1_CREATE_INSTANCE | ( | name, | |
ext_header | |||
) |
#define OLED1_BUTTON_ACTIVE false |
Active level for buttons.
Referenced by oled1_get_button_state().
#define OLED1_CREATE_INSTANCE | ( | name, | |
ext_header | |||
) | _OLED1_CREATE_INSTANCE(name, ext_header) |
Create a driver instance.
This macro creates a oled1_instance struct with the specified name, and populates it with pin identifiers that correspond to the specified extension header.
This macro is created for Xplained Pro-style board definitions as it makes use of the EXT_PIN_x macros.
To initialize the hardware, the function oled1_init() must be called on each driver instance.
name | Name to use for driver instance. |
ext_header | Extension header to use, on the form EXTn (f.ex. EXT1). |
#define OLED1_LED_ACTIVE false |
Active level for LEDs.
Referenced by oled1_get_led_state(), oled1_init(), and oled1_set_led_state().
enum oled1_button_id |
enum oled1_led_id |
|
inlinestatic |
Get the pin identifier for a given button number in instance.
oled1_instance | Driver instance to fetch pin identifier from. |
led_id | ID of the button to fetch pin identifier for. |
References oled1_instance::button0_pin, oled1_instance::button1_pin, oled1_instance::button2_pin, OLED1_BUTTON1_ID, OLED1_BUTTON2_ID, and OLED1_BUTTON3_ID.
Referenced by oled1_get_button_state().
|
inlinestatic |
Get the pin identifier for a given LED number in instance.
oled1 | Address of driver instance to fetch pin identifier from. |
led_id | ID of the LED to fetch pin identifier for. |
References oled1_instance::led0_pin, oled1_instance::led1_pin, oled1_instance::led2_pin, OLED1_LED1_ID, OLED1_LED2_ID, and OLED1_LED3_ID.
Referenced by oled1_get_led_state(), oled1_set_led_state(), and oled1_toggle_led_state().
|
inlinestatic |
Get the state of a button.
oled1 | Address of driver instance to operate on. |
led_id | ID of the button to get state of. |
true | if button is active, i.e., pressed. |
false | if button is not active. |
References _oled1_get_button_pin(), OLED1_BUTTON_ACTIVE, and port_pin_get_input_level().
Referenced by main_task().
|
inlinestatic |
Get the state of a LED.
oled1 | Address of driver instance to operate on. |
led_id | ID of the LED to get state of. |
true | if LED is active, i.e., lit up. |
false | if LED is not active. |
References _oled1_get_led_pin(), OLED1_LED_ACTIVE, and port_pin_get_input_level().
|
inlinestatic |
Initialize hardware for driver instance.
This function initializes the hardware (pins) that belong to the specified driver instance.
oled1 | Address of driver instance to initialize hardware for. |
References oled1_instance::button0_pin, oled1_instance::button1_pin, oled1_instance::button2_pin, port_config::direction, port_config::input_pull, oled1_instance::led0_pin, oled1_instance::led1_pin, oled1_instance::led2_pin, OLED1_LED_ACTIVE, port_get_config_defaults(), PORT_PIN_DIR_INPUT, PORT_PIN_DIR_OUTPUT_WTH_READBACK, PORT_PIN_PULL_NONE, PORT_PIN_PULL_UP, port_pin_set_config(), and port_pin_set_output_level().
Referenced by demotasks_init().
|
inlinestatic |
Set the state of a LED.
oled1 | Address of driver instance to operate on. |
led_id | ID of the LED to set state of. |
state | State to set LED to:
|
References _oled1_get_led_pin(), OLED1_LED_ACTIVE, and port_pin_set_output_level().
Referenced by about_task(), graph_task(), main_task(), terminal_task(), and uart_task().
|
inlinestatic |
Set the state of a LED.
oled1 | Address of driver instance to operate on. |
led_id | ID of the LED to toggle state of. |
References _oled1_get_led_pin(), and port_pin_toggle_output_level().