Commit 15c753b2 authored by Daniel Friesel's avatar Daniel Friesel
Browse files

driver configuration is now kconfig-first

parent 460ecf07
Loading
Loading
Loading
Loading
+1 −112
Original line number Diff line number Diff line
@@ -44,176 +44,68 @@ ifneq (${stack_usage}, )
	COMMON_FLAGS += -fstack-usage
endif

# Allow .config driver entries to be overriddenvia commandline / environment

ifneq ($(findstring dummy,${drivers}), )
	CONFIG_driver_dummy = y
endif

ifneq ($(findstring lm75,${drivers}), )
	CONFIG_driver_lm75 = y
endif

ifneq ($(findstring s5851a,${drivers}), )
	CONFIG_driver_s5851a = y
endif

ifneq ($(findstring am2320,${drivers}), )
	CONFIG_driver_am2320 = y
endif

ifneq ($(findstring bme280,${drivers}), )
	CONFIG_driver_bme280 = y
endif

ifneq ($(findstring bme680,${drivers}), )
	CONFIG_driver_bme680 = y
endif

ifneq ($(findstring ccs811,${drivers}), )
	CONFIG_driver_ccs811 = y
endif

ifneq ($(findstring eeprom24lc64,${drivers}), )
	CONFIG_driver_eeprom24lc64 = y
endif

ifneq ($(findstring max44006,${drivers}), )
	CONFIG_driver_max44006 = y
endif

ifneq ($(findstring max44009,${drivers}), )
	CONFIG_driver_max44009 = y
endif

ifneq ($(findstring hdc1080,${drivers}), )
	CONFIG_driver_hdc1080 = y
endif

ifneq ($(findstring mpu9250,${drivers}), )
	CONFIG_driver_mpu9250 = y
endif

ifneq ($(findstring mmsimple,${drivers}), )
	CONFIG_driver_mmsimple = y
endif

ifneq ($(findstring mmsubstate,${drivers}), )
	CONFIG_driver_mmsubstate = y
endif

ifneq ($(findstring nrf24l01,${drivers}), )
	CONFIG_driver_nrf24l01 = y
endif

ifneq ($(findstring sharp96,${drivers}), )
	CONFIG_driver_sharp96 = y
endif

ifneq ($(findstring ssd1306,${drivers}), )
	CONFIG_driver_ssd1306 = y
endif

ifneq ($(findstring tsl2591,${drivers}), )
	CONFIG_driver_tsl2591 = y
endif

ifneq ($(findstring scd4x,${drivers}), )
	CONFIG_driver_scd4x = y
endif

ifneq ($(findstring resistive_load,${drivers}), )
	CONFIG_driver_resistive_load = y
endif

ifneq ($(findstring aemr_transition_sync,${drivers}), )
	CONFIG_driver_aemr_transition_sync = y
endif

ifneq ($(findstring softi2c,${drivers}), )
	CONFIG_driver_softi2c = y
endif

# Load drivers

ifdef CONFIG_driver_dummy
	CXX_TARGETS += src/driver/dummy.cc
	COMMON_FLAGS += -DDRIVER_DUMMY
endif

ifdef CONFIG_driver_lm75
	CXX_TARGETS += src/driver/lm75.cc
	COMMON_FLAGS += -DDRIVER_LM75
endif

ifdef CONFIG_driver_s5851a
	CXX_TARGETS += src/driver/s5851a.cc
	COMMON_FLAGS += -DDRIVER_S5851A
endif

ifdef CONFIG_driver_am2320
	CXX_TARGETS += src/driver/am2320.cc
	COMMON_FLAGS += -DDRIVER_AM2320
endif

ifdef CONFIG_driver_bme280
	CXX_TARGETS += src/driver/bme280.cc src/driver/bme680_util.cc
	COMMON_FLAGS += -DDRIVER_BME280
endif

ifdef CONFIG_driver_bme680
	CXX_TARGETS += src/driver/bme680.cc src/driver/bme680_util.cc
	COMMON_FLAGS += -DDRIVER_BME680
