Added ADC thread that waits for msgq channel bitmask

This commit is contained in:
Your Name
2026-09-24 14:14:18 +03:00
parent dd7e6d9456
commit 4066cd3fbe
6 changed files with 102 additions and 9 deletions
+20 -4
View File
@@ -65,29 +65,45 @@ int command_handler(struct command_message_t *msg) {
break;
}
case ADC_READ: {
case ADC_READ_RAW: {
int channel = msg->data[0];
int value = adc_read_id(channel);
struct command_message_t *reply = usb_get_next_tx_buf();
command_create_message(reply, sizeof(value), ADC_READ, (uint8_t *)&value);
command_create_message(reply, sizeof(value), msg->command, (uint8_t *)&value);
usb_send_command(reply);
break;
}
case ADC_READ_ALL: {
case ADC_READ_RAW_ALL: {
int values[NUM_ADC_CHANNELS];
for (int i = 0; i < NUM_ADC_CHANNELS; i++) {
values[i] = adc_read_id(i);
}
struct command_message_t *reply = usb_get_next_tx_buf();
command_create_message(reply, sizeof(values), ADC_READ_ALL, (uint8_t *)values);
command_create_message(reply, sizeof(values), msg->command, (uint8_t *)values);
usb_send_command(reply);
break;
}
case ADC_READ: {
uint32_t mask;
memcpy(&mask, &msg->data[0], sizeof(uint32_t));
adc_add_mask(mask);
break;
}
case ADC_READ_ALL: {
uint32_t mask = 0b1111111111111111;
adc_add_mask(mask);
break;
}
default: {
LOG_WRN("Unknown command received: %d", msg->command);
return -EINVAL;