From 19adb8d3a45014efcc6b0955d606053795ddb54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Mon, 8 May 2017 02:31:38 +0200 Subject: [PATCH] Add USB command to retrieve ADC value. --- right/src/usb_protocol_handler.c | 10 ++++++++++ right/src/usb_protocol_handler.h | 1 + 2 files changed, 11 insertions(+) diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index dae4ae7..47c0aca 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -10,6 +10,7 @@ #include "slave_scheduler.h" #include "slave_drivers/slave_driver_uhk_module.h" #include "wormhole.h" +#include "peripherals/adc.h" void setError(uint8_t error); void setGenericError(); @@ -25,6 +26,7 @@ void readMergeSensor(); void uploadConfig(); void applyConfig(); void setLedPwm(); +void getAdcValue(void); // Functions for setting error statuses @@ -80,6 +82,9 @@ void usbProtocolHandler() case USB_COMMAND_SET_LED_PWM: setLedPwm(); break; + case USB_COMMAND_GET_ADC_VALUE: + setLedPwm(); + break; default: break; } @@ -198,3 +203,8 @@ void setLedPwm() UhkModuleStates[0].ledPwmBrightness = brightnessPercent; #endif } + +void getAdcValue(void) +{ + *((uint32_t*)GenericHidOutBuffer) = ADC_Measure(); +} diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index 83b432d..364611b 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -28,6 +28,7 @@ #define UPLOAD_CONFIG_INVALID_PAYLOAD_SIZE 1 #define USB_COMMAND_APPLY_CONFIG 9 #define USB_COMMAND_SET_LED_PWM 10 + #define USB_COMMAND_GET_ADC_VALUE 11 // Functions: