Added ADC thread that waits for msgq channel bitmask
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user