50#include "lib/sensors.h"
54#define PM10_SENSOR_PORT_BASE GPIO_PORT_TO_BASE(PM10_SENSOR_CTRL_PORT)
55#define PM10_SENSOR_PIN_MASK GPIO_PIN_MASK(PM10_SENSOR_CTRL_PIN)
57static int pm10_channel;
60configure(
int type,
int value)
62 if(type != SENSORS_ACTIVE) {
71 GPIO_CLR_PIN(PM10_SENSOR_PORT_BASE, PM10_SENSOR_PIN_MASK);
73 pm10_channel = (1 << value);
74 return adc_zoul.configure(SENSORS_HW_INIT, pm10_channel);
91 GPIO_SET_PIN(PM10_SENSOR_PORT_BASE, PM10_SENSOR_PIN_MASK);
95 val = (uint32_t)adc_zoul.value(pm10_channel);
97 if(val == ZOUL_SENSORS_ERROR) {
98 printf(
"PM10 sensor: failed retrieving data\n");
106 val *= PM10_EXTERNAL_VREF;
107 val /= PM10_EXTERNAL_VREF_CROSSVAL;
116 GPIO_CLR_PIN(PM10_SENSOR_PORT_BASE, PM10_SENSOR_PIN_MASK);
118 return (uint16_t)val;
121SENSORS_SENSOR(pm10, PM10_SENSOR, value, configure, NULL);
Header file for the Zoul ADC sensors API.
Header file for the Zoul ADC interface.
Header file with register and macro declarations for the cc2538 GPIO module.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE.
#define GPIO_SET_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE high.
#define GPIO_CLR_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE low.
#define GPIO_SET_OUTPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to output.
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
Set Port:Pin override function.
#define IOC_OVERRIDE_DIS
Override Disabled.
Header file with declarations for the I/O Control module.
GP2Y1010AU0F PM10 sensor driver.
Header file for the cc2538 System Control driver.
Implementation of a generic module controlling Zoul sensors.