From a66c4538209a93fcc0d4ae0cc94aae51741fb657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 1 Apr 2018 20:20:59 +0200 Subject: [PATCH] support for reading ADC calibration values --- units/adc/unit_adc.c | 17 +++++++++++++++++ version.h | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/units/adc/unit_adc.c b/units/adc/unit_adc.c index fb6c68e..a7d6d0b 100644 --- a/units/adc/unit_adc.c +++ b/units/adc/unit_adc.c @@ -13,6 +13,7 @@ enum AdcCmd_ { CMD_READ_RAW = 0, CMD_READ_SMOOTHED = 1, + CMD_READ_CAL_CONSTANTS = 2, CMD_GET_ENABLED_CHANNELS = 10, CMD_GET_SAMPLE_RATE = 11, @@ -101,6 +102,22 @@ static error_t UADC_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, P } return E_SUCCESS; + /** Read ADC calibration constants */ + case CMD_READ_CAL_CONSTANTS: + { + pb_u16(&pb, *VREFINT_CAL_ADDR); // VREFINT_CAL + pb_u16(&pb, VREFINT_CAL_VREF); // Vref pin voltage during calibration (usually bonded to Vdd) + + pb_u16(&pb, *TEMPSENSOR_CAL1_ADDR); // TEMPSENSOR_CAL1 + pb_u16(&pb, *TEMPSENSOR_CAL2_ADDR); // TEMPSENSOR_CAL2 + pb_u8(&pb, TEMPSENSOR_CAL1_TEMP); // temperature for CAL1 + pb_u8(&pb, TEMPSENSOR_CAL2_TEMP); // temperature for CAL2 + pb_u16(&pb, TEMPSENSOR_CAL_VREFANALOG); // VREFINT_CAL_VREF - Vref pin voltage during calibration (usually bonded to Vdd) + + com_respond_pb(frame_id, MSG_SUCCESS, &pb); + } + return E_SUCCESS; + /** * Enable channels. The channels must've been configured in the settings (except ch 16 and 17 which are available always) * pld: u32: bitmap of channels diff --git a/version.h b/version.h index 4fff841..cd89d47 100644 --- a/version.h +++ b/version.h @@ -7,6 +7,6 @@ #ifndef GEX_VERSION_H #define GEX_VERSION_H -#define GEX_VERSION "0.1.0" +#define GEX_VERSION "0.2.0" #endif //GEX_VERSION_H