UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
test.c
Go to the documentation of this file.
1 
11 #include "firmware.h"
12 #include "test.h"
13 
19 int main(void)
20 {
21  bool test_state = true;
22  Debug_print("## UoS³ Module Tests ##\n");
23 
24  /* Call module tests */
25  assert_run(packet_tests(), test_state);
26  assert_run(buffer_tests(), test_state);
27  assert_run(util_tests(), test_state);
28 
29  if(test_state)
30  return 0;
31  else
32  return -1;
33 }
34 
35 void buffer_print_dec(uint8_t *buffer, uint32_t length)
36 {
37  uint32_t i = 0;
38  uint8_t row = 20;
39  while(i<length)
40  {
41  if(row == 0)
42  {
43  Debug_print("\r\n");
44  row = 20;
45  }
46  Debug_print("%4d", buffer[i]);
47  row--;
48  i++;
49  }
50  Debug_print("\r\n");
51 }
52 
53 void buffer_print_hex(uint8_t *buffer, uint32_t length)
54 {
55  uint32_t i = 0;
56  uint8_t row = 20;
57  while(i<length)
58  {
59  if(row == 0)
60  {
61  Debug_print("\r\n");
62  row = 20;
63  }
64  Debug_print(" %02x", buffer[i]);
65  row--;
66  i++;
67  }
68  Debug_print("\r\n");
69 }
70 
71 void buffer_print_bin(uint8_t *buffer, uint32_t length)
72 {
73  uint32_t i = 0, j, m;
74  uint8_t row = 4;
75  while(i<length)
76  {
77  if(row == 0)
78  {
79  Debug_print("\r\n");
80  row = 4;
81  }
82  j=7;
83  m=0x80;
84  while(m!=0)
85  {
86  Debug_print(" %01d", (buffer[i] & m) >> j);
87  m >>= 1;
88  j--;
89  }
90  row--;
91  i++;
92  }
93  Debug_print("\r\n");
94 }
95 
int main(void)
Runs all module tests.
Definition: test.c:19
void Debug_print(char *fmt,...)
Definition: debug.c:16
void buffer_print_bin(uint8_t *buffer, uint32_t length)
Definition: test.c:71
void buffer_print_dec(uint8_t *buffer, uint32_t length)
Definition: test.c:35
void buffer_print_hex(uint8_t *buffer, uint32_t length)
Definition: test.c:53