Example code stm32nucleof401re_01_serial
Dependencies: mbed
main.cpp@0:a4fdcf8d64df, 2020-02-05 (annotated)
- Committer:
- perlatecnica
- Date:
- Wed Feb 05 17:10:52 2020 +0000
- Revision:
- 0:a4fdcf8d64df
v1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
perlatecnica | 0:a4fdcf8d64df | 1 | /* Copyright (c) 2019 Perlatecnica |
perlatecnica | 0:a4fdcf8d64df | 2 | * |
perlatecnica | 0:a4fdcf8d64df | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
perlatecnica | 0:a4fdcf8d64df | 4 | * you may not use this file except in compliance with the License. |
perlatecnica | 0:a4fdcf8d64df | 5 | * You may obtain a copy of the License at |
perlatecnica | 0:a4fdcf8d64df | 6 | * |
perlatecnica | 0:a4fdcf8d64df | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
perlatecnica | 0:a4fdcf8d64df | 8 | * |
perlatecnica | 0:a4fdcf8d64df | 9 | * Unless required by applicable law or agreed to in writing, software |
perlatecnica | 0:a4fdcf8d64df | 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
perlatecnica | 0:a4fdcf8d64df | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
perlatecnica | 0:a4fdcf8d64df | 12 | * See the License for the specific language governing permissions and |
perlatecnica | 0:a4fdcf8d64df | 13 | * limitations under the License. |
perlatecnica | 0:a4fdcf8d64df | 14 | */ |
perlatecnica | 0:a4fdcf8d64df | 15 | |
perlatecnica | 0:a4fdcf8d64df | 16 | /**************************************************** |
perlatecnica | 0:a4fdcf8d64df | 17 | * RAPID PROTOTYPING WITH NUCLEO * |
perlatecnica | 0:a4fdcf8d64df | 18 | * Example Code 01: Serial * |
perlatecnica | 0:a4fdcf8d64df | 19 | * Author: Mauro D'Angelo * |
perlatecnica | 0:a4fdcf8d64df | 20 | * Organization: Perlatecnica * |
perlatecnica | 0:a4fdcf8d64df | 21 | ***************************************************** |
perlatecnica | 0:a4fdcf8d64df | 22 | * Serial Client configuration * |
perlatecnica | 0:a4fdcf8d64df | 23 | * 9600 bauds, 8-bit data, no parity * |
perlatecnica | 0:a4fdcf8d64df | 24 | *****************************************************/ |
perlatecnica | 0:a4fdcf8d64df | 25 | |
perlatecnica | 0:a4fdcf8d64df | 26 | #include "mbed.h" |
perlatecnica | 0:a4fdcf8d64df | 27 | |
perlatecnica | 0:a4fdcf8d64df | 28 | // It creates an instance of the class Serial. 'pc' is the name of the variable and assign the TX and RX pin to it |
perlatecnica | 0:a4fdcf8d64df | 29 | Serial pc(USBTX, USBRX); |
perlatecnica | 0:a4fdcf8d64df | 30 | |
perlatecnica | 0:a4fdcf8d64df | 31 | // Entry point |
perlatecnica | 0:a4fdcf8d64df | 32 | int main() { |
perlatecnica | 0:a4fdcf8d64df | 33 | // Print to the serial console a string |
perlatecnica | 0:a4fdcf8d64df | 34 | pc.printf("Hello World !\r\n"); |
perlatecnica | 0:a4fdcf8d64df | 35 | pc.printf("Here I'm !\r\n"); |
perlatecnica | 0:a4fdcf8d64df | 36 | pc.printf("It works !\r\n"); |
perlatecnica | 0:a4fdcf8d64df | 37 | } |
perlatecnica | 0:a4fdcf8d64df | 38 | |
perlatecnica | 0:a4fdcf8d64df | 39 | // OBSERVE THAT ONCE THE MESSAGES HAVE BEEN PRINTED, NOTHING ELSE HAPPENS |
perlatecnica | 0:a4fdcf8d64df | 40 | |
perlatecnica | 0:a4fdcf8d64df | 41 | // EXERCISE: Modify the printed messages |