BOARD Module for Thunderboard Sense 2BSP > Thunderboard Sense BSP
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 I 2 C sensors on the board. 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)
- Hall effect sensor (Si7210)
- Indoor air quality sensor (CCS811)
- Inertial sensor (ICM-20948)
- Microphone (ICS-43434)
- 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.
Functions |
|
void | BOARD_alsClearIRQ (void) |
Function to clear the ALS sensor interrupt.
|
|
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) |
Function to clear the gas sensor 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.
|
|
void | BOARD_hallSensorClearIRQ (void) |
Function to clear the Hall sensor interrupt.
|
|
uint32_t | BOARD_hallSensorEnable (bool enable) |
Enables or disables the Hall sensor.
|
|
uint32_t | BOARD_hallSensorEnableIRQ (bool enable) |
Enables or disables the Hall sensor GPIO interrupt.
|
|
void |
BOARD_hallSensorSetIRQCallback
(
BOARD_IrqCallback
cb)
|
Function to register the Hall sensor interrupt callback function.
|
|
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) |
Function to clear the IMU sensor interrupt.
|
|
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.
|
|
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 |
|
) |
Function to clear the ALS sensor interrupt.
Clears the UV/Ambient light sensor GPIO interrupts.
- Returns
- Returns none
Definition at line
984
of file
board_4166.c
.
References GPIO_IntClear() .
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
617
of file
board_4166.c
.
References BOARD_envSensEnable() , and BOARD_OK .
Referenced by SI1133_deInit() , and SI1133_init() .
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
657
of file
board_4166.c
.
References BOARD_OK , and GPIO_ExtIntConfig() .
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
969
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
537
of file
board_4166.c
.
References BOARD_envSensEnable() , and BOARD_OK .
Referenced by BAP_deInit() , and BAP_init() .
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
506
of file
board_4166.c
.
References BOARD_OK , GPIO_PinModeSet() , GPIO_PinOutClear() , GPIO_PinOutSet() , gpioModeDisabled , and gpioModeWiredAnd .
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
734
of file
board_4166.c
.
References BOARD_OK , and GPIO_ExtIntConfig() .
void BOARD_flashDeepPowerDown | ( | void |
|
) |
Puts the Flash chip in deep power down mode.
- Returns
- Returns none
Definition at line
239
of file
board_4166.c
.
References GPIO_PinModeSet() , GPIO_PinOutClear() , GPIO_PinOutSet() , gpioModeDisabled , USART_Reset() , USART_SpiTransfer() , and UTIL_delay() .
void BOARD_gasSensorClearIRQ | ( | void |
|
) |
Function to clear the gas sensor interrupt.
Clears the Air Quality / Gas Sensor GPIO interrupt.
- Returns
- Returns none
Definition at line
921
of file
board_4166.c
.
References GPIO_IntClear() .
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
773
of file
board_4166.c
.
References BOARD_OK , GPIO_PinModeSet() , GPIO_PinOutClear() , GPIO_PinOutSet() , gpioModeDisabled , gpioModePushPull , and gpioModeWiredAnd .
Referenced by CCS811_deInit() , and CCS811_init() .
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
839
of file
board_4166.c
.
References BOARD_OK , and GPIO_ExtIntConfig() .
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
906
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
816
of file
board_4166.c
.
References BOARD_OK , GPIO_PinOutClear() , GPIO_PinOutSet() , and UTIL_delay() .
Referenced by CCS811_deInit() , CCS811_getMeasurement() , CCS811_getRawData() , CCS811_init() , CCS811_readMailbox() , CCS811_setEnvData() , CCS811_setMeasureMode() , and CCS811_softwareReset() .
void BOARD_hallSensorClearIRQ | ( | void |
|
) |
Function to clear the Hall sensor interrupt.
- Returns
- Returns none
Definition at line
953
of file
board_4166.c
.
References GPIO_IntClear() .
uint32_t BOARD_hallSensorEnable | ( | bool |
enable
|
) |
Enables or disables the Hall sensor.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
674
of file
board_4166.c
.
References BOARD_OK , GPIO_PinModeSet() , GPIO_PinOutClear() , GPIO_PinOutSet() , gpioModeDisabled , gpioModeInput , and gpioModeWiredAnd .
Referenced by HALL_deInit() , and HALL_init() .
uint32_t BOARD_hallSensorEnableIRQ | ( | bool |
enable
|
) |
Enables or disables the Hall sensor GPIO interrupt.
- Parameters
-
[in] enable
Set true to enable, false to disable
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
716
of file
board_4166.c
.
References BOARD_OK , and GPIO_ExtIntConfig() .
Referenced by HALL_deInit() , and HALL_init() .
void BOARD_hallSensorSetIRQCallback | ( |
BOARD_IrqCallback
|
cb
|
) |
Function to register the Hall sensor interrupt callback function.
- Parameters
-
[in] cb
The callback function to be registered
- Returns
- Returns none
Definition at line
938
of file
board_4166.c
.
References GPIOINT_CallbackRegister() .
Referenced by HALL_init() .
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
858
of file
board_4166.c
.
References BOARD_ERROR_I2C_BUS_SELECT_INVALID , BOARD_OK , I2C1 , I2C_ROUTEPEN_SCLPEN , and I2C_ROUTEPEN_SDAPEN .
Referenced by CCS811_getMeasurement() , CCS811_getRawData() , CCS811_readMailbox() , CCS811_setEnvData() , CCS811_setMeasureMode() , CCS811_softwareReset() , SI1133_registerBlockRead() , SI1133_registerBlockWrite() , SI1133_registerRead() , SI1133_registerWrite() , SI7021_cmdRead() , SI7021_cmdWrite() , SI7210_registerRead() , SI7210_registerWrite() , and SI7210_wakeUp() .
void BOARD_imuClearIRQ | ( | void |
|
) |
Function to clear the IMU sensor interrupt.
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 none
Definition at line
1015
of file
board_4166.c
.
References GPIO_IntClear() .
Referenced by IMU_clearDataReadyFlag() , and IMU_config() .
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
465
of file
board_4166.c
.
References BOARD_OK , GPIO_PinOutClear() , and GPIO_PinOutSet() .
Referenced by ICM20648_deInit() , and ICM20648_init() .
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
488
of file
board_4166.c
.
References BOARD_OK , and GPIO_ExtIntConfig() .
Referenced by IMU_config() .
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
1000
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
HALL effect sensor pin config
IMU pin config
ENV Sensor pin config
Microphone pin config
Gas sensor pin config
RGBLED / LED config
Definition at line
115
of file
board_4166.c
.
References _TIMER_ROUTELOC0_CC0LOC_SHIFT , _TIMER_ROUTELOC0_CC1LOC_SHIFT , _TIMER_ROUTELOC0_CC2LOC_SHIFT , BOARD_OK , CMU_ClockEnable() , cmuClock_GPIO , TIMER_Init_TypeDef::debugRun , GPIO_PinModeSet() , GPIOINT_Init() , gpioModeDisabled , gpioModeInput , gpioModePushPull , I2C1 , i2cInit() , I2CSPM_Init() , I2CSPM_INIT_DEFAULT , TIMER_InitCC_TypeDef::mode , I2CSPM_Init_TypeDef::port , I2CSPM_Init_TypeDef::portLocationScl , I2CSPM_Init_TypeDef::portLocationSda , TIMER_Init_TypeDef::prescale , TIMER_TypeDef::ROUTELOC0 , TIMER_TypeDef::ROUTEPEN , I2CSPM_Init_TypeDef::sclPin , I2CSPM_Init_TypeDef::sclPort , I2CSPM_Init_TypeDef::sdaPin , I2CSPM_Init_TypeDef::sdaPort , TIMER_Init() , TIMER_INIT_DEFAULT , TIMER_InitCC() , TIMER_INITCC_DEFAULT , TIMER_TopSet() , timerCCModePWM , and timerPrescale2 .
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
370
of file
board_4166.c
.
References BOARD_rgbledEnable() , BOARD_rgbledSetRawColor() , GPIO_PinOutClear() , and GPIO_PinOutSet() .
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
752
of file
board_4166.c
.
References BOARD_OK , GPIO_PinOutClear() , and GPIO_PinOutSet() .
Referenced by MIC_deInit() , and MIC_init() .
void BOARD_pushButton0ClearIRQ | ( | void |
|
) |
Function to clear the pushbutton 0 interrupt.
- Returns
- Returns none
Definition at line
1047
of file
board_4166.c
.
References GPIO_IntClear() .
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
1032
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
1079
of file
board_4166.c
.
References GPIO_IntClear() .
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
1064
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
293
of file
board_4166.c
.
References GPIO_ExtIntConfig() .
uint8_t BOARD_pushButtonGetState | ( | void |
|
) |
Gets the state of the pushbuttons.
- Returns
- Returns the state of the buttons
Definition at line
270
of file
board_4166.c
.
References GPIO_PortInGet() .
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
333
of file
board_4166.c
.
References BOARD_rgbledPowerEnable() , GPIO_PinOutClear() , and GPIO_PinOutSet() .
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
309
of file
board_4166.c
.
References GPIO_PinOutClear() , and GPIO_PinOutSet() .
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
446
of file
board_4166.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
406
of file
board_4166.c
.
References BOARD_ledSet() , TIMER_TypeDef::ROUTEPEN , TIMER_CompareBufSet() , TIMER_Enable() , TIMER_ROUTEPEN_CC0PEN , TIMER_ROUTEPEN_CC1PEN , and TIMER_ROUTEPEN_CC2PEN .
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
577
of file
board_4166.c
.
References BOARD_envSensEnable() , and BOARD_OK .
Referenced by SI7021_deInit() , and SI7021_init() .