
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
main.cpp
- Committer:
- dzoni
- Date:
- 2015-12-12
- Revision:
- 2:c190b9b39089
- Parent:
- 0:75ede6a15252
- Child:
- 5:ff77acf7d21d
File content as of revision 2:c190b9b39089:
#include "mbed.h" #include "DS1620.h" #include "TextLCD.h" DigitalOut myled(LED1); int main() { wait_us(500000); 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); } }