
Simple test program to get familiar with functionality of MBED RTOS on ST Nucleo-F411RE. Tasks for LED blinking, user button, temperature measurement with DS1620, temperature measurement with internal temperature sensor of ST32F411RE, ultrasonic distance measurement and displaying result on 16x2 TextLCD.
Dependencies: DS1620_improved TextLCD_improved mbed-rtos mbed
Diff: tsk_temp.cpp
- Revision:
- 9:645f0e517017
- Child:
- 11:e89f89c0920b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsk_temp.cpp Mon Dec 14 11:32:15 2015 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "rtos.h" + +#include "DS1620.h" + +#include "tsk_temp.h" + + +struct temp_data_struct temp_data = { 20, 10.0f }; + +static DS1620 ds1620Sensor(PB_4, PB_10, PB_3); + + +void initDS1620Temp(void) { + + ds1620Sensor.setSerialClockFrequency(freq500k); + + if ((ds1620Sensor.readConfig() & 0x03) != 0x03) { + ds1620Sensor.writeConfig(0x03); + } +} + +void temp_thread(void const *args) { + + while (true) { + ds1620Sensor.startConversion(); + + // Wait for conversion completion (Tconv = 750 ms typ) + Thread::wait(750); + while (!(ds1620Sensor.readConfig() & 0x80)) + Thread::wait(10); + + temp_data.temperature = ds1620Sensor.getHighResolutionTemperature(); + temp_data.temp_raw = ds1620Sensor.readTemperatureRaw(); + } +}