Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
switch_uart.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) Freek van Tienen
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
27 #include "mcu_periph/uart.h"
28 
31 
32 static uint8_t drop_string[] = "<Drop_Paintball_Now";
33 #define DROP_STRINGLEN 19
34 
35 
37 {
38  while (uart_char_available(&SWITCH_UART_PORT)) {
39  uint8_t r = uart_getch(&SWITCH_UART_PORT);
41  }
42 }
43 
44 void drop_ball(uint8_t number)
45 {
46  for (uint8_t i = 0; i < DROP_STRINGLEN; i++) {
47  uart_put_byte(&SWITCH_UART_PORT, 0, drop_string[i]);
48  }
49 
50  // Drop next ball
51  uint8_t last = '>';
52 
53  // Or Drop a specific ball
54  if (number == 1) {
55  last = '1';
56  } else if (number == 2) {
57  last = '2';
58  } else if (number == 3) {
59  last = '3';
60  } else if (number == 4) {
61  last = '4';
62  }
63  uart_put_byte(&SWITCH_UART_PORT, 0, last);
64 
65 }
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void periodic_switch_uart(void)
Definition: switch_uart.c:36
uint8_t switch_uart_status
Definition: switch_uart.c:30
uint8_t uart_getch(struct uart_periph *p)
Definition: uart_arch.c:840
uint16_t uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Definition: uart_arch.c:324
void drop_ball(uint8_t number)
Definition: switch_uart.c:44
uint8_t switch_uart_channel
Definition: switch_uart.c:29
static uint8_t drop_string[]
Definition: switch_uart.c:32
void uart_put_byte(struct uart_periph *p, long fd, uint8_t data)
Uart transmit implementation.
Definition: uart_arch.c:967
uint32_t last
Definition: rng_arch.c:31
unsigned char uint8_t
Definition: types.h:14
#define DROP_STRINGLEN
Definition: switch_uart.c:33