EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2
board.c
Go to the documentation of this file.
1 /***************************************************************************/
16 #include <stdint.h>
17 #include <stdbool.h>
18 
19 #include "i2cspm.h"
20 #include "em_cmu.h"
21 #include "em_gpio.h"
22 #include "em_prs.h"
23 #include "em_timer.h"
24 #include "em_usart.h"
25 
26 #include "thunderboard/board.h"
27 #include "thunderboard/util.h"
28 
29 /***************************************************************************/
56 /****************************************************************************/
57 /* Local function variables */
58 /****************************************************************************/
59 static I2C_TypeDef *i2cDevice; /* I2C device used to communicate with the IO expander */
60 static TIMER_TypeDef *pwmTimer; /* Timer used to generate PWM for the RGB LEDs */
61 static const uint8_t lightLevels[] = BOARD_RGBLED_PROFILE_EXP; /* Array to linearize the light level of the RGB LEDs */
62 static bool rgbledEnable; /* The status of the RGB LEDs, enabled or disabled */
63 static bool timerEnable; /* The status of the PWM timer, enabled or disabled */
64 static bool isLegacyIntCtrl; /* Shows if the legacy interrupt control method should be used */
65 
66 /****************************************************************************/
67 /* Local function prototypes */
68 /****************************************************************************/
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 );
74 
77 /***************************************************************************/
83 /***************************************************************************/
90 uint32_t BOARD_init( void )
91 {
92 
93  int timeout;
94  int i;
95  uint32_t picdevid;
99  uint32_t status;
100  uint8_t major, minor, patch;
101 
102  rgbledEnable = false;
103  timerEnable = false;
104  isLegacyIntCtrl = true;
105 
106  status = BOARD_OK;
107 
108  /* Enable GPIO clock */
110 
111  /*********************************************************************/
113  /*********************************************************************/
116 
117 #if 0
118  /* Route INT pin from IO-expander to PF6 */
119  CMU_ClockEnable( cmuClock_PRS, true );
121 
124  PRS->ROUTEPEN = PRS_ROUTEPEN_CH0PEN;
125  PRS->ROUTELOC0 = PRS_ROUTELOC0_CH0LOC_LOC6;
126  GPIO_PinModeSet( gpioPortF, 6, gpioModePushPull, 0 );
127 #endif
128 
129  /*********************************************************************/
131  /*********************************************************************/
134 
135  I2CSPM_Init( &i2cInit );
136  i2cDevice = i2cInit.port;
137 
138 
139  /*********************************************************************/
141  /*********************************************************************/
142  timeout = 50;
143  while( timeout-- > 0 ) {
144  status = BOARD_picWriteReg(0,0);
145  if( status == BOARD_OK ) {
146  break;
147  }
148  UTIL_delay( 10 );
149  }
150 
151  if( status == BOARD_OK ) {
152  picdevid = BOARD_picGetDeviceId();
153  if( picdevid != BOARD_PIC_DEVICE_ID ) {
155  }
156  }
157 
158  if( status == BOARD_OK ) {
159  picWake();
160  status = BOARD_picGetFwRevision(&major, &minor, &patch);
161  picSleep();
162  if( status == BOARD_OK ) {
163  if( major == 0 && minor <= 3 ) {
164  isLegacyIntCtrl = true;
165  }
166  else {
167  isLegacyIntCtrl = false;
168  }
169  }
170  }
171 
172  /*********************************************************************/
174  /*********************************************************************/
175  picWake();
176  for( i = 0; i < BOARD_PIC_NUM_APP_REGS; i++ ) {
177  picWriteReg( i, 0 );
178  }
179  picSleep();
180 
181  /*********************************************************************/
183  /*********************************************************************/
188 
189  pwmTimer = BOARD_RGBLED_TIMER;
190 
191  timerInit.debugRun = true;
192  timerInit.prescale = timerPrescale2;
193  TIMER_Init( pwmTimer, &timerInit );
194 
195  /* 65536 counts at 38.4 MHz / 2 = 293 Hz. */
196  TIMER_TopSet( pwmTimer, 0xFFFF );
197 
198  ccInit.mode = timerCCModePWM;
199  TIMER_InitCC( pwmTimer, 0, &ccInit );
200  TIMER_InitCC( pwmTimer, 1, &ccInit );
201  TIMER_InitCC( pwmTimer, 2, &ccInit );
202 
203  pwmTimer->ROUTEPEN = 0;
207 
208  return status;
209 
210 }
211 
212 /***************************************************************************/
220 {
221 
222  /* Initialize USART for SPI transactions to the flash */
223  flashSPIInit();
224 
225  /* Wake up device first if it was in DP already */
227  UTIL_delay( 10 );
229 
230  /* Send DP command ( 0xB9 ) */
234 
235  /* We must disable SPI communication */
237  GPIO_PinModeSet( gpioPortC, 6, gpioModeDisabled, 0 );
238  GPIO_PinModeSet( gpioPortC, 7, gpioModeDisabled, 0 );
239  GPIO_PinModeSet( gpioPortC, 8, gpioModeDisabled, 0 );
240 
241  return;
242 
243 }
244 
245 /***************************************************************************/
253 {
254 
255  uint32_t portState;
256  uint8_t buttonState;
257 
258  portState = GPIO_PortInGet( BOARD_BUTTON_PORT );
259  buttonState = (uint8_t) ( ( portState >> BOARD_BUTTON_SHIFT ) & BOARD_BUTTON_MASK );
260 
261  buttonState = ~buttonState & BOARD_BUTTON_MASK;
262 
263  return buttonState;
264 
265 }
266 
267 /***************************************************************************/
277 void BOARD_pushButtonEnableIRQ( bool enable )
278 {
279 
280  GPIO_IntConfig( BOARD_BUTTON_PORT, BOARD_BUTTON_LEFT_PIN, false, true, enable );
282 
283 }
284 
285 /***************************************************************************/
295 void BOARD_rgbledPowerEnable( bool enable )
296 {
297 
299 
300  return;
301 
302 }
303 
304 /***************************************************************************/
317 void BOARD_rgbledEnable( bool enable, uint8_t mask )
318 {
319 
320  if( ( ( mask != 0 ) && ( enable == true ) ) || ( ( ( mask & 0xf ) == 0xf ) && ( enable == false ) ) ) {
321  BOARD_rgbledPowerEnable( enable );
322  rgbledEnable = enable;
323  }
324 
327 
328  return;
329 
330 }
331 
332 /***************************************************************************/
343 void BOARD_ledSet( uint8_t leds )
344 {
345 
346  if( rgbledEnable && leds != 0 ) {
347  /* Reset PWM colors and stop timer */
348  BOARD_rgbledSetRawColor( 0, 0, 0 );
349  BOARD_rgbledEnable( false, 0xFF );
350  }
351 
352  uint8_t pins[2] = { BOARD_RGBLED_GREEN_PIN, BOARD_RGBLED_RED_PIN };
353  for( int i = 0; i < 2; i++ ) {
354  if( ( (leds >> i) & 1 ) == 1 ) {
356  }
357  else {
359  }
360  }
361 
362 
363  return;
364 
365 }
366 
367 /***************************************************************************/
384 void BOARD_rgbledSetRawColor( uint16_t red, uint16_t green, uint16_t blue )
385 {
386 
387  if( ( red == 0 ) && ( green == 0 ) && ( blue == 0 ) ) {
388  timerEnable = false;
389  TIMER_Enable ( pwmTimer, timerEnable );
390  TIMER_CompareBufSet ( pwmTimer, 0, 0 );
391  TIMER_CompareBufSet ( pwmTimer, 1, 0 );
392  TIMER_CompareBufSet ( pwmTimer, 2, 0 );
393  /* Ensure LED pins are disabled before changing ROUTE */
394  BOARD_ledSet( 0 );
395  pwmTimer->ROUTEPEN = 0;
396  }
397  else {
398  timerEnable = true;
399  TIMER_Enable ( pwmTimer, timerEnable );
400  TIMER_CompareBufSet ( pwmTimer, 0, red );
401  TIMER_CompareBufSet ( pwmTimer, 1, green );
402  TIMER_CompareBufSet ( pwmTimer, 2, blue );
404  }
405 
406  return;
407 
408 }
409 
410 /***************************************************************************/
427 void BOARD_rgbledSetColor( uint8_t red, uint8_t green, uint8_t blue )
428 {
429 
430  BOARD_rgbledSetRawColor( 256 * (uint16_t)lightLevels[red],
431  256 * (uint16_t)lightLevels[green],
432  256 * (uint16_t)lightLevels[blue] );
433 
434  return;
435 
436 }
437 
438 /***************************************************************************/
448 uint32_t BOARD_imuEnable( bool enable )
449 {
450 
451  uint32_t status;
452 
453  status = BOARD_picWriteReg( BOARD_PIC_REG_IMU_CTRL, enable );
454 
455  return status;
456 
457 }
458 
459 /***************************************************************************/
469 uint32_t BOARD_imuEnableIRQ( bool enable )
470 {
471 
472  uint32_t status;
473 
474  /* Enable SPI interrupts in IO-expander */
476 
477  return status;
478 
479 }
480 
481 /***************************************************************************/
492 uint32_t BOARD_envSensEnable( bool enable )
493 {
494 
495  uint32_t status;
496 
498 
499  return status;
500 
501 }
502 
503 /***************************************************************************/
514 uint32_t BOARD_envSensEnableIRQ( bool enable )
515 {
516 
517  uint32_t status;
518 
519  /* Enable I2C interrupts in IO-expander */
521 
522  return status;
523 
524 }
525 
526 /***************************************************************************/
536 uint32_t BOARD_micEnable( bool enable )
537 {
538 
539  uint32_t status;
540 
541  status = BOARD_picWriteReg( BOARD_PIC_REG_MIC_CTRL, enable );
542 
543  return status;
544 
545 }
546 
547 /***************************************************************************/
557 uint32_t BOARD_gasSensorEnable( bool enable )
558 {
559 
560  uint32_t status;
561 
562  if( enable ) {
564  }
565  else {
567  }
568 
569  return status;
570 
571 }
572 
573 /***************************************************************************/
583 uint32_t BOARD_gasSensorWake( bool wake )
584 {
585 
586  uint32_t status;
587 
588  if( wake ) {
590  }
591  else {
593  }
594 
595  return status;
596 
597 }
598 
599 /***************************************************************************/
609 uint32_t BOARD_gasSensorEnableIRQ( bool enable )
610 {
611 
612  uint32_t status;
613 
614  /* Enable I2C interrupts in IO-expander */
616 
617  return status;
618 
619 }
620 
621 /***************************************************************************/
631 uint32_t BOARD_picIntGet( uint8_t *flags )
632 {
633 
634  uint32_t status;
635 
636  status = BOARD_picReadReg( BOARD_PIC_REG_INT_FLAG, flags );
637 
638  return status;
639 
640 }
641 
642 /***************************************************************************/
652 uint32_t BOARD_picIntClear( uint8_t flags )
653 {
654 
655  uint32_t status;
656 
657  status = BOARD_picWriteReg( BOARD_PIC_REG_INT_CLEAR, flags );
658 
659  return status;
660 
661 }
662 
663 /***************************************************************************/
676 uint32_t BOARD_picWriteReg( uint8_t reg, uint8_t value )
677 {
678 
679  uint32_t status;
680 
681  picWake();
682  status = picWriteReg( reg, value );
683  picSleep();
684 
685  return status;
686 
687 }
688 
689 /***************************************************************************/
702 uint32_t BOARD_picReadReg( uint8_t reg, uint8_t *result )
703 {
704 
705  uint32_t status;
706 
707  picWake();
708  status = picReadReg( reg, result );
709  picSleep();
710 
711  return status;
712 
713 }
714 
715 /***************************************************************************/
731 uint32_t BOARD_picRegBitsSet( uint8_t addr, bool set, uint8_t bitMask )
732 {
733 
734  uint32_t status;
735  uint8_t value;
736 
737  picWake();
738 
739  status = picReadReg( addr, &value );
740  if( status != BOARD_OK ) {
741  goto cleanup;
742  }
743 
744  if( set ) {
745  value |= bitMask;
746  }
747  else {
748  value &= ~bitMask;
749  }
750 
751  status = picWriteReg( addr, value );
752  picSleep();
753 
754 cleanup:
755  return status;
756 
757 }
758 
759 /***************************************************************************/
766 uint32_t BOARD_picGetDeviceId( void )
767 {
768 
769  uint32_t result;
770  uint8_t *pU8;
771 
772  pU8 = (uint8_t *) &result;
773 
778 
779  return result;
780 
781 }
782 
783 /***************************************************************************/
790 uint8_t BOARD_picGetHwRevision ( void )
791 {
792 
793  uint8_t rev;
794 
796 
797  return rev;
798 
799 }
800 
801 /***************************************************************************/
817 uint32_t BOARD_picGetFwRevision( uint8_t *major, uint8_t *minor, uint8_t *patch )
818 {
819 
820  uint32_t status;
821 
822  *major = 0;
823  *minor = 0;
824  *patch = 0;
825 
826  /* Keep int/wake low (legacy behavior) */
829 
830  status = picReadReg( BOARD_PIC_REG_VERSION_MAJOR, major );
831  if( status != BOARD_OK ) {
832  goto cleanup;
833  }
834  status = picReadReg( BOARD_PIC_REG_VERSION_MINOR, minor );
835  if( status != BOARD_OK ) {
836  goto cleanup;
837  }
838  status = picReadReg( BOARD_PIC_REG_VERSION_PATCH, patch );
839 
840 cleanup:
843 
845 
846  return status;
847 
848 }
849 
850 /***************************************************************************/
858 {
859 
860  return isLegacyIntCtrl;
861 
862 }
863 
866 /****************************************************************************/
867 /* Local functions */
868 /****************************************************************************/
869 
870 /***************************************************************************/
883 static uint32_t picReadReg( uint8_t addr, uint8_t *result )
884 {
885 
886  uint32_t status;
887 
890 
891  seq.addr = 0x90;
893  seq.buf[0].len = 1;
894  seq.buf[0].data = &addr;
895  seq.buf[1].len = 1;
896  seq.buf[1].data = result;
897 
898  ret = I2CSPM_Transfer( i2cDevice, &seq );
899 
900  status = BOARD_OK;
901 
902  if( ret == i2cTransferInProgress ) {
904  }
905  else if( ret == i2cTransferNack ) {
907  }
908  else if( ret != i2cTransferDone ) {
910  }
911 
912  return status;
913 
914 }
915 
916 /***************************************************************************/
929 static uint32_t picWriteReg( uint8_t addr, uint8_t value )
930 {
931 
932  uint32_t status;
933 
936 
937  seq.addr = 0x90;
939  seq.buf[0].len = 1;
940  seq.buf[0].data = &addr;
941  seq.buf[1].len = 1;
942  seq.buf[1].data = &value;
943 
944  ret = I2CSPM_Transfer( i2cDevice, &seq );
945 
946  status = BOARD_OK;
947 
948  if( ret == i2cTransferInProgress ) {
950  }
951  else if( ret == i2cTransferNack ) {
953  }
954  else if( ret != i2cTransferDone ) {
956  }
957 
958  return status;
959 
960 }
961 
962 /***************************************************************************/
969 static inline void picWake( void )
970 {
971 
972  volatile int delay;
973 
975 
977 
978  if( !isLegacyIntCtrl ) {
979  /* Minimum 5 us delay */
980  delay = 27;
981  while( --delay );
982 
985 
987  }
988 
989  return;
990 
991 }
992 
993 /***************************************************************************/
1000 static inline void picSleep( void )
1001 {
1002 
1003  if( isLegacyIntCtrl ){
1004 
1007 
1009  }
1010 
1011  return;
1012 
1013 }
1014 
1015 /***************************************************************************/
1022 static void flashSPIInit( void )
1023 {
1024 
1026 
1027  /* Enable clocks */
1028  CMU_ClockEnable( cmuClock_GPIO, true );
1030 
1031  /* Configure GPIO pins */
1036 
1037  /* Configure USART */
1038  init.msbf = true;
1039  init.baudrate = 8000000;
1041 
1044 
1045  /* Wait for flash to power up */
1046  UTIL_delay( 10 );
1047 
1048  /* Set EM4 pin retention so chip select stays high if we enter EM4 */
1050 
1051  return;
1052 
1053 }
1054 
Clock management unit (CMU) API.
uint32_t BOARD_picIntGet(uint8_t *flags)
Reads the interrupt status flags from the interrupt controller.
Definition: board.c:631
__STATIC_INLINE void TIMER_TopSet(TIMER_TypeDef *timer, uint32_t val)
Set top value for timer.
Definition: em_timer.h:948
void BOARD_ledSet(uint8_t leds)
Turns on or off the red and/or green LED.
Definition: board.c:343
uint32_t BOARD_gasSensorWake(bool wake)
Wakes up the Air Quality / Gas Sensor.
Definition: board.c:583
#define TIMER_ROUTEPEN_CC2PEN
I2C_TransferReturn_TypeDef I2CSPM_Transfer(I2C_TypeDef *i2c, I2C_TransferSeq_TypeDef *seq)
Perform I2C transfer.
Definition: i2cspm.c:124
#define BOARD_BUTTON_LEFT_PORT
Definition: board.h:75
__IOM uint32_t ROUTEPEN
#define BOARD_PIC_REG_DEVICE_ID3
void USART_InitSync(USART_TypeDef *usart, const USART_InitSync_TypeDef *init)
Init USART for synchronous mode.
Definition: em_usart.c:640
#define BOARD_PIC_REG_LED_CTRL_PWR_EN
#define BOARD_FLASH_PIN_SPI_CLK
Definition: board.h:87
void I2CSPM_Init(I2CSPM_Init_TypeDef *init)
Initalize I2C peripheral.
Definition: i2cspm.c:39
__STATIC_INLINE void TIMER_Enable(TIMER_TypeDef *timer, bool enable)
Start/stop TIMER.
Definition: em_timer.h:660
#define BOARD_BUTTON_RIGHT_PIN
Definition: board.h:78
#define _TIMER_ROUTELOC0_CC0LOC_SHIFT
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...
Definition: board.c:427
#define TIMER_ROUTEPEN_CC1PEN
#define BOARD_ERROR_PIC_ID_MISMATCH
Definition: board.h:42
#define BOARD_FLASH_PIN_SPI_MISO
Definition: board.h:86
#define BOARD_RGBLED_CMU_CLK
Definition: board.h:59
#define BOARD_BUTTON_RIGHT_PORT
Definition: board.h:77
#define TIMER_INITCC_DEFAULT
Definition: em_timer.h:381
bool BOARD_picIsLegacyIntCtrl(void)
Checks if the legacy interrupt control method should be used.
Definition: board.c:857
uint8_t BOARD_pushButtonGetState(void)
Gets the state of the pushbuttons.
Definition: board.c:252
#define BOARD_RGBLED_BLUE_PORT
Definition: board.h:66
__STATIC_INLINE void GPIO_IntClear(uint32_t flags)
Clear one or more pending GPIO interrupts.
Definition: em_gpio.h:674
void UTIL_delay(uint32_t ms)
Delays number of msTick Systicks (1 ms)
Definition: util.c:97
#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.
Definition: board.c:817
#define USART_ROUTEPEN_TXPEN
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.
Definition: board.c:652
#define BOARD_BUTTON_LEFT_PIN
Definition: board.h:76
#define BOARD_PIC_REG_LED_CTRL_LED_MASK
#define BOARD_RGBLED_GREEN_PORT
Definition: board.h:63
TIMER_CCMode_TypeDef mode
Definition: em_timer.h:359
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
#define BOARD_ERROR_I2C_TRANSFER_NACK
Definition: board.h:40
uint32_t BOARD_picWriteReg(uint8_t reg, uint8_t value)
Writes a register in the IO expander.
Definition: board.c:676
__STATIC_INLINE uint32_t GPIO_PortInGet(GPIO_Port_TypeDef port)
Read the pad values for GPIO port.
Definition: em_gpio.h:895
#define BOARD_PIC_INT_WAKE_PORT
Definition: board.h:55
#define BOARD_FLASH_USART
Definition: board.h:82
I2C_TransferReturn_TypeDef
Definition: em_i2c.h:179
#define BOARD_PIC_REG_VERSION_MAJOR
#define TIMER_ROUTEPEN_CC0PEN
#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...
Definition: board.c:492
void BOARD_flashDeepPowerDown(void)
Puts the Flash chip in deep power down mode.
Definition: board.c:219
uint32_t BOARD_micEnable(bool enable)
Enables or disables the MEMS microphone.
Definition: board.c:536
#define BOARD_PIC_REG_LED_CTRL
__STATIC_INLINE void GPIO_IntDisable(uint32_t flags)
Disable one or more GPIO interrupts.
Definition: em_gpio.h:686
#define USART_ROUTELOC0_TXLOC_LOC11
#define USART_ROUTELOC0_RXLOC_LOC11
#define USART1
#define BOARD_ERROR_I2C_TRANSFER_FAILED
Definition: board.h:41
#define BOARD_FLASH_PORT_SPI
Definition: board.h:83
#define BOARD_PIC_REG_LED_CTRL_LED_SHIFT
#define BOARD_BUTTON_SHIFT
Definition: board.h:71
#define BOARD_PIC_REG_IMU_CTRL
#define BOARD_RGBLED_TIMER
Definition: board.h:58
__STATIC_INLINE void GPIO_IntEnable(uint32_t flags)
Enable one or more GPIO interrupts.
Definition: em_gpio.h:703
uint32_t BOARD_imuEnableIRQ(bool enable)
Enables or disables the accelerometer and gyroscope GPIO interrupt.
Definition: board.c:469
#define BOARD_RGBLED_GREEN_PIN
Definition: board.h:64
#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.
Definition: em_gpio.c:269
#define BOARD_ERROR_I2C_TRANSFER_TIMEOUT
Definition: board.h:39
General Purpose IO (GPIO) peripheral API.
I2C simple poll-based master mode driver for the DK/STK.
#define BOARD_FLASH_PIN_SPI_MOSI
Definition: board.h:85
uint8_t BOARD_picGetHwRevision(void)
Reads the hardware revision of the IO expander.
Definition: board.c:790
__IOM uint32_t ROUTELOC0
#define TIMER_INIT_DEFAULT
Definition: em_timer.h:301
#define I2CSPM_INIT_DEFAULT
Definition: i2cspm.h:73
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.
Definition: em_gpio.h:856
#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.
Definition: em_cmu.c:1453
#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.
Definition: em_prs.c:74
#define BOARD_PIC_NUM_APP_REGS
I2C_TypeDef * port
Definition: i2cspm.h:53
#define PRS
#define BOARD_PIC_REG_INT_CLEAR
void BOARD_rgbledEnable(bool enable, uint8_t mask)
Enables or disables the RGB LED power supply line.
Definition: board.c:317
#define BOARD_FLASH_PORT_SPI_CS
Definition: board.h:84
uint32_t BOARD_gasSensorEnableIRQ(bool enable)
Enables or disables the Air Quality / Gas Sensor GPIO interrupt.
Definition: board.c:609
#define BOARD_RGBLED_GREEN_CCLOC
Definition: board.h:65
#define PRS_CH_CTRL_SOURCESEL_GPIOH
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...
Definition: board.c:384
#define _TIMER_ROUTELOC0_CC2LOC_SHIFT
#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.
Definition: em_gpio.h:1104
#define USART_ROUTELOC0_CLKLOC_LOC11
#define BOARD_RGBLED_RED_CCLOC
Definition: board.h:62
TIMER_Prescale_TypeDef prescale
Definition: em_timer.h:263
#define BOARD_BUTTON_MASK
Definition: board.h:74
#define BOARD_PIC_REG_INT_ENABLE_UV_ALS
Master mode transfer message structure used to define a complete I2C transfer sequence (from start to...
Definition: em_i2c.h:252
void USART_Reset(USART_TypeDef *usart)
Reset USART/UART to same state as after a HW reset.
Definition: em_usart.c:856
void BOARD_pushButtonEnableIRQ(bool enable)
Enables or disables the pushbutton GPIO interrupt.
Definition: board.c:277
#define BOARD_PIC_REG_VERSION_MINOR
#define EMU
#define PRS_CH_CTRL_SIGSEL_GPIOPIN10
void TIMER_Init(TIMER_TypeDef *timer, const TIMER_Init_TypeDef *init)
Initialize TIMER.
Definition: em_timer.c:76
uint8_t USART_SpiTransfer(USART_TypeDef *usart, uint8_t data)
Perform one 8 bit frame SPI transfer.
Definition: em_usart.c:1050
#define BOARD_PIC_REG_BOARD_REV
#define USART_ROUTEPEN_RXPEN
uint32_t BOARD_imuEnable(bool enable)
Enables or disables the accelerometer and gyroscope sensor.
Definition: board.c:448
#define EMU_EM4CTRL_EM4IORETMODE_EM4EXIT
uint32_t BOARD_picRegBitsSet(uint8_t addr, bool set, uint8_t bitMask)
Sets the given bit(s) in a register in the IO expander.
Definition: board.c:731
#define _TIMER_ROUTELOC0_CC1LOC_SHIFT
uint32_t BOARD_init(void)
Initializes the Thunderboard Sense board.
Definition: board.c:90
#define I2C_FLAG_WRITE_WRITE
Indicate write sequence using two buffers: S+ADDR(W)+DATA0+DATA1+P.
Definition: em_i2c.h:159
#define PRS_ROUTELOC0_CH0LOC_LOC6
#define BOARD_RGBLED_BLUE_PIN
Definition: board.h:67
uint32_t BOARD_picReadReg(uint8_t reg, uint8_t *result)
Reads a register in the IO expander.
Definition: board.c:702
#define BOARD_PIC_REG_CCS_CTRL_WAKE
#define USART_ROUTEPEN_CLKPEN
__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...
Definition: em_timer.h:585
#define BOARD_PIC_REG_DEVICE_ID1
#define BOARD_RGBLED_BLUE_CCLOC
Definition: board.h:68
#define BOARD_PIC_INT_WAKE_PIN
Definition: board.h:56
#define I2C_FLAG_WRITE_READ
Indicate combined write/read sequence: S+ADDR(W)+DATA0+Sr+ADDR(R)+DATA1+P.
Definition: em_i2c.h:148
#define BOARD_OK
Definition: board.h:38
#define BOARD_PIC_REG_MIC_CTRL
__STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin)
Set a single pin in GPIO data out port register to 0.
Definition: em_gpio.h:811
#define PRS_ROUTEPEN_CH0PEN
uint32_t BOARD_envSensEnableIRQ(bool enable)
Enables or disables the environmental sensor group (Pressure, RH/Temp, UV/Ambient light and Hall sens...
Definition: board.c:514
#define BOARD_BUTTON_PORT
Definition: board.h:70
void TIMER_InitCC(TIMER_TypeDef *timer, unsigned int ch, const TIMER_InitCC_TypeDef *init)
Initialize TIMER compare/capture channel.
Definition: em_timer.c:130
#define BOARD_PIC_DEVICE_ID
Definition: board.h:54
#define BOARD_PIC_REG_INT_ENABLE_IMU
#define BOARD_FLASH_PIN_SPI_CS
Definition: board.h:88
#define USART_INITSYNC_DEFAULT
Definition: em_usart.h:467
#define BOARD_RGBLED_RED_PORT
Definition: board.h:60
#define BOARD_RGBLED_RED_PIN
Definition: board.h:61
uint16_t addr
Address to use after (repeated) start.
Definition: em_i2c.h:262
#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.
Definition: board.c:295
uint32_t BOARD_gasSensorEnable(bool enable)
Enables or disables the Air Quality / Gas Sensor.
Definition: board.c:557
uint32_t BOARD_picGetDeviceId(void)
Reads the device ID of the IO expander.
Definition: board.c:766