EFM32 Happy Gecko Software Documentation  efm32hg-doc-5.1.2
board.h
Go to the documentation of this file.
1 /***************************************************************************/
16 #ifndef __BOARD_H_
17 #define __BOARD_H_
18 
19 #include <stdint.h>
20 #include "em_gpio.h"
21 #include "i2cspm.h"
22 
25 
26 
27 /***************************************************************************/
32 /***************************************************************************/
38 #define BOARD_OK 0
39 #define BOARD_ERROR_I2C_TRANSFER_TIMEOUT 0x01
40 #define BOARD_ERROR_I2C_TRANSFER_NACK 0x02
41 #define BOARD_ERROR_I2C_TRANSFER_FAILED 0x03
42 #define BOARD_ERROR_PIC_ID_MISMATCH 0x04
43 #define BOARD_ERROR_PIC_FW_INVALID 0x05
44 #define BOARD_ERROR_PIC_FW_UPDATE_FAILED 0x06
48 /***************************************************************************/
54 #define BOARD_PIC_DEVICE_ID 0x50584F49
55 #define BOARD_PIC_INT_WAKE_PORT gpioPortD
56 #define BOARD_PIC_INT_WAKE_PIN 10
58 #define BOARD_RGBLED_TIMER (TIMER0)
59 #define BOARD_RGBLED_CMU_CLK cmuClock_TIMER0
60 #define BOARD_RGBLED_RED_PORT gpioPortD
61 #define BOARD_RGBLED_RED_PIN 11
62 #define BOARD_RGBLED_RED_CCLOC 19
63 #define BOARD_RGBLED_GREEN_PORT gpioPortD
64 #define BOARD_RGBLED_GREEN_PIN 12
65 #define BOARD_RGBLED_GREEN_CCLOC 19
66 #define BOARD_RGBLED_BLUE_PORT gpioPortD
67 #define BOARD_RGBLED_BLUE_PIN 13
68 #define BOARD_RGBLED_BLUE_CCLOC 19
70 #define BOARD_BUTTON_PORT gpioPortD
71 #define BOARD_BUTTON_SHIFT 14
72 #define BOARD_BUTTON_LEFT 0x01
73 #define BOARD_BUTTON_RIGHT 0x02
74 #define BOARD_BUTTON_MASK 0x03
75 #define BOARD_BUTTON_LEFT_PORT gpioPortD
76 #define BOARD_BUTTON_LEFT_PIN 14
77 #define BOARD_BUTTON_RIGHT_PORT gpioPortD
78 #define BOARD_BUTTON_RIGHT_PIN 15
79 #define BOARD_BUTTON_INT_FLAG 0x04
80 #define BOARD_BUTTON_INT_ENABLE true
82 #define BOARD_FLASH_USART (USART1)
83 #define BOARD_FLASH_PORT_SPI gpioPortC
84 #define BOARD_FLASH_PORT_SPI_CS gpioPortA
85 #define BOARD_FLASH_PIN_SPI_MOSI 6
86 #define BOARD_FLASH_PIN_SPI_MISO 7
87 #define BOARD_FLASH_PIN_SPI_CLK 8
88 #define BOARD_FLASH_PIN_SPI_CS 4
92 /***************************************************************************/
97 uint32_t BOARD_init ( void );
98 
99 uint32_t BOARD_imuEnable ( bool enable );
100 uint32_t BOARD_imuEnableIRQ ( bool enable );
101 
102 uint32_t BOARD_envSensEnable ( bool enable );
103 uint32_t BOARD_envSensEnableIRQ ( bool enable );
104 
105 void BOARD_flashDeepPowerDown ( void );
106 
107 uint32_t BOARD_gasSensorEnable ( bool enable );
108 uint32_t BOARD_gasSensorEnableIRQ ( bool enable );
109 uint32_t BOARD_gasSensorWake ( bool wake );
110 
111 void BOARD_ledSet ( uint8_t leds );
112 
113 uint32_t BOARD_micEnable ( bool enable );
114 
115 uint32_t BOARD_picIntGet ( uint8_t *flags );
116 uint32_t BOARD_picIntClear ( uint8_t flags );
117 uint32_t BOARD_picWriteReg ( uint8_t addr, uint8_t value );
118 uint32_t BOARD_picReadReg ( uint8_t addr, uint8_t *result );
119 uint32_t BOARD_picRegBitsSet ( uint8_t addr, bool set, uint8_t bitMask );
120 uint32_t BOARD_picGetDeviceId ( void );
121 uint32_t BOARD_picGetFwRevision ( uint8_t *major, uint8_t *minor, uint8_t *patch );
122 uint8_t BOARD_picGetHwRevision ( void );
123 bool BOARD_picIsLegacyIntCtrl ( void );
124 
125 uint8_t BOARD_pushButtonGetState ( void );
126 void BOARD_pushButtonEnableIRQ ( bool enable );
127 
128 void BOARD_rgbledEnable ( bool enable, uint8_t mask );
129 void BOARD_rgbledSetColor ( uint8_t red, uint8_t green, uint8_t blue );
130 void BOARD_rgbledSetRawColor ( uint16_t red, uint16_t green, uint16_t blue );
131 void BOARD_rgbledPowerEnable ( bool enable );
132 
137 #endif /* __BOARD_H_ */
uint32_t BOARD_picIntGet(uint8_t *flags)
Reads the interrupt status flags from the interrupt controller.
Definition: board.c:631
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
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
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
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
uint32_t BOARD_picIntClear(uint8_t flags)
Clears the interrupt status flags in the interrupt controller.
Definition: board.c:652
uint32_t BOARD_picWriteReg(uint8_t reg, uint8_t value)
Writes a register in the IO expander.
Definition: board.c:676
Power and Interrupt Controller Register Definitions.
void BOARD_flashDeepPowerDown(void)
Puts the Flash chip in deep power down mode.
Definition: board.c:219
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
uint32_t BOARD_micEnable(bool enable)
Enables or disables the MEMS microphone.
Definition: board.c:536
uint32_t BOARD_imuEnableIRQ(bool enable)
Enables or disables the accelerometer and gyroscope GPIO interrupt.
Definition: board.c:469
RGB LED profiles.
General Purpose IO (GPIO) peripheral API.
I2C simple poll-based master mode driver for the DK/STK.
uint8_t BOARD_picGetHwRevision(void)
Reads the hardware revision of the IO expander.
Definition: board.c:790
void BOARD_rgbledEnable(bool enable, uint8_t mask)
Enables or disables the RGB LED power supply line.
Definition: board.c:317
uint32_t BOARD_gasSensorEnableIRQ(bool enable)
Enables or disables the Air Quality / Gas Sensor GPIO interrupt.
Definition: board.c:609
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
void BOARD_pushButtonEnableIRQ(bool enable)
Enables or disables the pushbutton GPIO interrupt.
Definition: board.c:277
uint32_t BOARD_imuEnable(bool enable)
Enables or disables the accelerometer and gyroscope sensor.
Definition: board.c:448
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
uint32_t BOARD_picReadReg(uint8_t reg, uint8_t *result)
Reads a register in the IO expander.
Definition: board.c:702
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
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