2021_Colours_ModelRocket / Mbed 2 deprecated receiveUART

Dependencies:   mbed BufferedSerial

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  */
00005 
00006 #include "mbed.h"
00007 #include "PeripheralPins.h"
00008 #include "mbed_toolchain.h"
00009 //#include "BufferedSerial.h"
00010 
00011 extern const PinMap PinMap_UART_RX[] = {
00012     {PA_3,       UART_2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
00013 //  {PA_3,       LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // No LPUART_1 TX
00014     {PA_10,      UART_1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
00015     {PA_15,      UART_2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART2)}, // Connected to STDIO_UART_RX
00016     {PB_7,       UART_1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
00017     {NC, NC, 0}
00018 };
00019 
00020 //BufferedSerial L432(PA_2,PA_3,9600);
00021 //BufferedSerial im920(PA_9,PA_10,38400);
00022 Serial L432(PA_2,PA_3,9600);
00023 //Serial im920(PA_9,PA_10,38400);
00024 
00025 DigitalOut led(LED1);
00026 
00027 //BufferedSerial pc(USBTX,USBRX);
00028 //char str[15];
00029 //int i=0;
00030 
00031 
00032 int main(){
00033     //f303.baud(9600);
00034     //pc.baud(9600);
00035     printf("start\r\n");
00036     led=0;
00037     char temp;
00038     while(1){
00039         if(L432.readable()) { //f303からのデータがある場合
00040             printf("readable\r\n");
00041             //led=!led;
00042             led=!led;
00043             temp = L432.getc();//一文字読み込む
00044             //im920.printf("TXDA %c\r\n",temp);
00045             wait(1);
00046             //str[i++] = temp;
00047         }
00048     }
00049 }