Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OLED1 Xplained Pro LED and button driver

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)
 
#define _OLED1_CREATE_INSTANCE(name, ext_header)
 
#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...
 
#define OLED1_CREATE_INSTANCE(name, ext_header)   _OLED1_CREATE_INSTANCE(name, ext_header)
 Create a driver instance. More...
 
#define OLED1_CREATE_INSTANCE(name, ext_header)   _OLED1_CREATE_INSTANCE(name, ext_header)
 Create a driver instance. More...
 
#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,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID
}
 IDs for each of the on-board buttons. More...
 
enum  oled1_button_id {
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID
}
 IDs for each of the on-board buttons. More...
 
enum  oled1_button_id {
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID
}
 IDs for each of the on-board buttons. More...
 
enum  oled1_button_id {
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_ID,
  OLED1_BUTTON1_ID,
  OLED1_BUTTON2_ID,
  OLED1_BUTTON3_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,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID
}
 IDs for each of the on-board LEDs. More...
 
enum  oled1_led_id {
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID
}
 IDs for each of the on-board LEDs. More...
 
enum  oled1_led_id {
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID
}
 IDs for each of the on-board LEDs. More...
 
enum  oled1_led_id {
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_ID,
  OLED1_LED1_ID,
  OLED1_LED2_ID,
  OLED1_LED3_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...
 

Constants

#define OLED1_LED_ACTIVE   false
 Active level for LEDs. More...
 
#define OLED1_BUTTON_ACTIVE   false
 Active level for buttons. More...
 

Constants

#define OLED1_LED_ACTIVE   false
 Active level for LEDs. More...
 
#define OLED1_BUTTON_ACTIVE   false
 Active level for buttons. More...
 

Constants

#define OLED1_LED_ACTIVE   false
 Active level for LEDs. More...
 
#define OLED1_BUTTON_ACTIVE   false
 Active level for buttons. More...
 

#define _OLED1_CREATE_INSTANCE (   name,
  ext_header 
)
Value:
const struct oled1_instance name = { \
.led0_pin = ext_header ## _PIN_7, \
.led1_pin = ext_header ## _PIN_8, \
.led2_pin = ext_header ## _PIN_6, \
.button0_pin = ext_header ## _PIN_9, \
.button1_pin = ext_header ## _PIN_3, \
.button2_pin = ext_header ## _PIN_4, \
}
uint8_t led0_pin
Pin identifier for first LED.
Definition: oled1_co_routine_xpro_example/oled1.h:104
Driver instance struct.
Definition: oled1_co_routine_xpro_example/oled1.h:102
#define _OLED1_CREATE_INSTANCE (   name,
  ext_header 
)
Value:
const struct oled1_instance name = { \
.led0_pin = ext_header ## _PIN_7, \
.led1_pin = ext_header ## _PIN_8, \
.led2_pin = ext_header ## _PIN_6, \
.button0_pin = ext_header ## _PIN_9, \
.button1_pin = ext_header ## _PIN_3, \
.button2_pin = ext_header ## _PIN_4, \
}
uint8_t led0_pin
Pin identifier for first LED.
Definition: oled1_co_routine_xpro_example/oled1.h:104
Driver instance struct.
Definition: oled1_co_routine_xpro_example/oled1.h:102
#define _OLED1_CREATE_INSTANCE (   name,
  ext_header 
)
Value:
const struct oled1_instance name = { \
.led0_pin = ext_header ## _PIN_7, \
.led1_pin = ext_header ## _PIN_8, \
.led2_pin = ext_header ## _PIN_6, \
.button0_pin = ext_header ## _PIN_9, \
.button1_pin = ext_header ## _PIN_3, \
.button2_pin = ext_header ## _PIN_4, \
}
uint8_t led0_pin
Pin identifier for first LED.
Definition: oled1_co_routine_xpro_example/oled1.h:104
Driver instance struct.
Definition: oled1_co_routine_xpro_example/oled1.h:102
#define _OLED1_CREATE_INSTANCE (   name,
  ext_header 
)
Value:
const struct oled1_instance name = { \
.led0_pin = ext_header ## _PIN_7, \
.led1_pin = ext_header ## _PIN_8, \
.led2_pin = ext_header ## _PIN_6, \
.button0_pin = ext_header ## _PIN_9, \
.button1_pin = ext_header ## _PIN_3, \
.button2_pin = ext_header ## _PIN_4, \
}
uint8_t led0_pin
Pin identifier for first LED.
Definition: oled1_co_routine_xpro_example/oled1.h:104
Driver instance struct.
Definition: oled1_co_routine_xpro_example/oled1.h:102
#define OLED1_BUTTON_ACTIVE   false

