Skip to content

Commit

Permalink
Additional ADC options
Browse files Browse the repository at this point in the history
  • Loading branch information
microbuilder committed Feb 27, 2017
1 parent 5217449 commit 1399cdf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cores/nRF5/wiring_analog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ extern "C" {
typedef enum _eAnalogReference
{
AR_DEFAULT,
AR_INTERNAL,
AR_VDD4
AR_INTERNAL, // 0.6V Ref * 6 = 0..3.6V
AR_INTERNAL_3_0, // 0.6V Ref * 5 = 0..3.0V
AR_INTERNAL_2_4, // 0.6V Ref * 4 = 0..2.4V
AR_INTERNAL_1_8, // 0.6V Ref * 3 = 0..1.8V
AR_INTERNAL_1_2, // 0.6V Ref * 2 = 0..1.6V
AR_VDD4 // VDD/4 REF * 4 = 0..VDD
} eAnalogReference ;
#else
typedef enum _eAnalogReference
Expand Down
24 changes: 20 additions & 4 deletions cores/nRF5/wiring_analog_nRF52.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,33 @@ static inline uint32_t mapResolution( uint32_t value, uint32_t from, uint32_t to
void analogReference( eAnalogReference ulMode )
{
switch ( ulMode ) {
case AR_VDD4:
saadcReference = SAADC_CH_CONFIG_REFSEL_VDD1_4;
saadcGain = SAADC_CH_CONFIG_GAIN_Gain4;
break;
case AR_INTERNAL_3_0:
saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_5;
break;
case AR_INTERNAL_2_4:
saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_4;
break;
case AR_INTERNAL_1_8:
saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_3;
break;
case AR_INTERNAL_1_2:
saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_2;
break;
case AR_DEFAULT:
case AR_INTERNAL:
default:
saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;
saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_6;
break;

case AR_VDD4:
saadcReference = SAADC_CH_CONFIG_REFSEL_VDD1_4;
saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_4;
break;
}
}

Expand Down

0 comments on commit 1399cdf

Please sign in to comment.