Skip to content

Commit f19efb6

Browse files
committed
AnalogIn for nRF51 Fixes
multiinstances was not suported for nrf51 made nrf_saadc SDK hal private for nRF52
1 parent 44bef41 commit f19efb6

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF51822/analogin_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void analogin_init(analogin_t *obj, PinName pin)
5353
ret_code_t ret_code;
5454
// p_config, event_handler
5555
ret_code = nrf_drv_adc_init(NULL , NULL); // select blocking mode
56-
MBED_ASSERT(ret_code == NRF_SUCCESS);
56+
MBED_ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_INVALID_STATE)); //NRF_ERROR_INVALID_STATE expected for multiple channels used.
5757
}
5858

5959
uint16_t analogin_read_u16(analogin_t *obj)

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/sdk/drivers_nrf/hal/nrf_saadc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*
1111
*/
1212

13+
#ifdef NRF52
1314
/**
1415
* @file
1516
* @brief SAADC HAL implementation
@@ -29,3 +30,6 @@ void nrf_saadc_channel_init(uint8_t channel, nrf_saadc_channel_config_t const *
2930
nrf_saadc_channel_input_set(channel, config->pin_p, config->pin_n);
3031
return;
3132
}
33+
34+
#endif //NRF52
35+

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/sdk/drivers_nrf/hal/nrf_saadc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#ifndef NRF_SAADC_H_
1515
#define NRF_SAADC_H_
1616

17+
#ifdef NRF52
18+
1719
/**
1820
* @defgroup nrf_saadc_hal SAADC HAL
1921
* @{
@@ -27,6 +29,8 @@
2729
#include "nrf.h"
2830
#include "nrf_assert.h"
2931

32+
33+
3034
#define NRF_SAADC_CHANNEL_COUNT 8
3135

3236
/**
@@ -550,5 +554,7 @@ void nrf_saadc_channel_init(uint8_t channel, nrf_saadc_channel_config_t const *
550554
/**
551555
*@}
552556
**/
557+
558+
#endif // NRF52
553559

554560
#endif /* NRF_SAADC_H_ */

0 commit comments

Comments
 (0)