Skip to content

Commit

Permalink
support for reading ADC calibration values
Browse files Browse the repository at this point in the history
  • Loading branch information
MightyPork committed Apr 1, 2018
1 parent de75f2d commit a66c453
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions units/adc/unit_adc.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion version.h
Expand Up @@ -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

0 comments on commit a66c453

Please sign in to comment.