commit
72cd063282
|
@ -12,6 +12,8 @@
|
|||
|
||||
#ifdef RT_USING_ADC
|
||||
|
||||
#define ADC_NAME "adc"
|
||||
|
||||
struct rt_adc_device nrf5x_adc_device;
|
||||
|
||||
drv_nrfx_saadc_result_t results;
|
||||
|
@ -183,7 +185,7 @@ int rt_hw_adc_init(void)
|
|||
{
|
||||
int result = RT_EOK;
|
||||
uint8_t i;
|
||||
char name_buf[6] = {'S', 'A', 'A', 'D', 'C', 0};
|
||||
char name_buf[6] = ADC_NAME;
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
|
@ -221,22 +223,43 @@ INIT_BOARD_EXPORT(rt_hw_adc_init);
|
|||
/*test saadc*/
|
||||
#include <drv_adc.h>
|
||||
|
||||
#define SAMPLE_ADC_MODE_SINGLE_ENDED 0 //single-ended mode
|
||||
#define SAMPLE_ADC_MODE_DIFFERENTIAL 1 //differential mode
|
||||
|
||||
#define SAMPLE_ADC_AIN1 1
|
||||
#define SAMPLE_ADC_AIN2 2
|
||||
#define SAMPLE_ADC_AIN7 7
|
||||
#define SAMPLE_ADC_AIN_NC 0 //disable input of AINx
|
||||
|
||||
#define SAMPLE_ADC_CHANNEL_0 0
|
||||
#define SAMPLE_ADC_CHANNEL_1 1
|
||||
#define SAMPLE_ADC_CHANNEL_5 5
|
||||
|
||||
void saadc_sample(void)
|
||||
{
|
||||
drv_nrfx_saadc_channel_t channel_config;
|
||||
rt_uint32_t result;
|
||||
|
||||
rt_adc_device_t adc_dev;
|
||||
adc_dev = (rt_adc_device_t)rt_device_find("SAADC");
|
||||
adc_dev = (rt_adc_device_t)rt_device_find(ADC_NAME);
|
||||
adc_dev->parent.user_data = &channel_config;
|
||||
|
||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = 0, .pin_p = 1, .pin_n = 1, .channel_num = 0};
|
||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
||||
.pin_p = SAMPLE_ADC_AIN1,
|
||||
.pin_n = SAMPLE_ADC_AIN_NC,
|
||||
.channel_num = SAMPLE_ADC_CHANNEL_0};
|
||||
rt_adc_enable(adc_dev, channel_config.channel_num);
|
||||
|
||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = 0, .pin_p = 2, .pin_n = 1, .channel_num = 1};
|
||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
||||
.pin_p = SAMPLE_ADC_AIN2,
|
||||
.pin_n = SAMPLE_ADC_AIN_NC,
|
||||
.channel_num = SAMPLE_ADC_CHANNEL_1};
|
||||
rt_adc_enable(adc_dev, channel_config.channel_num);
|
||||
|
||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = 0, .pin_p = 7, .pin_n = 1, .channel_num = 5};
|
||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
||||
.pin_p = SAMPLE_ADC_AIN7,
|
||||
.pin_n = SAMPLE_ADC_AIN_NC,
|
||||
.channel_num = SAMPLE_ADC_CHANNEL_5};
|
||||
rt_adc_enable(adc_dev, channel_config.channel_num);
|
||||
|
||||
int count = 1;
|
||||
|
|
|
@ -65,7 +65,7 @@ CONFIG_RT_USING_DEVICE=y
|
|||
# CONFIG_RT_USING_INTERRUPT_INFO is not set
|
||||
CONFIG_RT_USING_CONSOLE=y
|
||||
CONFIG_RT_CONSOLEBUF_SIZE=128
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
|
||||
CONFIG_RT_VER_NUM=0x40003
|
||||
# CONFIG_RT_USING_CPU_FFS is not set
|
||||
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
|
||||
|
@ -196,12 +196,15 @@ CONFIG_RT_USING_LIBC=y
|
|||
#
|
||||
# IoT - internet of things
|
||||
#
|
||||
# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
|
||||
# CONFIG_PKG_USING_PAHOMQTT is not set
|
||||
# CONFIG_PKG_USING_UMQTT is not set
|
||||
# CONFIG_PKG_USING_WEBCLIENT is not set
|
||||
# CONFIG_PKG_USING_WEBNET is not set
|
||||
# CONFIG_PKG_USING_MONGOOSE is not set
|
||||
# CONFIG_PKG_USING_MYMQTT is not set
|
||||
# CONFIG_PKG_USING_KAWAII_MQTT is not set
|
||||
# CONFIG_PKG_USING_BC28_MQTT is not set
|
||||
# CONFIG_PKG_USING_WEBTERMINAL is not set
|
||||
# CONFIG_PKG_USING_CJSON is not set
|
||||
# CONFIG_PKG_USING_JSMN is not set
|
||||
|
@ -228,6 +231,7 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_COAP is not set
|
||||
# CONFIG_PKG_USING_NOPOLL is not set
|
||||
# CONFIG_PKG_USING_NETUTILS is not set
|
||||
# CONFIG_PKG_USING_CMUX is not set
|
||||
# CONFIG_PKG_USING_PPP_DEVICE is not set
|
||||
# CONFIG_PKG_USING_AT_DEVICE is not set
|
||||
# CONFIG_PKG_USING_ATSRV_SOCKET is not set
|
||||
|
@ -240,7 +244,7 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
|
||||
# CONFIG_PKG_USING_ALI_IOTKIT is not set
|
||||
# CONFIG_PKG_USING_AZURE is not set
|
||||
# CONFIG_PKG_USING_TENCENT_IOTHUB is not set
|
||||
# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set
|
||||
# CONFIG_PKG_USING_JIOT-C-SDK is not set
|
||||
# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
|
||||
# CONFIG_PKG_USING_JOYLINK is not set
|
||||
|
@ -262,6 +266,11 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_CAPNP is not set
|
||||
# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set
|
||||
# CONFIG_PKG_USING_AGILE_TELNET is not set
|
||||
# CONFIG_PKG_USING_NMEALIB is not set
|
||||
# CONFIG_PKG_USING_AGILE_JSMN is not set
|
||||
# CONFIG_PKG_USING_PDULIB is not set
|
||||
# CONFIG_PKG_USING_BTSTACK is not set
|
||||
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
|
||||
|
||||
#
|
||||
# security packages
|
||||
|
@ -270,6 +279,7 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_libsodium is not set
|
||||
# CONFIG_PKG_USING_TINYCRYPT is not set
|
||||
# CONFIG_PKG_USING_TFM is not set
|
||||
# CONFIG_PKG_USING_YD_CRYPTO is not set
|
||||
|
||||
#
|
||||
# language packages
|
||||
|
@ -286,6 +296,7 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_STEMWIN is not set
|
||||
# CONFIG_PKG_USING_WAVPLAYER is not set
|
||||
# CONFIG_PKG_USING_TJPGD is not set
|
||||
# CONFIG_PKG_USING_HELIX is not set
|
||||
|
||||
#
|
||||
# tools packages
|
||||
|
@ -304,6 +315,9 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
|
||||
# CONFIG_PKG_USING_LUNAR_CALENDAR is not set
|
||||
# CONFIG_PKG_USING_BS8116A is not set
|
||||
# CONFIG_PKG_USING_GPS_RMC is not set
|
||||
# CONFIG_PKG_USING_URLENCODE is not set
|
||||
# CONFIG_PKG_USING_UMCN is not set
|
||||
|
||||
#
|
||||
# system packages
|
||||
|
@ -314,6 +328,7 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_LWEXT4 is not set
|
||||
# CONFIG_PKG_USING_PARTITION is not set
|
||||
# CONFIG_PKG_USING_FAL is not set
|
||||
# CONFIG_PKG_USING_FLASHDB is not set
|
||||
# CONFIG_PKG_USING_SQLITE is not set
|
||||
# CONFIG_PKG_USING_RTI is not set
|
||||
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
|
||||
|
@ -326,6 +341,14 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_SYSWATCH is not set
|
||||
# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
|
||||
# CONFIG_PKG_USING_PLCCORE is not set
|
||||
# CONFIG_PKG_USING_RAMDISK is not set
|
||||
# CONFIG_PKG_USING_MININI is not set
|
||||
# CONFIG_PKG_USING_QBOOT is not set
|
||||
# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
|
||||
# CONFIG_PKG_USING_UC_CRC is not set
|
||||
# CONFIG_PKG_USING_UC_CLK is not set
|
||||
# CONFIG_PKG_USING_UC_COMMON is not set
|
||||
# CONFIG_PKG_USING_PPOOL is not set
|
||||
|
||||
#
|
||||
# peripheral libraries and drivers
|
||||
|
@ -367,6 +390,7 @@ CONFIG_PKG_NRFX_VER="v2.1.0"
|
|||
# CONFIG_PKG_USING_RPLIDAR is not set
|
||||
# CONFIG_PKG_USING_AS608 is not set
|
||||
# CONFIG_PKG_USING_RC522 is not set
|
||||
# CONFIG_PKG_USING_WS2812B is not set
|
||||
# CONFIG_PKG_USING_EMBARC_BSP is not set
|
||||
# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
|
||||
# CONFIG_PKG_USING_MULTI_RTIMER is not set
|
||||
|
@ -374,6 +398,15 @@ CONFIG_PKG_NRFX_VER="v2.1.0"
|
|||
# CONFIG_PKG_USING_BEEP is not set
|
||||
# CONFIG_PKG_USING_EASYBLINK is not set
|
||||
# CONFIG_PKG_USING_PMS_SERIES is not set
|
||||
# CONFIG_PKG_USING_CAN_YMODEM is not set
|
||||
# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set
|
||||
# CONFIG_PKG_USING_QLED is not set
|
||||
# CONFIG_PKG_USING_PAJ7620 is not set
|
||||
# CONFIG_PKG_USING_AGILE_CONSOLE is not set
|
||||
# CONFIG_PKG_USING_LD3320 is not set
|
||||
# CONFIG_PKG_USING_WK2124 is not set
|
||||
# CONFIG_PKG_USING_LY68L6400 is not set
|
||||
# CONFIG_PKG_USING_DM9051 is not set
|
||||
|
||||
#
|
||||
# miscellaneous packages
|
||||
|
@ -408,8 +441,14 @@ CONFIG_PKG_NRFX_VER="v2.1.0"
|
|||
# CONFIG_PKG_USING_ELAPACK is not set
|
||||
# CONFIG_PKG_USING_ARMv7M_DWT is not set
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
# CONFIG_PKG_USING_TETRIS is not set
|
||||
# CONFIG_PKG_USING_ULAPACK is not set
|
||||
# CONFIG_PKG_USING_UKAL is not set
|
||||
# CONFIG_PKG_USING_CRCLIB is not set
|
||||
# CONFIG_PKG_USING_THREES is not set
|
||||
# CONFIG_PKG_USING_2048 is not set
|
||||
# CONFIG_PKG_USING_LWGPS is not set
|
||||
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
|
||||
|
||||
#
|
||||
# Hardware Drivers Config
|
||||
|
@ -423,7 +462,7 @@ CONFIG_SOC_NORDIC=y
|
|||
#
|
||||
# Onboard Peripheral Drivers
|
||||
#
|
||||
# CONFIG_BSP_USING_JLINK_TO_USART is not set
|
||||
CONFIG_BSP_USING_JLINK_TO_USART=y
|
||||
# CONFIG_BSP_USING_QSPI_FLASH is not set
|
||||
|
||||
#
|
||||
|
|
|
@ -159,6 +159,7 @@
|
|||
|
||||
/* Onboard Peripheral Drivers */
|
||||
|
||||
#define BSP_USING_JLINK_TO_USART
|
||||
|
||||
/* On-chip Peripheral Drivers */
|
||||
|
||||
|
|
Loading…
Reference in New Issue