rt-thread-official/bsp/nrf5x/libraries/drivers/drv_adc.h

49 lines
1.2 KiB
C
Raw Normal View History

2020-08-18 22:11:50 +08:00
/*
2021-03-14 15:18:33 +08:00
* Copyright (c) 2006-2021, RT-Thread Development Team
2020-08-18 22:11:50 +08:00
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-18 guohp1128 the first version
*/
2021-03-14 15:18:33 +08:00
2020-08-18 22:11:50 +08:00
#ifndef __DRV_ADC_H__
#define __DRV_ADC_H__
#include <board.h>
#include "rtdevice.h"
#include <hal/nrf_saadc.h>
#include <drivers/include/nrfx_saadc.h>
#define ADC_NAME "adc"
2021-03-14 15:18:33 +08:00
/*
2020-08-18 22:11:50 +08:00
previous definition in application
2021-03-14 15:18:33 +08:00
2020-08-18 22:11:50 +08:00
set single-ended mode or differential mode.
selection ADC input pin, and config the number of Channel.
2021-03-14 15:18:33 +08:00
2020-08-18 22:11:50 +08:00
mode: 0 single-ended mode,1 differential mode
pin_p: 0-7
pin_n: 0-7,if single-ended mode, pin_n invalid
channel_num: 0-7
*/
typedef struct
{
nrf_saadc_mode_t mode; ///< SAADC mode. Single-ended or differential.
uint8_t pin_p; ///< Input positive pin selection.
uint8_t pin_n; ///< Input negative pin selection.
uint8_t channel_num; ///< Channel number.
} drv_nrfx_saadc_channel_t;
typedef struct
{
nrfx_saadc_channel_t channels[8];
2021-03-14 15:18:33 +08:00
uint8_t channel_count;
nrf_saadc_value_t result_buffer[8];
uint8_t done;
2020-08-18 22:11:50 +08:00
} drv_nrfx_saadc_result_t;
#endif /* __DRV_ADC_H__ */