boards: sltb001a: adapt to common board files.
This commit is contained in:
parent
eada4b71df
commit
abf16ef658
@ -1,3 +1,5 @@
|
|||||||
MODULE = board
|
MODULE = board
|
||||||
|
|
||||||
|
DIRS = $(RIOTBOARD)/common/silabs
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.base
|
include $(RIOTBASE)/Makefile.base
|
||||||
|
|||||||
@ -4,7 +4,7 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
|
|||||||
USEMODULE += si7021
|
USEMODULE += si7021
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# i2c is required for environmental sensors
|
# include board common dependencies
|
||||||
USEMODULE += periph_i2c
|
include $(RIOTBOARD)/common/silabs/Makefile.dep
|
||||||
|
|
||||||
include $(RIOTCPU)/efm32/Makefile.dep
|
include $(RIOTCPU)/efm32/Makefile.dep
|
||||||
|
|||||||
@ -6,9 +6,16 @@ export CPU_MODEL = efr32mg1p132f256gm48
|
|||||||
PORT_LINUX ?= /dev/ttyACM0
|
PORT_LINUX ?= /dev/ttyACM0
|
||||||
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
|
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
|
||||||
|
|
||||||
|
# setup serial terminal
|
||||||
|
include $(RIOTMAKE)/tools/serial.inc.mk
|
||||||
|
|
||||||
# setup JLink for flashing
|
# setup JLink for flashing
|
||||||
export JLINK_DEVICE := EFR32MG1PxxxF256
|
export JLINK_DEVICE := EFR32MG1PxxxF256
|
||||||
include $(RIOTMAKE)/tools/jlink.inc.mk
|
include $(RIOTMAKE)/tools/jlink.inc.mk
|
||||||
|
|
||||||
# setup serial terminal
|
# add board common drivers
|
||||||
include $(RIOTMAKE)/tools/serial.inc.mk
|
USEMODULE += boards_common_silabs
|
||||||
|
USEMODULE += silabs_pic
|
||||||
|
|
||||||
|
# include board common
|
||||||
|
include $(RIOTBOARD)/common/silabs/Makefile.include
|
||||||
|
|||||||
@ -20,91 +20,43 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "cpu.h"
|
#include "board_common.h"
|
||||||
|
#include "pic.h"
|
||||||
|
|
||||||
#include "periph/gpio.h"
|
#include "periph/gpio.h"
|
||||||
#include "periph/i2c.h"
|
|
||||||
|
|
||||||
#if BMP280_ENABLED || CCS811_ENABLED || ICM_20648_ENABLED || \
|
|
||||||
SI1133_ENABLED || SI7021_ENABLED || SI7210A_ENABLED || \
|
|
||||||
RGB_LED1_ENABLED || RGB_LED2_ENABLED || RGB_LED3_ENABLED || \
|
|
||||||
RGB_LED4_ENABLED
|
|
||||||
static inline void board_usleep(uint32_t delay)
|
|
||||||
{
|
|
||||||
/* decrement + compare take two cycles, therefore divide by two */
|
|
||||||
uint32_t count = (delay * (SystemCoreClock / 1000 / 1000)) / 2;
|
|
||||||
|
|
||||||
while (count--) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void board_pic_init(void)
|
|
||||||
{
|
|
||||||
gpio_init(PIC_INT_WAKE_PIN, GPIO_OD);
|
|
||||||
gpio_set(PIC_INT_WAKE_PIN);
|
|
||||||
|
|
||||||
i2c_init_master(PIC_I2C, I2C_SPEED_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void board_pic_write(uint8_t addr, uint8_t value)
|
|
||||||
{
|
|
||||||
/* toggle the pin for 4 us */
|
|
||||||
gpio_clear(PIC_INT_WAKE_PIN);
|
|
||||||
board_usleep(4);
|
|
||||||
|
|
||||||
/* write to gpio expander */
|
|
||||||
i2c_acquire(PIC_I2C);
|
|
||||||
uint8_t bytes[] = { addr, value };
|
|
||||||
i2c_write_bytes(PIC_I2C, PIC_I2C_ADDR, bytes, 2);
|
|
||||||
i2c_release(PIC_I2C);
|
|
||||||
|
|
||||||
/* put PIC in sleep mode again */
|
|
||||||
gpio_set(PIC_INT_WAKE_PIN);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void board_init(void)
|
void board_init(void)
|
||||||
{
|
{
|
||||||
/* initialize the CPU */
|
/* initialize the CPU */
|
||||||
cpu_init();
|
cpu_init();
|
||||||
|
|
||||||
/* initialize the LEDs */
|
/* perform common board initialization */
|
||||||
gpio_init(LED0_PIN, GPIO_OUT);
|
board_common_init();
|
||||||
gpio_init(LED1_PIN, GPIO_OUT);
|
|
||||||
|
|
||||||
/* initialize the push buttons */
|
|
||||||
gpio_init(PB0_PIN, GPIO_IN);
|
|
||||||
gpio_init(PB1_PIN, GPIO_IN);
|
|
||||||
|
|
||||||
/* initialize the environmental sensors (multiple ones) */
|
|
||||||
#if BMP280_ENABLED || CCS811_ENABLED || ICM_20648_ENABLED || \
|
|
||||||
SI1133_ENABLED || SI7021_ENABLED || SI7210A_ENABLED || \
|
|
||||||
RGB_LED1_ENABLED || RGB_LED2_ENABLED || RGB_LED3_ENABLED || \
|
|
||||||
RGB_LED4_ENABLED
|
|
||||||
board_pic_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifdef MODULE_SILABS_PIC
|
||||||
/* enable the CCS811 air quality/gas sensor */
|
/* enable the CCS811 air quality/gas sensor */
|
||||||
#if CCS811_ENABLED
|
#if CCS811_ENABLED
|
||||||
board_pic_write(CCS811_PIC_ADDR, (1 << CCS811_PIC_EN_BIT) | (1 << CCS811_PIC_WAKE_BIT));
|
pic_write(CCS811_PIC_ADDR, (1 << CCS811_PIC_EN_BIT) | (1 << CCS811_PIC_WAKE_BIT));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* enable the IMU sensor */
|
/* enable the IMU sensor */
|
||||||
#if ICM_20648_ENABLED
|
#if ICM_20648_ENABLED
|
||||||
board_pic_write(ICM20648_PIC_ADDR, 1 << ICM20648_PIC_EN_BIT);
|
pic_write(ICM20648_PIC_ADDR, 1 << ICM20648_PIC_EN_BIT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* enable the environmental sensors */
|
/* enable the environmental sensors */
|
||||||
#if BMP280_ENABLED || SI1133_ENABLED || SI7021_ENABLED || SI7210A_ENABLED
|
#if BMP280_ENABLED || SI1133_ENABLED || SI7021_ENABLED || SI7210A_ENABLED
|
||||||
board_pic_write(ENV_SENSE_PIC_ADDR, 1 << ENV_SENSE_PIC_BIT);
|
pic_write(ENV_SENSE_PIC_ADDR, 1 << ENV_SENSE_PIC_BIT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* enable the RGB leds */
|
/* enable the RGB leds */
|
||||||
#if RGB_LED1_ENABLED || RGB_LED2_ENABLED || RGB_LED3_ENABLED || RGB_LED4_ENABLED
|
#if RGB_LED1_ENABLED || RGB_LED2_ENABLED || RGB_LED3_ENABLED || RGB_LED4_ENABLED
|
||||||
board_pic_write(RGB_LED_ADDR,
|
pic_write(RGB_LED_ADDR,
|
||||||
(1 << RGB_LED_EN_BIT) |
|
(1 << RGB_LED_EN_BIT) |
|
||||||
(RGB_LED1_ENABLED << RGB_LED1_EN_BIT) |
|
(RGB_LED1_ENABLED << RGB_LED1_EN_BIT) |
|
||||||
(RGB_LED2_ENABLED << RGB_LED2_EN_BIT) |
|
(RGB_LED2_ENABLED << RGB_LED2_EN_BIT) |
|
||||||
(RGB_LED3_ENABLED << RGB_LED3_EN_BIT) |
|
(RGB_LED3_ENABLED << RGB_LED3_EN_BIT) |
|
||||||
(RGB_LED4_ENABLED << RGB_LED4_EN_BIT));
|
(RGB_LED4_ENABLED << RGB_LED4_EN_BIT));
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user