endif

ifdef CONFIG_driver_ccs811
	CXX_TARGETS += src/driver/ccs811.cc
	COMMON_FLAGS += -DDRIVER_CCS811
endif

ifdef CONFIG_driver_eeprom24lc64
	CXX_TARGETS += src/driver/eeprom24lc64.cc
	COMMON_FLAGS += -DDRIVER_EEPROM24LC64
endif

ifdef CONFIG_driver_max44006
	CXX_TARGETS += src/driver/max44006.cc
	COMMON_FLAGS += -DDRIVER_MAX44006
endif

ifdef CONFIG_driver_max44009
	CXX_TARGETS += src/driver/max44009.cc
	COMMON_FLAGS += -DDRIVER_MAX44009
endif

ifdef CONFIG_driver_hdc1080
	CXX_TARGETS += src/driver/hdc1080.cc
	COMMON_FLAGS += -DDRIVER_HDC1080
endif

ifdef CONFIG_driver_mpu9250
	CXX_TARGETS += src/driver/mpu9250.cc
	COMMON_FLAGS += -DDRIVER_MPU9250
endif

ifdef CONFIG_driver_mmsimple
	CXX_TARGETS += src/driver/mmsimple.cc
	COMMON_FLAGS += -DDRIVER_MMSIMPLE
endif

ifdef CONFIG_driver_mmsubstate
	CXX_TARGETS += src/driver/mmsubstate.cc
	COMMON_FLAGS += -DDRIVER_MMSUBSTATE
endif

ifdef CONFIG_driver_tsl2591
	CXX_TARGETS += src/driver/tsl2591.cc
	COMMON_FLAGS += -DDRIVER_TSL2591
endif

ifdef CONFIG_driver_scd4x
	CXX_TARGETS += src/driver/scd4x.cc
	COMMON_FLAGS += -DDRIVER_SCD4X
endif

ifdef CONFIG_driver_nrf24l01
@@ -233,7 +125,6 @@ ifdef CONFIG_driver_nrf24l01
		nrf24l01_cs_pin ?= pc0
		nrf24l01_irq_pin ?= pc2
	endif
	COMMON_FLAGS += -DDRIVER_NRF24L01
	COMMON_FLAGS += -DNRF24L01_EN_PIN=GPIO::${nrf24l01_en_pin}
	COMMON_FLAGS += -DNRF24L01_CS_PIN=GPIO::${nrf24l01_cs_pin}
	COMMON_FLAGS += -DNRF24L01_IRQ_PIN=GPIO::${nrf24l01_irq_pin}
@@ -259,7 +150,7 @@ endif

ifdef CONFIG_driver_ssd1306
	CXX_TARGETS += src/driver/ssd1306.cc
	COMMON_FLAGS += -DDRIVER_SSD1306 -DSSD1306_WIDTH=${CONFIG_driver_ssd1306_width} -DSSD1306_HEIGHT=${CONFIG_driver_ssd1306_height}
	COMMON_FLAGS += -DSSD1306_WIDTH=${CONFIG_driver_ssd1306_width} -DSSD1306_HEIGHT=${CONFIG_driver_ssd1306_height}
endif

ifdef CONFIG_driver_resistive_load
@@ -268,7 +159,6 @@ ifdef CONFIG_driver_resistive_load
	resistor2_pin ?= p3_1
	resistor3_pin ?= p3_2
	resistor4_pin ?= p3_3
	COMMON_FLAGS += -DDRIVER_RESISTIVE_LOAD
	COMMON_FLAGS += -DRESISTIVE_LOAD_PIN1=GPIO::${resistor1_pin}
	COMMON_FLAGS += -DRESISTIVE_LOAD_PIN2=GPIO::${resistor2_pin}
	COMMON_FLAGS += -DRESISTIVE_LOAD_PIN3=GPIO::${resistor3_pin}
@@ -281,7 +171,6 @@ endif

