UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
demo_camera.c
1 /* firmware.h contains all relevant headers */
2 #include "../firmware.h"
3 
4 #include <stdio.h>
5 
6 uint32_t image_length;
7 void image_length_add(uint8_t *data, uint32_t data_length);
8 
9 int main(void)
10 {
11  char output[200];
12 
13  Board_init();
14  RTC_init();
15 
16  UART_init(UART_GNSS, 115200);
17  UART_puts(UART_GNSS, "Camera Demo\r\n");
18 
19  UART_init(UART_CAMERA, 115200);
20 
21  while(1)
22  {
23  LED_on(LED_B);
24  UART_puts(UART_GNSS, "Capturing..\r\n");
25  image_length = 0;
26 
27  if(Camera_capture(5000, image_length_add))
28  {
29  sprintf(output, "SUCCESS (%"PRIu32" Bytes)\r\n", image_length);
30  UART_puts(UART_GNSS, output);
31  }
32  else
33  {
34  sprintf(output, "FAIL (%"PRIu32" Bytes)\r\n", image_length);
35  UART_puts(UART_GNSS, output);
36  }
37 
38  LED_off(LED_B);
39 
40  /* On period */
41  Delay_ms(1000);
42  }
43 }
44 
45 void image_length_add(uint8_t *data, uint32_t data_length)
46 {
47  char output[60];
48  (void) data;
49 
50  image_length += data_length;
51 
52  sprintf(output, "0x%02"PRIx8", 0x%02"PRIx8" ..(%"PRIu32"B).. 0x%02"PRIx8", 0x%02"PRIx8"\r\n",
53  data[0], data[1],
54  data_length,
55  data[data_length-2], data[data_length-1]
56  );
57  UART_puts(UART_GNSS, output);
58 }
void Delay_ms(uint32_t milliseconds)
Definition: delay.c:19
bool Camera_capture(uint32_t page_size, void(*page_store)(uint8_t *, uint32_t))
Definition: camera.c:107
void UART_init(uint8_t uart_num, uint32_t baudrate)
Definition: uart.c:78
void LED_off(uint8_t led_num)
Definition: led.c:20
int main(void)
Runs all module tests.
Definition: test.c:19
void UART_puts(uint8_t uart_num, char *str)
Definition: uart.c:129
void Board_init(void)
Definition: board.c:13
void LED_on(uint8_t led_num)
Definition: led.c:15
void RTC_init(void)
Definition: rtc.c:15