term.c
Go to the documentation of this file.
1 /*
2  i2sniff.c : sniff and report I^2C devices
3 
4  Copyright (C) 2016 Simon D. Levy
5 
6  Adapted from https://github.com/multiwii/baseflight/blob/master/src/drv_adc.c
7 
8  Don't forget to supply external power for external sensors (like MB1242 sonar)!
9 
10  This file is part of BreezySTM32.
11 
12  BreezySTM32 is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  BreezySTM32 is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #include <breezystm32.h>
27 
28 void receive_cb(uint16_t c)
29 {
30  printf('%c', (uint8_t)c);
31 }
32 
34 
35 extern void SetSysClock(bool overclock);
36 
37 static void _putc(void *p, char c)
38 {
39  (void)p; // avoid compiler warning about unused variable
40  serialWrite(Serial1, c);
41 
42  while (!isSerialTransmitBufferEmpty(Serial1));
43 }
44 
45 int main(void)
46 {
47  // Configure clock, this figures out HSE for hardware autodetect
48  SetSysClock(0);
49 
50  systemInit();
51 
52  Serial1 = uartOpen(USART1, &receive_cb, 115200, MODE_RXTX);
53 
55 
56  while (1);
57 }
58 
void systemInit(void)
Definition: system.c:55
void receive_cb(uint16_t c)
Definition: term.c:28
serialPort_t * Serial1
Definition: term.c:33
void SetSysClock(bool overclock)
#define USART1
Definition: stm32f4xx.h:2080
int main(void)
Definition: term.c:45
static void _putc(void *p, char c)
Definition: term.c:37
bool isSerialTransmitBufferEmpty(serialPort_t *instance)
Definition: drv_serial.c:60
void serialWrite(serialPort_t *instance, uint8_t ch)
Definition: drv_serial.c:40
serialPort_t * uartOpen(USART_TypeDef *USARTx, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode)
Definition: drv_uart.c:80
#define NULL
Definition: usbd_def.h:50
void init_printf(void *putp, void(*putf)(void *, char))
Definition: printf.cpp:264


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:49