UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
demo_imu.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[100];
12 
13  Board_init();
14 
15  LED_on(LED_B);
16 
17  UART_init(UART_INTERFACE, 9600);
18  UART_puts(UART_INTERFACE, "\r\nIMU Demo\r\n");
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  UART_puts(UART_INTERFACE, "\r\nSelftest: OK\r\n");
29 
30  while(1)
31  {
32  LED_on(LED_B);
33 
34  IMU_read_accel(&x, &y, &z);
35  sprintf(output,"Accel: X %+06d, Y %+06d, Z %+06d\r\n", x, y, z);
36  UART_puts(UART_INTERFACE, output);
37 
38  IMU_read_gyro(&x, &y, &z);
39  sprintf(output,"Gyro: X %+06d, Y %+06d, Z %+06d\r\n", x, y, z);
40  UART_puts(UART_INTERFACE, output);
41 
42  IMU_read_magno(&x, &y, &z);
43  sprintf(output,"Magno: X %+06d, Y %+06d, Z %+06d\r\n", x, y, z);
44  UART_puts(UART_INTERFACE, output);
45 
46  IMU_read_temp(&x);
47  sprintf(output,"Temp: %+06d\r\n", x);
48  UART_puts(UART_INTERFACE, output);
49 
50  UART_puts(UART_INTERFACE, "--------------------------------\r\n");
51 
52  LED_off(LED_B);
53 
54  Delay_ms(200);
55  }
56 }
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