
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@2:c190b9b39089, 2015-12-12 (annotated)
- Committer:
- dzoni
- Date:
- Sat Dec 12 20:15:24 2015 +0000
- Revision:
- 2:c190b9b39089
- Parent:
- 0:75ede6a15252
- Child:
- 5:ff77acf7d21d
Release 1.1 (optimization of TextLCD library)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dzoni | 0:75ede6a15252 | 1 | #include "mbed.h" |
dzoni | 0:75ede6a15252 | 2 | #include "DS1620.h" |
dzoni | 0:75ede6a15252 | 3 | #include "TextLCD.h" |
dzoni | 0:75ede6a15252 | 4 | |
dzoni | 0:75ede6a15252 | 5 | |
dzoni | 0:75ede6a15252 | 6 | DigitalOut myled(LED1); |
dzoni | 0:75ede6a15252 | 7 | |
dzoni | 0:75ede6a15252 | 8 | int main() { |
dzoni | 0:75ede6a15252 | 9 | |
dzoni | 2:c190b9b39089 | 10 | wait_us(500000); |
dzoni | 0:75ede6a15252 | 11 | |
dzoni | 0:75ede6a15252 | 12 | TextLCD lcd(PA_8, PA_7, PA_9, PA_1, PB_5, PA_10, TextLCD::LCD16x2); |
dzoni | 0:75ede6a15252 | 13 | |
dzoni | 0:75ede6a15252 | 14 | DS1620 ds1620Sensor(PB_4, PB_10, PB_3); |
dzoni | 0:75ede6a15252 | 15 | |
dzoni | 0:75ede6a15252 | 16 | float temperature; |
dzoni | 0:75ede6a15252 | 17 | uint32_t uiCnt=0; |
dzoni | 0:75ede6a15252 | 18 | |
dzoni | 0:75ede6a15252 | 19 | ds1620Sensor.setSerialClockFrequency(freq500k); |
dzoni | 0:75ede6a15252 | 20 | if ((ds1620Sensor.readConfig() & 0x03) != 0x03) { |
dzoni | 0:75ede6a15252 | 21 | ds1620Sensor.writeConfig(0x03); |
dzoni | 0:75ede6a15252 | 22 | } |
dzoni | 0:75ede6a15252 | 23 | |
dzoni | 0:75ede6a15252 | 24 | while(1) { |
dzoni | 0:75ede6a15252 | 25 | myled = myled ^ 1; |
dzoni | 0:75ede6a15252 | 26 | |
dzoni | 0:75ede6a15252 | 27 | ds1620Sensor.startConversion(); |
dzoni | 0:75ede6a15252 | 28 | |
dzoni | 0:75ede6a15252 | 29 | // Wait for conversion completion (Tconv = 750 ms typ) |
dzoni | 0:75ede6a15252 | 30 | wait_us(750000); |
dzoni | 0:75ede6a15252 | 31 | while (!(ds1620Sensor.readConfig() & 0x80)) |
dzoni | 0:75ede6a15252 | 32 | wait_us(10000); |
dzoni | 0:75ede6a15252 | 33 | |
dzoni | 0:75ede6a15252 | 34 | temperature = ds1620Sensor.getHighResolutionTemperature(); |
dzoni | 0:75ede6a15252 | 35 | |
dzoni | 0:75ede6a15252 | 36 | lcd.cls(); |
dzoni | 0:75ede6a15252 | 37 | lcd.printf("Raw: %u", ds1620Sensor.readTemperatureRaw()); |
dzoni | 0:75ede6a15252 | 38 | uiCnt += 1; |
dzoni | 0:75ede6a15252 | 39 | lcd.locate(0, 1); |
dzoni | 0:75ede6a15252 | 40 | lcd.printf("Float: %3.2f%cC", temperature, 0xdf); |
dzoni | 0:75ede6a15252 | 41 | |
dzoni | 0:75ede6a15252 | 42 | wait_us(250000); |
dzoni | 0:75ede6a15252 | 43 | } |
dzoni | 0:75ede6a15252 | 44 | } |
dzoni | 0:75ede6a15252 | 45 |