UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
demo_imu-csv.c
1 /* firmware.h contains all relevant headers */
2 #include "../firmware.h"
3 
4 #include <stdio.h>
5 
6 #define UART_INTERFACE UART_CAMERA
7 
8 int main(void)
9 {
10  int16_t x, y, z;
11  char output[200];
12 
13  Board_init();
14  setupwatchdoginterrupt();
15 
16  LED_on(LED_B);
17 
18  UART_init(UART_INTERFACE, 9600);
19 
20  IMU_Init();
21 
22  if(IMU_selftest() == false)
23  {
24  UART_puts(UART_INTERFACE, "\r\nSelftest: FAIL\r\n");
25  LED_off(LED_B);
26  while(1) {};
27  }
28 
29  while(1)
30  {
31  LED_on(LED_B);
32 
33  IMU_read_accel(&x, &y, &z);
34  sprintf(output,"%+06d,%+06d,%+06d", x, y, z);
35 
36  IMU_read_gyro(&x, &y, &z);
37  sprintf(output,"%s,%+06d,%+06d,%+06d", output, x, y, z);
38 
39  IMU_read_magno(&x, &y, &z);
40  sprintf(output,"%s,%+06d,%+06d,%+06d", output, x, y, z);
41 
42  IMU_read_temp(&x);
43  sprintf(output,"%s,%+06d\r\n", output, x);
44  LED_off(LED_B);
45 
46  UART_puts(UART_INTERFACE, output);
47 
48  Delay_ms(100);
49  }
50 }
void Delay_ms(uint32_t milliseconds)
Definition: delay.c:19
void UART_init(uint8_t uart_num, uint32_t baudrate)
Definition: uart.c:78
void IMU_read_temp(int16_t *temp_imu)
Definition: imu.c:197
void IMU_Init(void)
Definition: imu.c:43
void LED_off(uint8_t led_num)
Definition: led.c:20
int main(void)
Runs all module tests.
Definition: test.c:19
bool IMU_selftest(void)
Definition: imu.c:164
void IMU_read_magno(int16_t *magno_x, int16_t *magno_y, int16_t *magno_z)
Definition: imu.c:187
void UART_puts(uint8_t uart_num, char *str)
Definition: uart.c:129
void Board_init(void)
Definition: board.c:13
void IMU_read_gyro(int16_t *gyro_x, int16_t *gyro_y, int16_t *gyro_z)
Definition: imu.c:178
void IMU_read_accel(int16_t *accel_x, int16_t *accel_y, int16_t *accel_z)
Definition: imu.c:171
void LED_on(uint8_t led_num)
Definition: led.c:15