Skip to content

Commit e1c191a

Browse files
committed
Update polysat.c
1 parent b3d90fd commit e1c191a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

firmware/chipignite/polysat/src/polysat.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "../include/uart.h"
66
#include "../include/gpio.h"
77

8+
#define ARRAY_SIZE 100
9+
810
// --------------------------------------------------------
911
// Firmware routines
1012
// --------------------------------------------------------
@@ -149,8 +151,11 @@ void main() {
149151
reg_mprj_datah = 0x00000000; // Set all high pins (32-37) low
150152
reg_mprj_datal = 0x00000000; // Set all low pins (0-31) low
151153

154+
// Define a static array of items initialized to zero
155+
static uint8_t zero_array[ARRAY_SIZE] = {0};
156+
152157
// Main loop - echo received characters and blink LED and
153-
while (1) {
158+
while (true) {
154159
if (!pulse) {
155160
led_off();
156161
// Set GPIO 33 low (bit 1)
@@ -161,8 +166,21 @@ void main() {
161166
gpio_set(33, true);
162167
}
163168
pulse = !pulse;
164-
const char message_to_send[] = "Hello, World!";
165-
slip_send_packet(message_to_send, sizeof(message_to_send) - 1, SLIP_CMD_DATA, uart_write);
169+
170+
// For every non-zero element in the array, set back to zero and send a packet to the host
171+
for (uint32_t i = 0; i < ARRAY_SIZE; i++) {
172+
if (zero_array[i] != 0) {
173+
// When a non-zero element is found (due to radiation), send a packet to the host
174+
struct {
175+
uint8_t* base_address; // base address of the array
176+
uint8_t index; // index of the non-zero element
177+
uint8_t value; // value of the non-zero element
178+
} carp_data = {zero_array, i, zero_array[i]};
179+
180+
slip_send_packet((uint8_t*)&carp_data, sizeof(carp_data), SLIP_CMD_DATA, uart_write);
181+
zero_array[i] = 0;
182+
}
183+
}
166184

167185
// Wait for 1 second
168186
delay(10000000);

0 commit comments

Comments
 (0)