stm32g0xx/Core/main.cc

30 lines
723 B
C++
Raw Permalink Normal View History

2021-01-08 10:58:59 +00:00
#include <cstring>
#include <cstdint>
#include <cstdio>
2021-01-08 10:58:59 +00:00
#include "delay.h"
2020-12-17 09:39:45 +00:00
#include "platform/stm32g0xx/Gpio.h"
2021-01-08 09:21:58 +00:00
#include "platform/stm32g0xx/Uart.h"
2021-01-08 09:50:38 +00:00
2020-12-17 09:51:20 +00:00
using namespace perinet::platform::stm32g0xx;
2021-05-28 09:06:00 +00:00
Uart uart1(Uart::UartDevice::UART_1, 115200);
Uart uart2(Uart::UartDevice::UART_2, 115200);
2021-01-08 09:21:58 +00:00
int main(void)
{
2021-06-09 11:34:48 +00:00
char tx_buf[] = "\r\rProgram: UART bridge\r\n\n Receive on uart2 and transmit it on uart 1\r\n";
uint8_t rec;
uart1.sync_send((const uint8_t *)tx_buf, strlen(tx_buf));
2021-01-08 09:50:38 +00:00
2021-06-09 11:34:48 +00:00
while(true) {
if(uart2.sync_receive(&rec)) {
uart1.sync_send(&rec, 1);
}
2021-06-09 11:34:48 +00:00
if(uart1.sync_receive(&rec)) {
uart2.sync_send(&rec, 1);
}
}
}