![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Serial control with STM32 Nucleo
main.cpp@0:fde0aa5b370d, 2021-04-29 (annotated)
- Committer:
- lucadevito
- Date:
- Thu Apr 29 09:23:17 2021 +0000
- Revision:
- 0:fde0aa5b370d
- Child:
- 1:457c0c664181
1st release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lucadevito | 0:fde0aa5b370d | 1 | /* mbed Microcontroller Library |
lucadevito | 0:fde0aa5b370d | 2 | * Copyright (c) 2019 ARM Limited |
lucadevito | 0:fde0aa5b370d | 3 | * SPDX-License-Identifier: Apache-2.0 |
lucadevito | 0:fde0aa5b370d | 4 | */ |
lucadevito | 0:fde0aa5b370d | 5 | |
lucadevito | 0:fde0aa5b370d | 6 | #include "mbed.h" |
lucadevito | 0:fde0aa5b370d | 7 | #include "platform/mbed_thread.h" |
lucadevito | 0:fde0aa5b370d | 8 | |
lucadevito | 0:fde0aa5b370d | 9 | |
lucadevito | 0:fde0aa5b370d | 10 | // Blinking rate in milliseconds |
lucadevito | 0:fde0aa5b370d | 11 | #define BLINKING_RATE_MS 500 |
lucadevito | 0:fde0aa5b370d | 12 | |
lucadevito | 0:fde0aa5b370d | 13 | Serial pc(USBTX,USBRX); |
lucadevito | 0:fde0aa5b370d | 14 | |
lucadevito | 0:fde0aa5b370d | 15 | int main() |
lucadevito | 0:fde0aa5b370d | 16 | { |
lucadevito | 0:fde0aa5b370d | 17 | // Initialise the digital pin LED1 as an output |
lucadevito | 0:fde0aa5b370d | 18 | DigitalOut led(LED1); |
lucadevito | 0:fde0aa5b370d | 19 | |
lucadevito | 0:fde0aa5b370d | 20 | pc.printf("Hello World !\r\n"); |
lucadevito | 0:fde0aa5b370d | 21 | pc.printf("Here I'm !\r\n"); |
lucadevito | 0:fde0aa5b370d | 22 | pc.printf("It works !\r\n"); |
lucadevito | 0:fde0aa5b370d | 23 | |
lucadevito | 0:fde0aa5b370d | 24 | while (true) { |
lucadevito | 0:fde0aa5b370d | 25 | led = !led; |
lucadevito | 0:fde0aa5b370d | 26 | thread_sleep_for(BLINKING_RATE_MS); |
lucadevito | 0:fde0aa5b370d | 27 | } |
lucadevito | 0:fde0aa5b370d | 28 | } |