UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
uart_passthrough.c
1 
2 // UART passthrough with debug code
3 //
4 // Suzanna Lucarotti (c) 13/9/2017
5 //
6 // for use with the UoS3 Cubesat
7 //
8 // should effectively remove module, allowing testing of interfaces through board, with codes coming back converted into hex for clarity
9 
10 
11 #include "../firmware.h"
12 
13 #include "inc/hw_memmap.h"
14 #include "inc/hw_types.h"
15 
16 #include "driverlib/gpio.h"
17 #include "driverlib/pin_map.h"
18 #include "driverlib/sysctl.h"
19 
20 #include <stdlib.h>
21 #include <stdarg.h>
22 
23 #define GPS_SERIAL UART_GNSS
24 #define CAM_SERIAL UART_CAMERA
25 
27  // the actual main code
29 
30 int main(void)
31 {
32  Board_init(); // start the board
33  // WDT_kick(); // kick the watchdog
34  setupwatchdoginterrupt();
35 // UART at 115200, unreliable at 9600
36 
37  UART_init(CAM_SERIAL, 115200); UART_puts(CAM_SERIAL,"UART_passthrough");
38  UART_init(GPS_SERIAL, 9600); // UART_puts(GPS_SERIAL,"UART_passthrough");
39 
40  while(1) // infinite loop
41  {
42  char c; // echo back to sending port
43  if (UART_getc_nonblocking(GPS_SERIAL,&c)) {UART_putc_nonblocking(CAM_SERIAL,c); } // input
44  if (UART_getc_nonblocking(CAM_SERIAL,&c)) {UART_putc_nonblocking(GPS_SERIAL,c); } //output
45  }
46 }
47 
48 
void UART_init(uint8_t uart_num, uint32_t baudrate)
Definition: uart.c:78
bool UART_getc_nonblocking(uint8_t uart_num, char *c)
Definition: uart.c:145
int main(void)
Runs all module tests.
Definition: test.c:19
bool UART_putc_nonblocking(uint8_t uart_num, char c)
Definition: uart.c:163
void UART_puts(uint8_t uart_num, char *str)
Definition: uart.c:129
void Board_init(void)
Definition: board.c:13