26 #include <libopencmsis/core_cm3.h> 27 #include <libopencm3/cm3/nvic.h> 28 #include <libopencm3/stm32/rcc.h> 29 #include <libopencm3/stm32/gpio.h> 30 #include <libopencm3/stm32/timer.h> 39 #define SENSOR_DHT11_TIMER 3 40 #define SENSOR_DHT11_CHANNEL 1 41 #define SENSOR_DHT11_JITTER 0.1 44 volatile bool sensor_dht11_measurement_received = false; 49 SENSOR_DHT11_HOST_START,
50 SENSOR_DHT11_HOST_STARTED,
51 SENSOR_DHT11_SLAVE_START,
52 SENSOR_DHT11_SLAVE_BIT,
155 case (SENSOR_DHT11_HOST_STARTED):
158 case (SENSOR_DHT11_SLAVE_START):
165 case (SENSOR_DHT11_SLAVE_BIT):
library to query measurements from Aosong DHT11 temperature and relative humidity sensor (API) ...
#define RCC_TIM_CH(x, y)
get RCC for port based on TIMx_CHy identifier
#define NVIC_TIM_IRQ(x)
get NVIC IRQ for timer base on TIM identifier
#define TIM_SR_CCIF(x)
get TIM_SR_CCxIF based on CHx identifier
static void sensor_dht11_reset(void)
reset all states
#define TIM_DIER_CCIE(x)
get TIM_DIER_CCxIE based on CHx identifier
global definitions and methods (API)
#define TIM_CCR(x, y)
get TIM_CCRy register based on TIMx_CHy identifier
#define SENSOR_DHT11_CHANNEL
channel used as input capture
sensor_dht11_state_t
communication states
void sensor_dht11_setup(void)
setup peripherals to communicate with sensor
volatile bool sensor_dht11_measurement_received
a measurement response has been received
volatile uint8_t sensor_dht11_bit
the bit number being sent (MSb first), up to 40
#define RCC_TIM(x)
get RCC for timer based on TIM identifier
#define TIM_CH_PIN(x, y)
get pin based on TIMx_CHy identifier
void TIM_ISR(2)
timer ISR to measure edge timing
#define SENSOR_DHT11_TIMER
timer peripheral
#define TIM_IC(x)
get TIM_IC based on CHx identifier
bool sensor_dht11_measurement_request(void)
request measurement from sensor
#define TIM_IC_IN_TI(x)
get TIM_IC_IN_TI based on CHx identifier
#define TIM_CH_PORT(x, y)
get port based on TIMx_CHy identifier
measurement returned by sensor
struct sensor_dht11_measurement_t sensor_dht11_measurement_decode(void)
decode received measurement
uint8_t humidity
relative humidity in RH (20-95)
volatile uint8_t sensor_dht11_bits[5]
the 40 bits (5 bytes) being sent by the device
#define TIM(x)
get TIM based on TIM identifier
uint8_t temperature
temperature in °C (0-50)
#define SENSOR_DHT11_JITTER
signal timing jitter tolerated in timing
enum sensor_dht11_state_t sensor_dht11_state
current communication state