BOARD Module for Thunderboard Sense
Detailed Description
Board hardware control, configuraton and miscellaneous functions.
This module contains functions releated to board features. It allows control over power management features, interrupt controller and RGB LEDs.
The BOARD module uses the common I2CSPM driver to communicate with the on-board Power and Interrupt Controller over I 2 C. The following board features can be enabled when needed using the BOARD Module:
-
Environmental sensor group
- RH/Temp (Si7021)
- UV/ALS (Si1133)
- Barometric Pressure (BMP280)
- Indoor air quality sensor (CCS811)
- Inertial sensor (ICM-20648)
- Microphone (SPV1840)
- RGB LED boost converter
The BOARD Module also contains functions for controlling the RGB LEDs. The implementation uses one of the TIMER peripherals in PWM mode, with three compare capture channels, one each for red, green and blue.
Modules |
|
Power and Interrupt Controller Definitions | |
Thunderboard Sense 1 Power and Interrupt Controller register and bitfield definitions.
|
|
Functions |
|
void | BOARD_alsClearIRQ (void) |
Clears the UV/Ambient light sensor GPIO interrupts.
|
|
uint32_t | BOARD_alsEnable (bool enable) |
Enables or disables the UV/Ambient light sensor.
|
|
uint32_t | BOARD_alsEnableIRQ (bool enable) |
Enables or disables the UV/Ambient light sensor GPIO interrupts.
|
|
void |
BOARD_alsSetIRQCallback
(
BOARD_IrqCallback
cb)
|
Function to register the ALS sensor interrupt callback function.
|
|
uint32_t | BOARD_bapEnable (bool enable) |
Enables or disables the Barometric Pressure sensor.
|
|
uint32_t | BOARD_envSensEnable (bool enable) |
Enables or disables the environmental sensor group (Pressure, RH/Temp, UV/Ambient light and Hall sensors)
|
|
uint32_t | BOARD_envSensEnableIRQ (bool enable) |
Enables or disables the environmental sensor group (Pressure, RH/Temp, UV/Ambient light and Hall sensors) GPIO interrupts.
|
|
void | BOARD_flashDeepPowerDown (void) |
Puts the Flash chip in deep power down mode.
|
|
void | BOARD_gasSensorClearIRQ (void) |
Clears the Air Quality / Gas Sensor GPIO interrupt.
|
|
uint32_t | BOARD_gasSensorEnable (bool enable) |
Enables or disables the Air Quality / Gas Sensor.
|
|
uint32_t | BOARD_gasSensorEnableIRQ (bool enable) |
Enables or disables the Air Quality / Gas Sensor GPIO interrupt.
|
|
void |
BOARD_gasSensorSetIRQCallback
(
BOARD_IrqCallback
cb)
|
Function to register the gas sensor interrupt callback function.
|
|
uint32_t | BOARD_gasSensorWake (bool wake) |
Wakes up the Air Quality / Gas Sensor.
|
|
uint32_t | BOARD_i2cBusSelect (uint8_t select) |
Sets up the route register of the I2C device to use the correct set of pins.
|
|
void | BOARD_imuClearIRQ (void) |
Clears the accelerometer and gyroscope GPIO interrupt In the ThunderBoard Sense app example the IMU registers need to be read at quite high rate. Clearing the PIC interrupt register would take too much time. Due to the nature of this example only the IMU interrupt is active and the program can work correctly without identifying the interrupt source and clearing the IT flag in the PIC. If speed is not a limiting factor then always clear the PIC interrupt register by calling the BOARD_picIntClear(BOARD_PIC_REG_INT_CLEAR_IMU); function.
|
|
uint32_t | BOARD_imuEnable (bool enable) |
Enables or disables the accelerometer and gyroscope sensor.
|
|
uint32_t | BOARD_imuEnableIRQ (bool enable) |
Enables or disables the accelerometer and gyroscope GPIO interrupt.
|
|
void |
BOARD_imuSetIRQCallback
(
BOARD_IrqCallback
cb)
|
Function to register the IMU sensor interrupt callback function.
|
|
uint32_t | BOARD_init (void) |
Initializes the Thunderboard Sense board.
|
|
void | BOARD_ledSet (uint8_t leds) |
Turns on or off the red and/or green LED.
|
|
uint32_t | BOARD_micEnable (bool enable) |
Enables or disables the MEMS microphone.
|
|
uint32_t | BOARD_picGetDeviceId (void) |
Reads the device ID of the IO expander.
|
|
uint32_t | BOARD_picGetFwRevision (uint8_t *major, uint8_t *minor, uint8_t *patch) |
Reads the firmware revision of the IO expander.
|
|
uint8_t | BOARD_picGetHwRevision (void) |
Reads the hardware revision of the IO expander.
|
|
uint32_t | BOARD_picIntClear (uint8_t flags) |
Clears the interrupt status flags in the interrupt controller.
|
|
uint32_t | BOARD_picIntGet (uint8_t *flags) |
Reads the interrupt status flags from the interrupt controller.
|
|
bool | BOARD_picIsLegacyIntCtrl (void) |
Checks if the legacy interrupt control method should be used.
|
|
uint32_t | BOARD_picReadReg (uint8_t reg, uint8_t *result) |
Reads a register in the IO expander.
|
|
uint32_t | BOARD_picRegBitsSet (uint8_t addr, bool set, uint8_t bitMask) |
Sets the given bit(s) in a register in the IO expander.
|
|
uint32_t | BOARD_picWriteReg (uint8_t reg, uint8_t value) |
Writes a register in the IO expander.
|
|
void | BOARD_pushButton0ClearIRQ (void) |
Function to clear the pushbutton 0 interrupt.
|
|
void |
BOARD_pushButton0SetIRQCallback
(
BOARD_IrqCallback
cb)
|
Function to register the pushbutton 0 interrupt callback function.
|
|
void | BOARD_pushButton1ClearIRQ (void) |
Function to clear the pushbutton 1 interrupt.
|
|
void |
BOARD_pushButton1SetIRQCallback
(
BOARD_IrqCallback
cb)
|
Function to register the pushbutton 1 interrupt callback function.
|
|
void | BOARD_pushButtonEnableIRQ (bool enable) |
Enables or disables the pushbutton GPIO interrupt.
|
|
uint8_t | BOARD_pushButtonGetState (void) |
Gets the state of the pushbuttons.
|
|
void | BOARD_rgbledEnable (bool enable, uint8_t mask) |
Enables or disables the RGB LED power supply line.
|
|
void | BOARD_rgbledPowerEnable (bool enable) |
Enables or disables the RGB LED power supply line.
|
|
void | BOARD_rgbledSetColor (uint8_t red, uint8_t green, uint8_t blue) |
Sets the color of the RGB LEDs. The brightness of the LEDs is almost linear to the color value.
|
|
void | BOARD_rgbledSetRawColor (uint16_t red, uint16_t green, uint16_t blue) |
Sets the raw color of the RGB LEDs. The brightness is non-linear function of the raw color value.
|
|
uint32_t | BOARD_rhtempEnable (bool enable) |
Enables or disables the RH/Temp sensor.
|
|
Function Documentation
void BOARD_alsClearIRQ | ( | void |
|
) |
Clears the UV/Ambient light sensor GPIO interrupts.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
686
of file
board_4160.c
.
References BOARD_PIC_REG_INT_CLEAR_UV_ALS , and BOARD_picIntClear() .
uint32_t BOARD_alsEnable | ( | bool |
enable
|
) |
Enables or disables the UV/Ambient light sensor.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
629
of file
board_4160.c
.
References BOARD_envSensEnable() , and BOARD_OK .
uint32_t BOARD_alsEnableIRQ | ( | bool |
enable
|
) |
Enables or disables the UV/Ambient light sensor GPIO interrupts.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
669
of file
board_4160.c
.
References BOARD_PIC_REG_INT_ENABLE , BOARD_PIC_REG_INT_ENABLE_UV_ALS , and BOARD_picRegBitsSet() .
void BOARD_alsSetIRQCallback | ( |
BOARD_IrqCallback
|
cb
|
) |
Function to register the ALS sensor interrupt callback function.
- Parameters
-
[in] cb
The callback function to be registered
- Returns
- Returns none
Definition at line
976
of file
board_4166.c
.
References GPIOINT_CallbackRegister() .
uint32_t BOARD_bapEnable | ( | bool |
enable
|
) |
Enables or disables the Barometric Pressure sensor.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
549
of file
board_4160.c
.
References BOARD_envSensEnable() , and BOARD_OK .
uint32_t BOARD_envSensEnable | ( | bool |
enable
|
) |
Enables or disables the environmental sensor group (Pressure, RH/Temp, UV/Ambient light and Hall sensors)
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
530
of file
board_4160.c
.
References BOARD_PIC_REG_ENV_SENSOR_CTRL , and BOARD_picWriteReg() .
Referenced by BOARD_alsEnable() , BOARD_bapEnable() , and BOARD_rhtempEnable() .
uint32_t BOARD_envSensEnableIRQ | ( | bool |
enable
|
) |
Enables or disables the environmental sensor group (Pressure, RH/Temp, UV/Ambient light and Hall sensors) GPIO interrupts.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
707
of file
board_4160.c
.
References BOARD_PIC_REG_INT_ENABLE , BOARD_PIC_REG_INT_ENABLE_UV_ALS , and BOARD_picRegBitsSet() .
void BOARD_flashDeepPowerDown | ( | void |
|
) |
Puts the Flash chip in deep power down mode.
- Returns
- Returns none
Definition at line
249
of file
board_4160.c
.
References UTIL_delay() .
void BOARD_gasSensorClearIRQ | ( | void |
|
) |
Clears the Air Quality / Gas Sensor GPIO interrupt.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
815
of file
board_4160.c
.
References BOARD_PIC_REG_INT_CLEAR_CCS811 , and BOARD_picIntClear() .
uint32_t BOARD_gasSensorEnable | ( | bool |
enable
|
) |
Enables or disables the Air Quality / Gas Sensor.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
746
of file
board_4160.c
.
References BOARD_PIC_REG_CCS_CTRL , BOARD_PIC_REG_CCS_CTRL_EN , and BOARD_picWriteReg() .
uint32_t BOARD_gasSensorEnableIRQ | ( | bool |
enable
|
) |
Enables or disables the Air Quality / Gas Sensor GPIO interrupt.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
798
of file
board_4160.c
.
References BOARD_PIC_REG_INT_ENABLE , BOARD_PIC_REG_INT_ENABLE_CCS811 , and BOARD_picRegBitsSet() .
void BOARD_gasSensorSetIRQCallback | ( |
BOARD_IrqCallback
|
cb
|
) |
Function to register the gas sensor interrupt callback function.
- Parameters
-
[in] cb
The callback function to be registered
- Returns
- Returns none
Definition at line
913
of file
board_4166.c
.
References GPIOINT_CallbackRegister() .
uint32_t BOARD_gasSensorWake | ( | bool |
wake
|
) |
Wakes up the Air Quality / Gas Sensor.
- Parameters
-
[in] wake
Set true to wake up, false otherwise
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
775
of file
board_4160.c
.
References BOARD_PIC_REG_CCS_CTRL , BOARD_PIC_REG_CCS_CTRL_EN , BOARD_PIC_REG_CCS_CTRL_WAKE , and BOARD_picWriteReg() .
uint32_t BOARD_i2cBusSelect | ( | uint8_t |
select
|
) |
Sets up the route register of the I2C device to use the correct set of pins.
-
- Parameters
-
[in] select
The I2C bus route to use (None, Environmental sensors, Gas sensor, Hall sensor)
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
837
of file
board_4160.c
.
References BOARD_OK .
void BOARD_imuClearIRQ | ( | void |
|
) |
Clears the accelerometer and gyroscope GPIO interrupt In the ThunderBoard Sense app example the IMU registers need to be read at quite high rate. Clearing the PIC interrupt register would take too much time. Due to the nature of this example only the IMU interrupt is active and the program can work correctly without identifying the interrupt source and clearing the IT flag in the PIC. If speed is not a limiting factor then always clear the PIC interrupt register by calling the BOARD_picIntClear(BOARD_PIC_REG_INT_CLEAR_IMU); function.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
509
of file
board_4160.c
.
uint32_t BOARD_imuEnable | ( | bool |
enable
|
) |
Enables or disables the accelerometer and gyroscope sensor.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
457
of file
board_4160.c
.
References BOARD_OK , BOARD_PIC_REG_IMU_CTRL , and BOARD_picWriteReg() .
uint32_t BOARD_imuEnableIRQ | ( | bool |
enable
|
) |
Enables or disables the accelerometer and gyroscope GPIO interrupt.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
484
of file
board_4160.c
.
References BOARD_PIC_REG_INT_ENABLE , BOARD_PIC_REG_INT_ENABLE_IMU , and BOARD_picRegBitsSet() .
void BOARD_imuSetIRQCallback | ( |
BOARD_IrqCallback
|
cb
|
) |
Function to register the IMU sensor interrupt callback function.
- Parameters
-
[in] cb
The callback function to be registered
- Returns
- Returns none
Definition at line
1007
of file
board_4166.c
.
References GPIOINT_CallbackRegister() .
Referenced by IMU_config() .
uint32_t BOARD_init | ( | void |
|
) |
Initializes the Thunderboard Sense board.
- Returns
- Returns zero on OK, non-zero otherwise
Push button config
PIC Config
Wait for IO-expander to boot up
PIC default register content
RGBLED / LED config
Definition at line
133
of file
board_4160.c
.
References BOARD_ERROR_PIC_ID_MISMATCH , BOARD_OK , BOARD_PIC_NUM_APP_REGS , BOARD_picGetDeviceId() , BOARD_picGetFwRevision() , BOARD_picWriteReg() , i2cInit() , I2CSPM_Init() , I2CSPM_Init_TypeDef::port , and UTIL_delay() .
void BOARD_ledSet | ( | uint8_t |
leds
|
) |
Turns on or off the red and/or green LED.
- Parameters
-
[in] leds
The two LSB bits determine the state of the green and red LED. If the bit is 1 then the LED will be turned on.
- Returns
- None
Definition at line
362
of file
board_4160.c
.
References BOARD_rgbledEnable() , and BOARD_rgbledSetRawColor() .
Referenced by BOARD_rgbledSetRawColor() .
uint32_t BOARD_micEnable | ( | bool |
enable
|
) |
Enables or disables the MEMS microphone.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
727
of file
board_4160.c
.
References BOARD_PIC_REG_MIC_CTRL , and BOARD_picWriteReg() .
uint32_t BOARD_picGetDeviceId | ( | void |
|
) |
Reads the device ID of the IO expander.
- Returns
- Returns the device ID read from the device
Definition at line
981
of file
board_4160.c
.
References BOARD_PIC_REG_DEVICE_ID0 , BOARD_PIC_REG_DEVICE_ID1 , BOARD_PIC_REG_DEVICE_ID2 , BOARD_PIC_REG_DEVICE_ID3 , and BOARD_picReadReg() .
Referenced by BOARD_init() .
uint32_t BOARD_picGetFwRevision | ( | uint8_t * |
major,
|
uint8_t * |
minor,
|
||
uint8_t * |
patch
|
||
) |
Reads the firmware revision of the IO expander.
- Parameters
-
[out] major
The major version number of the firmware [out] minor
The minor version number of the firmware [out] patch
The patch version number of the firmware
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
1028
of file
board_4160.c
.
References BOARD_OK , BOARD_PIC_REG_VERSION_MAJOR , BOARD_PIC_REG_VERSION_MINOR , and BOARD_PIC_REG_VERSION_PATCH .
Referenced by BOARD_init() .
uint8_t BOARD_picGetHwRevision | ( | void |
|
) |
Reads the hardware revision of the IO expander.
- Returns
- Returns the HW revision the device
Definition at line
1003
of file
board_4160.c
.
References BOARD_PIC_REG_BOARD_REV , and BOARD_picReadReg() .
uint32_t BOARD_picIntClear | ( | uint8_t |
flags
|
) |
Clears the interrupt status flags in the interrupt controller.
- Parameters
-
[out] flags
Holds the flags that indicate which events have taken place
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
877
of file
board_4160.c
.
References BOARD_PIC_REG_INT_CLEAR , and BOARD_picWriteReg() .
Referenced by BOARD_alsClearIRQ() , and BOARD_gasSensorClearIRQ() .
uint32_t BOARD_picIntGet | ( | uint8_t * |
flags
|
) |
Reads the interrupt status flags from the interrupt controller.
- Parameters
-
[out] flags
Holds the flags that indicate which events have taken place
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
858
of file
board_4160.c
.
References BOARD_PIC_REG_INT_FLAG , and BOARD_picReadReg() .
bool BOARD_picIsLegacyIntCtrl | ( | void |
|
) |
Checks if the legacy interrupt control method should be used.
- Returns
- Returns true if the legacy method should be used (before board rev A02)
Definition at line
1066
of file
board_4160.c
.
uint32_t BOARD_picReadReg | ( | uint8_t |
reg,
|
uint8_t * |
result
|
||
) |
Reads a register in the IO expander.
- Parameters
-
[in] reg
The register address to read [out] result
The data read from the device
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
923
of file
board_4160.c
.
Referenced by BOARD_picGetDeviceId() , BOARD_picGetHwRevision() , and BOARD_picIntGet() .
uint32_t BOARD_picRegBitsSet | ( | uint8_t |
addr,
|
bool |
set,
|
||
uint8_t |
bitMask
|
||
) |
Sets the given bit(s) in a register in the IO expander.
- Parameters
-
[in] addr
The address of the register [in] set
Specifies whether the bits selected by the mask should be set or cleared [in] bitMask
The mask specifies which bits should be changed
- Returns
- None
Definition at line
950
of file
board_4160.c
.
References BOARD_OK .
Referenced by BOARD_alsEnableIRQ() , BOARD_envSensEnableIRQ() , BOARD_gasSensorEnableIRQ() , BOARD_imuEnableIRQ() , BOARD_rgbledEnable() , and BOARD_rgbledPowerEnable() .
uint32_t BOARD_picWriteReg | ( | uint8_t |
reg,
|
uint8_t |
value
|
||
) |
Writes a register in the IO expander.
- Parameters
-
[in] reg
The register address to write [in] value
The data to write to the register
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
899
of file
board_4160.c
.
Referenced by BOARD_envSensEnable() , BOARD_gasSensorEnable() , BOARD_gasSensorWake() , BOARD_imuEnable() , BOARD_init() , BOARD_micEnable() , and BOARD_picIntClear() .
void BOARD_pushButton0ClearIRQ | ( | void |
|
) |
Function to clear the pushbutton 0 interrupt.
- Returns
- Returns none
Definition at line
1054
of file
board_4166.c
.
void BOARD_pushButton0SetIRQCallback | ( |
BOARD_IrqCallback
|
cb
|
) |
Function to register the pushbutton 0 interrupt callback function.
- Parameters
-
[in] cb
The callback function to be registered
- Returns
- Returns none
Definition at line
1039
of file
board_4166.c
.
References GPIOINT_CallbackRegister() .
void BOARD_pushButton1ClearIRQ | ( | void |
|
) |
Function to clear the pushbutton 1 interrupt.
- Returns
- Returns none
Definition at line
1086
of file
board_4166.c
.
void BOARD_pushButton1SetIRQCallback | ( |
BOARD_IrqCallback
|
cb
|
) |
Function to register the pushbutton 1 interrupt callback function.
- Parameters
-
[in] cb
The callback function to be registered
- Returns
- Returns none
Definition at line
1071
of file
board_4166.c
.
References GPIOINT_CallbackRegister() .
void BOARD_pushButtonEnableIRQ | ( | bool |
enable
|
) |
Enables or disables the pushbutton GPIO interrupt.
- Parameters
-
[in] enable
Set true to enable, false to disable the pushbutton interrupts
- Returns
- None
Definition at line
303
of file
board_4160.c
.
uint8_t BOARD_pushButtonGetState | ( | void |
|
) |
Gets the state of the pushbuttons.
- Returns
- Returns the state of the buttons
Definition at line
280
of file
board_4160.c
.
void BOARD_rgbledEnable | ( | bool |
enable,
|
uint8_t |
mask
|
||
) |
Enables or disables the RGB LED power supply line.
- Parameters
-
[in] enable
Set true to enable, false to disable [in] mask
Mask indicating which bits to modify
- Returns
- None
Definition at line
339
of file
board_4160.c
.
References BOARD_PIC_REG_LED_CTRL , BOARD_PIC_REG_LED_CTRL_LED_MASK , BOARD_PIC_REG_LED_CTRL_LED_SHIFT , BOARD_picRegBitsSet() , and BOARD_rgbledPowerEnable() .
Referenced by BOARD_ledSet() .
void BOARD_rgbledPowerEnable | ( | bool |
enable
|
) |
Enables or disables the RGB LED power supply line.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- None
Definition at line
319
of file
board_4160.c
.
References BOARD_PIC_REG_LED_CTRL , BOARD_PIC_REG_LED_CTRL_PWR_EN , and BOARD_picRegBitsSet() .
Referenced by BOARD_rgbledEnable() .
void BOARD_rgbledSetColor | ( | uint8_t |
red,
|
uint8_t |
green,
|
||
uint8_t |
blue
|
||
) |
Sets the color of the RGB LEDs. The brightness of the LEDs is almost linear to the color value.
- Parameters
-
[in] red
An 8-bit value, which determines the brightness of the red channel [in] green
An 8-bit value, which determines the brightness of the green channel [in] blue
An 8-bit value, which determines the brightness of the blue channel
- Returns
- None
Definition at line
438
of file
board_4160.c
.
References BOARD_rgbledSetRawColor() .
void BOARD_rgbledSetRawColor | ( | uint16_t |
red,
|
uint16_t |
green,
|
||
uint16_t |
blue
|
||
) |
Sets the raw color of the RGB LEDs. The brightness is non-linear function of the raw color value.
- Parameters
-
[in] red
A 16-bit value, which determines the PWM value of the red channel [in] green
A 16-bit value, which determines the PWM value of the green channel [in] blue
A 16-bit value, which determines the PWM value of the blue channel
- Returns
- None
Definition at line
398
of file
board_4160.c
.
References BOARD_ledSet() .
Referenced by BOARD_ledSet() , and BOARD_rgbledSetColor() .
uint32_t BOARD_rhtempEnable | ( | bool |
enable
|
) |
Enables or disables the RH/Temp sensor.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
589
of file
board_4160.c
.
References BOARD_envSensEnable() , and BOARD_OK .