1912 views|5 replies

2865

Posts

4

Resources
The OP
 

Pingtouge RVB2601 board-ADC acquisition and CSI [Copy link]

 

According to limited information, CH2601 has an internal ADC, but the pins are connected through the "ARDUINO" interface.

The ADC driver of CH2601 is the CSI interface provided in the YOC development kit. CSI is for embedded systems and defines the unified software interface specifications of the CPU core porting interface and the peripheral device operation interface to eliminate the differences between different chips, simplify the use of software and improve the portability of software. Through the CSI interface specification, the chip can be quickly connected to the YoC platform. There are two types of CSI, CSI1 and CSI2. The function of CSI2 is higher than that of CSI1 in code density, and the abstraction of CSI2 is better.

The ADC of CH2601 can provide "support single conversion and continuous conversion". This test is a single acquisition test. The code is based on the routine of yoc.

The main steps of the procedure are as follows:

1. Enable the pin function csi_pin_set_mux(EXAMPLE_ADC_CHANNEL0_PIN, EXAMPLE_ADC_CHANNEL0_PIN_FUNC);

2. ADC initialization, ret = csi_adc_init(&adc, 0);

3. Set the ADC working sampling frequency ret = csi_adc_freq_div(&adc, 128);

4. Set the sampling period, ret = csi_adc_sampling_time(&adc, 2);

5. Enable ADC channel, ret = csi_adc_channel_enable(&adc, 0, true);

6. Start sampling, ret = csi_adc_start(&adc);

7. Read the sampled data, data = csi_adc_read(&adc);

Steps 6 and 7 can be repeated. The complete procedure is as follows:

#include <drv/adc.h>
#include <drv/tick.h>
#include <board_config.h>
//#include <board_init.h>
#define ADC_CHECK_RETURN(ret)            \
do {                                     \
    if (ret != CSI_OK) {                 \
        return -1;                       \
    }                                    \
} while(0);


static csi_adc_t adc;

int main(void)
{
	int      ret;
    uint32_t data;
	board_yoc_init();
	
	csi_pin_set_mux(EXAMPLE_ADC_CHANNEL0_PIN,  EXAMPLE_ADC_CHANNEL0_PIN_FUNC);
	ret = csi_adc_init(&adc, 0);
    ADC_CHECK_RETURN(ret);
	
	ret = csi_adc_freq_div(&adc, 128);
    if(ret == 0){
        return -1;
    }
	
	/* Configure sampling time */
    ret = csi_adc_sampling_time(&adc, 2);
    ADC_CHECK_RETURN(ret);

    /* Enable channel */
    ret = csi_adc_channel_enable(&adc, 0, true);
    ADC_CHECK_RETURN(ret);

    /* Trigger new conversion */
    ret = csi_adc_start(&adc);
    ADC_CHECK_RETURN(ret);

    /* Read result */
    data = csi_adc_read(&adc);
    printf("get adc result: %d\n", data);
	
	/* Uninit adc */
    csi_adc_uninit(&adc);
		
    LOGD(TAG, "%s\n", aos_get_app_version());
    oled_init();
    while (1) {
        LOGD(TAG, "Hello world! YoC");
        aos_msleep(1000);
    }

    return 0;
}

csi_adc_uninit(&adc); This step is optional. The test results are as follows:

This post is from Domestic Chip Exchange

Latest reply

WTF, it's so confusing to mess around with this abbreviation that's recognized by most people.   Details Published on 2021-9-8 22:11
 
 

1942

Posts

2

Resources
2
 

I thought it was a CSI camera interface!

This post is from Domestic Chip Exchange
 
 
 

7422

Posts

2

Resources
3
 

What is the abbreviation for CSI?

This post is from Domestic Chip Exchange

Comments

Just follow the definition of the chip driver interface layer (CSI), CHIP SERVIC INTFACE  Details Published on 2021-9-8 12:44
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

2865

Posts

4

Resources
4
 
freebsder posted on 2021-9-8 00:11 What is the abbreviation of CSI?

Just follow the definition of the chip driver interface layer (CSI), CHIP SERVIC INTFACE

This post is from Domestic Chip Exchange

Comments

WTF, it's so confusing to mess around with an abbreviation that's generally accepted by most people.  Details Published on 2021-9-8 22:11
 
 
 

30

Posts

0

Resources
5
 

I was pleasantly surprised to find the ES7210+ES8156 that I represented. Haha!

This post is from Domestic Chip Exchange
 
 
 

7422

Posts

2

Resources
6
 
bigbat posted on 2021-9-8 12:44 Just follow the definition of the chip driver interface layer (CSI), CHIP SERVIC INTFACE

WTF, it's so confusing to mess around with this abbreviation that's recognized by most people.

This post is from Domestic Chip Exchange
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list