Smartage application
Dependencies: BufferedSerial SX1276GenericLib USBDeviceHT mbed Crypto X_NUCLEO_IKS01A2
Fork of STM32L0_LoRa by
main.cpp@19:7763501775e5, 2018-05-17 (annotated)
- Committer:
- marcozecchini
- Date:
- Thu May 17 09:52:47 2018 +0000
- Revision:
- 19:7763501775e5
- Parent:
- 18:d5527ce82e6b
- Child:
- 20:1557c9d9c183
First working version for Discovery-L072Z
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Helmut64 | 0:c43b6919ae15 | 1 | /* |
Helmut64 | 17:98f2528e8399 | 2 | * Copyright (c) 2018 HELIOS Software GmbH |
Helmut64 | 0:c43b6919ae15 | 3 | * 30826 Garbsen (Hannover) Germany |
Helmut64 | 0:c43b6919ae15 | 4 | * Licensed under the Apache License, Version 2.0); |
Helmut64 | 0:c43b6919ae15 | 5 | */ |
Helmut64 | 0:c43b6919ae15 | 6 | #include "main.h" |
Helmut64 | 0:c43b6919ae15 | 7 | |
Helmut64 | 0:c43b6919ae15 | 8 | |
Helmut64 | 17:98f2528e8399 | 9 | DigitalOut myled(LED); |
marcozecchini | 19:7763501775e5 | 10 | //D12 TRIGGER D11 ECHO |
marcozecchini | 19:7763501775e5 | 11 | HCSR04 sensor(D12, D11); |
Helmut64 | 0:c43b6919ae15 | 12 | |
Helmut64 | 17:98f2528e8399 | 13 | int main() { |
Helmut64 | 17:98f2528e8399 | 14 | #ifdef HELTEC_STM32L4 |
Helmut64 | 17:98f2528e8399 | 15 | DigitalOut vext(POWER_VEXT); |
Helmut64 | 17:98f2528e8399 | 16 | vext = POWER_VEXT_ON; |
Helmut64 | 17:98f2528e8399 | 17 | #endif |
Helmut64 | 17:98f2528e8399 | 18 | /* |
Helmut64 | 17:98f2528e8399 | 19 | * inits the Serial or USBSerial when available (230400 baud). |
Helmut64 | 17:98f2528e8399 | 20 | * If the serial uart is not is not connected it swiches to USB Serial |
Helmut64 | 17:98f2528e8399 | 21 | * blinking LED means USBSerial detected, waiting for a connect. |
Helmut64 | 17:98f2528e8399 | 22 | * It waits up to 30 seconds for a USB terminal connections |
Helmut64 | 17:98f2528e8399 | 23 | */ |
marcozecchini | 19:7763501775e5 | 24 | InitSerial(30*1000, &myled); |
marcozecchini | 19:7763501775e5 | 25 | dprintf("SMARTAGE"); |
marcozecchini | 19:7763501775e5 | 26 | |
marcozecchini | 19:7763501775e5 | 27 | while(1){ |
marcozecchini | 19:7763501775e5 | 28 | //Ultrasonic measurement |
marcozecchini | 19:7763501775e5 | 29 | long distance = sensor.distance(); |
marcozecchini | 19:7763501775e5 | 30 | dprintf("distance %d \n",distance); |
marcozecchini | 19:7763501775e5 | 31 | |
marcozecchini | 19:7763501775e5 | 32 | char message[8];//Message to be sent |
marcozecchini | 19:7763501775e5 | 33 | sprintf(message, "%d", distance); |
marcozecchini | 19:7763501775e5 | 34 | dump("Check: ", (uint8_t*)message, 8); |
marcozecchini | 19:7763501775e5 | 35 | |
marcozecchini | 19:7763501775e5 | 36 | SendAndBack((uint8_t*)message); |
marcozecchini | 19:7763501775e5 | 37 | } |
marcozecchini | 19:7763501775e5 | 38 | } |