Commit 2872af1a authored by Christian Taedcke's avatar Christian Taedcke Committed by Kumar Gala
Browse files

boards: efr32mg_sltb004a: Add support for sensor ccs811



The on-board sensor has a enable pin that must be pulled
high in order to power the sensor.
Since no i2c sensor connected to ENV_I2C is supported by zephyr yet,
changed the pins of i2c1 to be connected to CCS811_I2C pins.

Signed-off-by: default avatarChristian Taedcke <christian.taedcke@lemonbeat.com>
parent 8ab0d153
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
# Copyright (c) 2020 Christian Taedcke
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_CCS811)
  zephyr_library()
  zephyr_library_sources(board.c)
  zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
endif()
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020 Christian Taedcke
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <init.h>
#include "board.h"
#include <drivers/gpio.h>
#include <sys/printk.h>

static int efr32mg_sltb004a_init(struct device *dev)
{
	struct device *cur_dev;

	ARG_UNUSED(dev);

#ifdef CONFIG_CCS811
	/* Enable the CCS811 power */
	cur_dev = device_get_binding(CCS811_PWR_ENABLE_GPIO_NAME);
	if (!cur_dev) {
		printk("CCS811 power gpio port was not found!\n");
		return -ENODEV;
	}

	gpio_pin_configure(cur_dev, CCS811_PWR_ENABLE_GPIO_PIN, GPIO_OUTPUT);
	gpio_pin_set(cur_dev, CCS811_PWR_ENABLE_GPIO_PIN, 1);

#endif /* CONFIG_CCS811 */

	return 0;
}

/* needs to be done after GPIO driver init */
SYS_INIT(efr32mg_sltb004a_init, PRE_KERNEL_1, CONFIG_BOARD_INIT_PRIORITY);
+16 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020 Christian Taedcke
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef __INC_BOARD_H
#define __INC_BOARD_H

/* CCS811 specific pins */
#ifdef CONFIG_CCS811
#define CCS811_PWR_ENABLE_GPIO_NAME	"GPIO_F"
#define CCS811_PWR_ENABLE_GPIO_PIN	14
#endif /* CONFIG_CCS811 */

#endif /* __INC_BOARD_H */
+2 −2
Original line number Diff line number Diff line
@@ -120,9 +120,9 @@ in the board's and microcontroller's datasheets and manuals.
+------+-------------+-----------------------------------+
| PC11 | I2C_SCL     | EXP15_I2C_SCL I2C0_SCL #15        |
+------+-------------+-----------------------------------+
| PC4  | I2C_SDA     | ENV_I2C_SDA I2C1_SDA #17          |
| PB6  | I2C_SDA     | CCS811_I2C_SDA I2C1_SDA #6        |
+------+-------------+-----------------------------------+
| PC5  | I2C_SCL     | ENV_I2C_SCL I2C1_SCL #17          |
| PB7  | I2C_SCL     | CCS811_I2C_SCL I2C1_SCL #6        |
+------+-------------+-----------------------------------+
| PK0  | SPI_MOSI    | Flash MOSI US2_TX #29             |
+------+-------------+-----------------------------------+
+10 −3
Original line number Diff line number Diff line
@@ -105,9 +105,16 @@
};

&i2c1 {
	location-sda = <GECKO_LOCATION(17) GECKO_PORT_C GECKO_PIN(4)>;
	location-scl = <GECKO_LOCATION(17) GECKO_PORT_C GECKO_PIN(5)>;
	status = "okay";
	location-sda = <GECKO_LOCATION(6) GECKO_PORT_B GECKO_PIN(6)>;
	location-scl = <GECKO_LOCATION(6) GECKO_PORT_B GECKO_PIN(7)>;

	ccs811: ccs811@5a {
		compatible = "ams,ccs811";
		reg = <0x5a>;
		label = "CCS811";
		irq-gpios = <&gpiof 13 GPIO_ACTIVE_LOW>;
		wake-gpios = <&gpiof 15 GPIO_ACTIVE_LOW>;
	};
};

&rtcc0 {