ifdef CONFIG_driver_softi2c
	CXX_TARGETS += src/driver/soft_i2c.cc
	COMMON_FLAGS += -DCONFIG_driver_softi2c
endif

ifdef CONFIG_meta_driver_hardware_i2c
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ ifdef app
	override arch_drivers += ,i2c
	CONFIG_driver_bme680 = y
	CONFIG_driver_max44009 = y
	COMMON_FLAGS += -DCONFIG_driver_bme680 -DCONFIG_driver_max44009
endif

COMMON_FLAGS += -DBME680_FLOAT_POINT_COMPENSATION
+1 −0
Original line number Diff line number Diff line
@@ -7,4 +7,5 @@
ifdef app
	override arch_drivers += ,adc,i2c
	CONFIG_driver_mpu9250 = y
	COMMON_FLAGS += -DCONFIG_driver_mpu9250
endif
+2 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@

ifdef app
	override arch_drivers += ,i2c
	CONFIG_driver_ccS811 = y
	CONFIG_driver_ccs811 = y
	COMMON_FLAGS += -DCONFIG_driver_ccs811
	loop = 1
endif
+29 −29
Original line number Diff line number Diff line
@@ -13,57 +13,57 @@
#include "driver/soft_i2c.h"
#endif

#ifdef DRIVER_LM75
#ifdef CONFIG_driver_lm75
#include "driver/lm75.h"
#endif
#ifdef DRIVER_S5851A
#ifdef CONFIG_driver_s5851a
#include "driver/s5851a.h"
#endif
#ifdef DRIVER_AM2320
#ifdef CONFIG_driver_am2320
#include "driver/am2320.h"
#endif
#ifdef DRIVER_BME280
#ifdef CONFIG_driver_bme280
#include "driver/bme280.h"
#include "driver/bme680_util.h"
#endif
#ifdef DRIVER_BME680
#ifdef CONFIG_driver_bme680
#include "driver/bme680.h"
#include "driver/bme680_util.h"
#endif
#ifdef DRIVER_CCS811
#ifdef CONFIG_driver_ccs811
#include "driver/ccs811.h"
#endif
#ifdef DRIVER_MAX44009
#ifdef CONFIG_driver_max44009
#include "driver/max44009.h"
#endif
#ifdef DRIVER_HDC1080
#ifdef CONFIG_driver_hdc1080
#include "driver/hdc1080.h"
#endif
#ifdef DRIVER_MPU9250
#ifdef CONFIG_driver_mpu9250
#include "driver/mpu9250.h"
#endif
#ifdef DRIVER_TSL2591
#ifdef CONFIG_driver_tsl2591
#include "driver/tsl2591.h"
#endif
#ifdef DRIVER_SCD4X
#ifdef CONFIG_driver_scd4x
#include "driver/scd4x.h"
#endif

