Skip to content

Instantly share code, notes, and snippets.

@dagon666
Created October 30, 2013 18:50
Show Gist options
  • Save dagon666/7237955 to your computer and use it in GitHub Desktop.
Save dagon666/7237955 to your computer and use it in GitHub Desktop.
sample collection function
static void serial_collect_samples(void *a_data __attribute__((unused))) {
struct packet *data = (struct packet *)a_data;
uint8_t size = 0x00;
uint16_t buffs = (PWM_SAMPLES_BUFFER*PWM_BUFFERS);
uint16_t avail = (buffs + g_head - g_tail) % buffs;
if (avail > 192) {
serial_poll_send("WAIT", 4);
}
if (0 >= (size = slip_recv((void *)data,
sizeof(struct packet)))) {
return;
}
// ignore incomplete data chunks, packet should contain at least 1 sample
if (size < 4) {
return;
}
// verify if the information is genuine
if (!slip_verify_crc16((unsigned char *)data, size, 0)) {
return;
}
g_head += data->num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment