
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: main.cpp
- Revision:
- 0:75ede6a15252
- Child:
- 2:c190b9b39089
diff -r 000000000000 -r 75ede6a15252 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 12 19:15:13 2015 +0000 @@ -0,0 +1,45 @@ +#include "mbed.h" +#include "DS1620.h" +#include "TextLCD.h" + + +DigitalOut myled(LED1); + +int main() { + + wait_us(1000000); + + TextLCD lcd(PA_8, PA_7, PA_9, PA_1, PB_5, PA_10, TextLCD::LCD16x2); + + DS1620 ds1620Sensor(PB_4, PB_10, PB_3); + + float temperature; + uint32_t uiCnt=0; + + ds1620Sensor.setSerialClockFrequency(freq500k); + if ((ds1620Sensor.readConfig() & 0x03) != 0x03) { + ds1620Sensor.writeConfig(0x03); + } + + while(1) { + myled = myled ^ 1; + + ds1620Sensor.startConversion(); + + // Wait for conversion completion (Tconv = 750 ms typ) + wait_us(750000); + while (!(ds1620Sensor.readConfig() & 0x80)) + wait_us(10000); + + temperature = ds1620Sensor.getHighResolutionTemperature(); + + lcd.cls(); + lcd.printf("Raw: %u", ds1620Sensor.readTemperatureRaw()); + uiCnt += 1; + lcd.locate(0, 1); + lcd.printf("Float: %3.2f%cC", temperature, 0xdf); + + wait_us(250000); + } +} + \ No newline at end of file