61 static const uint8_t lightLevels[] = BOARD_RGBLED_PROFILE_EXP;
62 static bool rgbledEnable;
63 static bool timerEnable;
64 static bool isLegacyIntCtrl;
69 static void flashSPIInit (
void );
70 static inline void picWake (
void );
71 static inline void picSleep (
void );
72 static uint32_t picReadReg ( uint8_t addr, uint8_t *result );
73 static uint32_t picWriteReg ( uint8_t addr, uint8_t value );
100 uint8_t major, minor, patch;
102 rgbledEnable =
false;
104 isLegacyIntCtrl =
true;
124 PRS->ROUTEPEN = PRS_ROUTEPEN_CH0PEN;
125 PRS->ROUTELOC0 = PRS_ROUTELOC0_CH0LOC_LOC6;
136 i2cDevice = i2cInit.
port;
143 while( timeout-- > 0 ) {
163 if( major == 0 && minor <= 3 ) {
164 isLegacyIntCtrl =
true;
167 isLegacyIntCtrl =
false;
203 pwmTimer->ROUTEPEN = 0;
320 if( ( ( mask != 0 ) && ( enable ==
true ) ) || ( ( ( mask & 0xf ) == 0xf ) && ( enable ==
false ) ) ) {
322 rgbledEnable = enable;
346 if( rgbledEnable && leds != 0 ) {
353 for(
int i = 0; i < 2; i++ ) {
354 if( ( (leds >> i) & 1 ) == 1 ) {
387 if( ( red == 0 ) && ( green == 0 ) && ( blue == 0 ) ) {
395 pwmTimer->ROUTEPEN = 0;
403 pwmTimer->ROUTEPEN = TIMER_ROUTEPEN_CC0PEN | TIMER_ROUTEPEN_CC1PEN | TIMER_ROUTEPEN_CC2PEN;
431 256 * (uint16_t)lightLevels[green],
432 256 * (uint16_t)lightLevels[blue] );
682 status = picWriteReg( reg, value );
708 status = picReadReg( reg, result );
739 status = picReadReg( addr, &value );
751 status = picWriteReg( addr, value );
772 pU8 = (uint8_t *) &result;
860 return isLegacyIntCtrl;
883 static uint32_t picReadReg( uint8_t addr, uint8_t *result )
929 static uint32_t picWriteReg( uint8_t addr, uint8_t value )
969 static inline void picWake(
void )
978 if( !isLegacyIntCtrl ) {
1000 static inline void picSleep(
void )
1003 if( isLegacyIntCtrl ){
1022 static void flashSPIInit(
void )
1042 USART1->ROUTELOC0 = ( USART_ROUTELOC0_RXLOC_LOC11 | USART_ROUTELOC0_TXLOC_LOC11 | USART_ROUTELOC0_CLKLOC_LOC11 );
1043 USART1->ROUTEPEN = ( USART_ROUTEPEN_RXPEN | USART_ROUTEPEN_TXPEN | USART_ROUTEPEN_CLKPEN );
1049 EMU ->EM4CTRL |= EMU_EM4CTRL_EM4IORETMODE_EM4EXIT;
Clock management unit (CMU) API.
uint32_t BOARD_picIntGet(uint8_t *flags)
Reads the interrupt status flags from the interrupt controller.
__STATIC_INLINE void TIMER_TopSet(TIMER_TypeDef *timer, uint32_t val)
Set top value for timer.
void BOARD_ledSet(uint8_t leds)
Turns on or off the red and/or green LED.
uint32_t BOARD_gasSensorWake(bool wake)
Wakes up the Air Quality / Gas Sensor.
I2C_TransferReturn_TypeDef I2CSPM_Transfer(I2C_TypeDef *i2c, I2C_TransferSeq_TypeDef *seq)
Perform I2C transfer.
#define BOARD_BUTTON_LEFT_PORT
#define BOARD_PIC_REG_DEVICE_ID3
void USART_InitSync(USART_TypeDef *usart, const USART_InitSync_TypeDef *init)
Init USART for synchronous mode.
#define BOARD_PIC_REG_LED_CTRL_PWR_EN
#define BOARD_FLASH_PIN_SPI_CLK
void I2CSPM_Init(I2CSPM_Init_TypeDef *init)
Initalize I2C peripheral.
__STATIC_INLINE void TIMER_Enable(TIMER_TypeDef *timer, bool enable)
Start/stop TIMER.
#define BOARD_BUTTON_RIGHT_PIN
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...
#define BOARD_ERROR_PIC_ID_MISMATCH
#define BOARD_FLASH_PIN_SPI_MISO
#define BOARD_RGBLED_CMU_CLK
#define BOARD_BUTTON_RIGHT_PORT
#define TIMER_INITCC_DEFAULT
bool BOARD_picIsLegacyIntCtrl(void)
Checks if the legacy interrupt control method should be used.
uint8_t BOARD_pushButtonGetState(void)
Gets the state of the pushbuttons.
#define BOARD_RGBLED_BLUE_PORT
__STATIC_INLINE void GPIO_IntClear(uint32_t flags)
Clear one or more pending GPIO interrupts.
void UTIL_delay(uint32_t ms)
Delays number of msTick Systicks (1 ms)
#define BOARD_PIC_REG_DEVICE_ID2
uint32_t BOARD_picGetFwRevision(uint8_t *major, uint8_t *minor, uint8_t *patch)
Reads the firmware revision of the IO expander.
Timer/counter (TIMER) peripheral API.
#define BOARD_PIC_REG_INT_ENABLE_CCS811
#define BOARD_PIC_REG_CCS_CTRL
uint32_t BOARD_picIntClear(uint8_t flags)
Clears the interrupt status flags in the interrupt controller.
#define BOARD_BUTTON_LEFT_PIN
#define BOARD_PIC_REG_LED_CTRL_LED_MASK
#define BOARD_RGBLED_GREEN_PORT
TIMER_CCMode_TypeDef mode
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
#define BOARD_ERROR_I2C_TRANSFER_NACK
uint32_t BOARD_picWriteReg(uint8_t reg, uint8_t value)
Writes a register in the IO expander.
__STATIC_INLINE uint32_t GPIO_PortInGet(GPIO_Port_TypeDef port)
Read the pad values for GPIO port.
#define BOARD_PIC_INT_WAKE_PORT
#define BOARD_FLASH_USART
I2C_TransferReturn_TypeDef
#define BOARD_PIC_REG_VERSION_MAJOR
#define BOARD_PIC_REG_ENV_SENSOR_CTRL
uint32_t BOARD_envSensEnable(bool enable)
Enables or disables the environmental sensor group (Pressure, RH/Temp, UV/Ambient light and Hall sens...
void BOARD_flashDeepPowerDown(void)
Puts the Flash chip in deep power down mode.
uint32_t BOARD_micEnable(bool enable)
Enables or disables the MEMS microphone.
#define BOARD_PIC_REG_LED_CTRL
__STATIC_INLINE void GPIO_IntDisable(uint32_t flags)
Disable one or more GPIO interrupts.
#define BOARD_ERROR_I2C_TRANSFER_FAILED
#define BOARD_FLASH_PORT_SPI
#define BOARD_PIC_REG_LED_CTRL_LED_SHIFT
#define BOARD_BUTTON_SHIFT
#define BOARD_PIC_REG_IMU_CTRL
#define BOARD_RGBLED_TIMER
__STATIC_INLINE void GPIO_IntEnable(uint32_t flags)
Enable one or more GPIO interrupts.
uint32_t BOARD_imuEnableIRQ(bool enable)
Enables or disables the accelerometer and gyroscope GPIO interrupt.
#define BOARD_RGBLED_GREEN_PIN
#define BOARD_PIC_REG_INT_FLAG
void GPIO_PinModeSet(GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
Set the mode for a GPIO pin.
#define BOARD_ERROR_I2C_TRANSFER_TIMEOUT
General Purpose IO (GPIO) peripheral API.
I2C simple poll-based master mode driver for the DK/STK.
#define BOARD_FLASH_PIN_SPI_MOSI
uint8_t BOARD_picGetHwRevision(void)
Reads the hardware revision of the IO expander.
#define TIMER_INIT_DEFAULT
#define I2CSPM_INIT_DEFAULT
Utility Functions for the Thunderboard Sense.
__STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out register to 1.
#define BOARD_PIC_REG_VERSION_PATCH
struct I2C_TransferSeq_TypeDef::@0 buf[2]
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
#define BOARD_PIC_REG_INT_ENABLE
void PRS_SourceSignalSet(unsigned int ch, uint32_t source, uint32_t signal, PRS_Edge_TypeDef edge)
Set source and signal to be used for a channel.
#define BOARD_PIC_NUM_APP_REGS
#define BOARD_PIC_REG_INT_CLEAR
void BOARD_rgbledEnable(bool enable, uint8_t mask)
Enables or disables the RGB LED power supply line.
#define BOARD_FLASH_PORT_SPI_CS
uint32_t BOARD_gasSensorEnableIRQ(bool enable)
Enables or disables the Air Quality / Gas Sensor GPIO interrupt.
#define BOARD_RGBLED_GREEN_CCLOC
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...
#define BOARD_PIC_REG_DEVICE_ID0
__STATIC_INLINE void GPIO_IntConfig(GPIO_Port_TypeDef port, unsigned int pin, bool risingEdge, bool fallingEdge, bool enable)
Configure GPIO interrupt.
#define BOARD_RGBLED_RED_CCLOC
TIMER_Prescale_TypeDef prescale
#define BOARD_BUTTON_MASK
#define BOARD_PIC_REG_INT_ENABLE_UV_ALS
Master mode transfer message structure used to define a complete I2C transfer sequence (from start to...
void USART_Reset(USART_TypeDef *usart)
Reset USART/UART to same state as after a HW reset.
void BOARD_pushButtonEnableIRQ(bool enable)
Enables or disables the pushbutton GPIO interrupt.
#define BOARD_PIC_REG_VERSION_MINOR
void TIMER_Init(TIMER_TypeDef *timer, const TIMER_Init_TypeDef *init)
Initialize TIMER.
uint8_t USART_SpiTransfer(USART_TypeDef *usart, uint8_t data)
Perform one 8 bit frame SPI transfer.
#define PRS_CH_CTRL_SIGSEL_GPIOPIN10
#define BOARD_PIC_REG_BOARD_REV
uint32_t BOARD_imuEnable(bool enable)
Enables or disables the accelerometer and gyroscope sensor.
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_init(void)
Initializes the Thunderboard Sense board.
#define I2C_FLAG_WRITE_WRITE
Indicate write sequence using two buffers: S+ADDR(W)+DATA0+DATA1+P.
#define BOARD_RGBLED_BLUE_PIN
uint32_t BOARD_picReadReg(uint8_t reg, uint8_t *result)
Reads a register in the IO expander.
#define BOARD_PIC_REG_CCS_CTRL_WAKE
__STATIC_INLINE void TIMER_CompareBufSet(TIMER_TypeDef *timer, unsigned int ch, uint32_t val)
Set compare value buffer for compare/capture channel when operating in compare or PWM mode...
#define BOARD_PIC_REG_DEVICE_ID1
#define BOARD_RGBLED_BLUE_CCLOC
#define BOARD_PIC_INT_WAKE_PIN
#define I2C_FLAG_WRITE_READ
Indicate combined write/read sequence: S+ADDR(W)+DATA0+Sr+ADDR(R)+DATA1+P.
#define BOARD_PIC_REG_MIC_CTRL
#define PRS_CH_CTRL_SOURCESEL_GPIOH
__STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out port register to 0.
uint32_t BOARD_envSensEnableIRQ(bool enable)
Enables or disables the environmental sensor group (Pressure, RH/Temp, UV/Ambient light and Hall sens...
#define BOARD_BUTTON_PORT
void TIMER_InitCC(TIMER_TypeDef *timer, unsigned int ch, const TIMER_InitCC_TypeDef *init)
Initialize TIMER compare/capture channel.
#define BOARD_PIC_DEVICE_ID
#define BOARD_PIC_REG_INT_ENABLE_IMU
#define BOARD_FLASH_PIN_SPI_CS
#define USART_INITSYNC_DEFAULT
#define BOARD_RGBLED_RED_PORT
#define BOARD_RGBLED_RED_PIN
uint16_t addr
Address to use after (repeated) start.
#define BOARD_PIC_REG_CCS_CTRL_EN
BOARD module header file.
Peripheral Reflex System (PRS) peripheral API.
void BOARD_rgbledPowerEnable(bool enable)
Enables or disables the RGB LED power supply line.
uint32_t BOARD_gasSensorEnable(bool enable)
Enables or disables the Air Quality / Gas Sensor.
uint32_t BOARD_picGetDeviceId(void)
Reads the device ID of the IO expander.