File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF52832 Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change 13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
+
16
17
#include "mbed_assert.h"
17
18
#include "analogin_api.h"
18
19
#include "cmsis.h"
@@ -57,27 +58,15 @@ void analogin_init(analogin_t *obj, PinName pin)
57
58
MBED_ASSERT (ret_code == NRF_SUCCESS );
58
59
}
59
60
60
- /**
61
- * NRF52 SAR ADC module provides measurement with sign.
62
- * Already mbed API dosn't support readout of signed integer value.
63
- */
64
- static int16_t analogin_read_i16 (analogin_t * obj )
61
+
62
+ uint16_t analogin_read_u16 (analogin_t * obj )
65
63
{
66
- nrf_saadc_value_t adc_value ;
64
+ int16_t adc_value ;
67
65
ret_code_t ret_code ;
68
66
69
67
ret_code = nrf_drv_saadc_sample_convert (obj -> adc_pin , & adc_value );
70
68
MBED_ASSERT (ret_code == NRF_SUCCESS );
71
69
72
- return adc_value ;
73
- }
74
-
75
- uint16_t analogin_read_u16 (analogin_t * obj )
76
- {
77
- int16_t adc_value ;
78
-
79
- adc_value = analogin_read_i16 (obj );
80
-
81
70
if (adc_value < 0 )
82
71
{
83
72
// Even in the single ended mode measured value can be {-0}. Saturation for avoid casting to a big integer.
@@ -91,7 +80,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
91
80
92
81
float analogin_read (analogin_t * obj )
93
82
{
94
- int16_t value = analogin_read_i16 (obj );
83
+ uint16_t value = analogin_read_u16 (obj );
95
84
return (float )value * (1.0f / (float )ADC_RANGE );
96
85
}
97
86
You can’t perform that action at this time.
0 commit comments