Microchip® Advanced Software Framework

oled1_tickless_xpro_example/oled1.h File Reference

OLED1 Xplained Pro LED and button driver for FreeRTOS demo.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <board.h>
#include <compiler.h>
#include <port.h>

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...
 
Constants
#define OLED1_LED_ACTIVE   false
 Active level for LEDs. More...
 
#define OLED1_BUTTON_ACTIVE   false
 Active level for buttons. 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_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...
 
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...
 

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

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

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

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