Created
October 30, 2013 18:50
-
-
Save dagon666/7237955 to your computer and use it in GitHub Desktop.
sample collection function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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