Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nRF51822
Diff: hw.cpp
- Revision:
- 10:b3553e75eee0
- Parent:
- 9:0b017e956142
--- a/hw.cpp Tue May 30 19:01:17 2017 +0000
+++ b/hw.cpp Tue May 30 21:12:04 2017 +0000
@@ -78,9 +78,9 @@
/// @param chan is the channel to read
/// @param times is the number of readings to take
/// @return avg of all the readings
-uint16_t adc_read(int chan, int num_readings)
+int adc_read(int chan, int num_readings)
{
- uint16_t result = 0;
+ int result = 0;
int times = num_readings;
NRF_ADC->INTENCLR = ADC_INTENCLR_END_Clear; // turn off ADC interrupts
@@ -123,12 +123,12 @@
}
//NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Disabled;
- return (uint16_t)result/num_readings; // 10 bit
+ return (int)result/num_readings; // 10 bit
}
/// Reads the battery voltage
/// Returns the voltage as an int * 100. 3V = 300
-uint16_t read_battery_voltage(void)
+int read_battery_voltage(void)
{
return ((float)adc_read(ADC_CHAN_BATTERY,4)*3.6)/1023.0*100.0;
}