Active level for buttons.

Referenced by oled1_get_button_state().

#define OLED1_BUTTON_ACTIVE   false

Active level for buttons.

Referenced by oled1_get_button_state().

#define OLED1_BUTTON_ACTIVE   false

Active level for buttons.

Referenced by oled1_get_button_state().

#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.

Parameters
nameName to use for driver instance.
ext_headerExtension header to use, on the form EXTn (f.ex. EXT1).
#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.

Parameters
nameName to use for driver instance.
ext_headerExtension header to use, on the form EXTn (f.ex. EXT1).
#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.

Parameters
nameName to use for driver instance.
ext_headerExtension header to use, on the form EXTn (f.ex. EXT1).
#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.

Parameters
nameName to use for driver instance.
ext_headerExtension 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().

#define OLED1_LED_ACTIVE   false

Active level for LEDs.

Referenced by oled1_get_led_state(), oled1_init(), and oled1_set_led_state().

#define OLED1_LED_ACTIVE   false

Active level for LEDs.

Referenced by oled1_get_led_state(), oled1_init(), and oled1_set_led_state().

#define OLED1_LED_ACTIVE   false

Active level for LEDs.

Referenced by oled1_get_led_state(), oled1_init(), and oled1_set_led_state().

IDs for each of the on-board buttons.

Enumerator
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 

IDs for each of the on-board buttons.

Enumerator
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 

IDs for each of the on-board buttons.

Enumerator
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 

IDs for each of the on-board buttons.

Enumerator
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 
OLED1_BUTTON1_ID 
OLED1_BUTTON2_ID 
OLED1_BUTTON3_ID 

IDs for each of the on-board LEDs.

Enumerator
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 

IDs for each of the on-board LEDs.

Enumerator
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 

IDs for each of the on-board LEDs.

Enumerator
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 

IDs for each of the on-board LEDs.

Enumerator
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 
OLED1_LED1_ID 
OLED1_LED2_ID 
OLED1_LED3_ID 

static uint8_t _oled1_get_button_pin ( const struct oled1_instance *const  oled1,
const enum oled1_button_id  button_id 
)
inlinestatic

Get the pin identifier for a given button number in instance.

Parameters
oled1_instanceDriver instance to fetch pin identifier from.
led_idID of the button to fetch pin identifier for.
Returns
Identifier of pin for specified button.

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().

static uint8_t _oled1_get_led_pin ( const struct oled1_instance *const  oled1,
const enum oled1_led_id  led_id 
)
inlinestatic

Get the pin identifier for a given LED number in instance.

Parameters
oled1Address of driver instance to fetch pin identifier from.
led_idID 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().

static bool oled1_get_button_state ( const struct oled1_instance *const  oled1,
const enum oled1_button_id  button_id 
)
inlinestatic

Get the state of a button.

Parameters
oled1Address of driver instance to operate on.
led_idID of the button to get state of.
Return values
trueif button is active, i.e., pressed.
falseif button is not active.

References _oled1_get_button_pin(), OLED1_BUTTON_ACTIVE, and port_pin_get_input_level().

Referenced by main_task().

static bool oled1_get_led_state ( const struct oled1_instance *const  oled1,
const enum oled1_led_id  led_id 
)
inlinestatic

Get the state of a LED.

Parameters
oled1Address of driver instance to operate on.
led_idID of the LED to get state of.
Return values
trueif LED is active, i.e., lit up.
falseif LED is not active.

References _oled1_get_led_pin(), OLED1_LED_ACTIVE, and port_pin_get_input_level().

static void oled1_init ( const struct oled1_instance *const  oled1)
inlinestatic

Initialize hardware for driver instance.

This function initializes the hardware (pins) that belong to the specified driver instance.

Parameters
oled1Address 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().

static void oled1_set_led_state ( const struct oled1_instance *const  oled1,
const enum oled1_led_id  led_id,
const bool  state 
)
inlinestatic

Set the state of a LED.

Parameters
oled1Address of driver instance to operate on.
led_idID of the LED to set state of.
stateState to set LED to:
  • true to activate, i.e., light it up.
  • false to deactivate.

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().

static void oled1_toggle_led_state ( const struct oled1_instance *const  oled1,
const enum oled1_led_id  led_id 
)
inlinestatic

Set the state of a LED.

Parameters
oled1Address of driver instance to operate on.
led_idID of the LED to toggle state of.

References _oled1_get_led_pin(), and port_pin_toggle_output_level().