void loop(void)
{
#ifdef DRIVER_LM75
#ifdef CONFIG_driver_lm75
	kout << "temperature_celsius: ";
	kout.printf_float(lm75.getTemp());
	kout << endl;
#endif

#ifdef DRIVER_S5851A
#ifdef CONFIG_driver_s5851a
	kout << "temperature_celsius: ";
	kout.printf_float(s5851a.getTemp());
	kout << endl;
#endif

#ifdef DRIVER_AM2320
#ifdef CONFIG_driver_am2320
	am2320.read();
	if (am2320.getStatus() == 0) {
		kout.printf_float(am2320.getTemp());
@@ -75,7 +75,7 @@ void loop(void)
	}
#endif

#ifdef DRIVER_BME280
#ifdef CONFIG_driver_bme280
	struct bme280_data comp_data;
	int8_t rslt = bme280.getSensorData(BME280_ALL, &comp_data);
	kout << "BME280 read " << rslt << endl;
@@ -84,7 +84,7 @@ void loop(void)
	kout << "BME280 pressure " << (float)comp_data.pressure / 100 << " Pa" << endl;
#endif

#ifdef DRIVER_BME680
#ifdef CONFIG_driver_bme680
	struct bme680_field_data data;
	bme680.setSensorMode();
	arch.delay_ms(250);
@@ -95,7 +95,7 @@ void loop(void)
	kout << "BME680 gas resistance " << data.gas_resistance << endl;
#endif

#ifdef DRIVER_CCS811
#ifdef CONFIG_driver_ccs811
	ccs811.read();
	kout << bin;
	kout << "CCS811 status / error: " << ccs811.status << " / " << ccs811.error_id << endl;
@@ -103,7 +103,7 @@ void loop(void)
	kout << "CCS811 tVOC / eCO₂ : " << ccs811.tvoc << " ppb / " << ccs811.eco2 << " ppm" << endl;
#endif

#ifdef DRIVER_HDC1080
#ifdef CONFIG_driver_hdc1080
	/*
	hdc1080.heater(1);
	for (unsigned char i = 0; i < 50; i++) {
@@ -114,7 +114,7 @@ void loop(void)
	kout << "HDC1080 humidity " << hdc1080.getRH() << " %H" << endl;
#endif

#ifdef DRIVER_MPU9250
#ifdef CONFIG_driver_mpu9250
	int mx, my, mz;
	kout << "Temperature: " << mpu9250.getTemperature() << endl;
	kout << "Accel X " << mpu9250.getAccelX() << endl;
@@ -129,18 +129,18 @@ void loop(void)
	kout << "Magnet Z " << mz << endl;
#endif

#ifdef DRIVER_MAX44009
#ifdef CONFIG_driver_max44009
	kout.printf_float(max44009.getLux());
	kout << endl;
#endif

#ifdef DRIVER_TSL2591
#ifdef CONFIG_driver_tsl2591
	tsl2591.read();
	kout << dec << "TSL2591 CH0: " << tsl2591.ch0 << " / CH1: " << tsl2591.ch1;
	kout << hex << "   (status: 0x" << tsl2591.getStatus() << ")" << endl;
#endif

#ifdef DRIVER_SCD4X
#ifdef CONFIG_driver_scd4x
	scd4x.read();
	kout << dec << "CO₂: " << scd4x.co2 << " ppm" << endl;
	kout << "Temperature: ";
@@ -167,7 +167,7 @@ int main(void)
	kout << "I2C setup OK" << endl;
#endif

#ifdef DRIVER_BME280
#ifdef CONFIG_driver_bme280
	bme280.intf = BME280_I2C_INTF;
	bme280.read = bme680_i2c_read;
	bme280.write = bme680_i2c_write;
@@ -186,7 +186,7 @@ int main(void)
	bme280.enterNormalMode();
#endif

#ifdef DRIVER_BME680
#ifdef CONFIG_driver_bme680
	bme680.intf = BME680_I2C_INTF;
	bme680.read = bme680_i2c_read;
	bme680.write = bme680_i2c_write;
@@ -209,7 +209,7 @@ int main(void)
	bme680.setSensorSettings(BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_GAS_SENSOR_SEL);
#endif

#ifdef DRIVER_CCS811
#ifdef CONFIG_driver_ccs811
	kout << hex;
	kout << "CCS811 HWID: " << ccs811.getManufacturerID() << endl;
	arch.delay_ms(65);
@@ -223,22 +223,22 @@ int main(void)
	arch.delay_ms(50);
#endif

#ifdef DRIVER_HDC1080
#ifdef CONFIG_driver_hdc1080
	hdc1080.init();
	if (hdc1080.getManufacturerID() != 0x5449) {
		kout << "[!] invalid HDC1080 manufacturer ID: " << hex << hdc1080.getManufacturerID() << endl;
	}
#endif

#ifdef DRIVER_MPU9250
#ifdef CONFIG_driver_mpu9250
	mpu9250.init();
#endif

#ifdef DRIVER_TSL2591
#ifdef CONFIG_driver_tsl2591
	tsl2591.init();
#endif

#ifdef DRIVER_SCD4X
#ifdef CONFIG_driver_scd4x
	scd4x.start();
#endif

Loading