Skip to content

Commit

Permalink
Merge branch 'adc_default' into hyperfirmata
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosperate committed Apr 24, 2017
2 parents acd6b31 + c6a6d04 commit 871447f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ For 64-bit Linux users, ```libc6:i386```, ```libstdc++6:i386```, ```libncurses5

__NOTE__: To roll back to the original driver go to: Device Manager -> Right click on device -> Check box for "Delete the driver software for this device" and click Uninstall

### Selecting a SoftDevice
SoftDevices contain the BLE stack and housekeeping, and must be downloaded once before a sketch using BLE can be loaded.
The SD consumes ~5k of Ram + some extra based on actual BLE configuration.
* SoftDevice S110 v8.0.0 supports [Revision](http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf51%2Fdita%2Fnrf51%2Fcompatibility_matrix%2FnRF51822_ic_revision_overview.html&cp=3_0_1) 2 and 3 of nRF51 in peripheral role. It is 96k in size.
* SoftDevice S130 v2.0.1 supports Revision 3 of nRF51 in peripheral and central role. It is 108k in size.
* SoftDevice S132 v2.0.1 supports nRF52 in peripheral and central role. It is 112k in size.

### Flashing a SoftDevice

Expand Down Expand Up @@ -117,7 +123,7 @@ This Arduino Core does **not** contain any Arduino style API's for BLE functiona

If the selected board has an external 32 kHz crystal connected, it will be used as the source for the low frequency clock. Otherwise the internal 32 kHz RC oscillator will be used. The low frequency clock is used by the `delay(ms)` and `millis()` Arduino API's.

The Generic nRF51 and nRF52 board options have an additional menu item under `Tools -> Low Frequency Clock` that allows you to select the low frequency clock source.
The Generic nRF51 and nRF52 board options have an additional menu item under `Tools -> Low Frequency Clock` that allows you to select the low frequency clock source. However, Nordic does not recommend the Synthesized clock, which also has a significant power impact.

## Credits

Expand Down
20 changes: 10 additions & 10 deletions cores/nRF5/wiring_analog_nRF51.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static struct PWMContext pwmContext[PWM_COUNT] = {

static int timerEnabled = 0;

static uint32_t adcReference = ADC_CONFIG_REFSEL_VBG;
static uint32_t adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling;
static uint32_t adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling;

static uint32_t readResolution = 10;
Expand Down Expand Up @@ -89,10 +89,8 @@ static inline uint32_t mapResolution( uint32_t value, uint32_t from, uint32_t to
*/
void analogReference( eAnalogReference ulMode )
{
switch ( ulMode ) {
case AR_DEFAULT:
switch ( ulMode ) {
case AR_VBG:
default:
// 1.2 Reference, 1/3 prescaler = 0 V - 3.6 V range
// Minimum VDD for full range in safe operation = 3.3V
adcReference = ADC_CONFIG_REFSEL_VBG;
Expand All @@ -105,12 +103,6 @@ void analogReference( eAnalogReference ulMode )
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputTwoThirdsPrescaling;
break;

case AR_SUPPLY_ONE_THIRD:
// 1/3 VDD Reference, 1/3 prescaler = 0 V - VDD range
adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling;
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling;
break;

case AR_EXT0:
// ARF0 reference, 2/3 prescaler = 0 V - 1.5 ARF0
adcReference = ADC_CONFIG_REFSEL_External | (ADC_CONFIG_EXTREFSEL_AnalogReference0 << ADC_CONFIG_EXTREFSEL_Pos);
Expand All @@ -122,6 +114,14 @@ void analogReference( eAnalogReference ulMode )
adcReference = (ADC_CONFIG_REFSEL_External | ADC_CONFIG_EXTREFSEL_AnalogReference1 << ADC_CONFIG_EXTREFSEL_Pos);
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputTwoThirdsPrescaling;
break;

case AR_SUPPLY_ONE_THIRD:
case AR_DEFAULT:
default:
// 1/3 VDD Reference, 1/3 prescaler = 0 V - VDD range
adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling;
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling;
break;
}
}

Expand Down

0 comments on commit 871447f

Please sign in to comment.