How to check ADC sampling status.

How we can get to know about the ADC sampling is done. On the basis of the sampling done i want to do furture opration like the stop sampling,Continues sampling. How i can achive this, one callback function is there which will return the enum adc_action *(adc_sequence_callback)(const struct device *dev,const struct adc_sequence *sequence,uint16_t sampling_index); can i use this to achieve my functionally if yes how i can proceed furture please give some suggestions.

1. I want to know about the how adc adc_sequence_callback is working for what purpose we can use it
adc typedef enum adc_action (*adc_sequence_callback)(const struct device *dev, const struct adc_sequence *sequence, uint16_t sampling_index);

2.  I want to understand about the Zeyphr adc_context_on_sampling_done() API how it is working in drivers/adc/adc_context.h.

 I am referring  adc.h from  "nCS\v1.8.0\zephyr\include\drivers" 

Parents
  • Hi Swati

    All functions and variables I reference in the following text can be found in Zephyr ADC API reference.

    When you are calling the adc_read function, you need to configure the ADC using the adc_sequence argument.

    adc_sequence has seven different configurations for the adc. These are

    1. channels
    2. buffer
    3. buffer_size
    4. resolution
    5. oversampling
    6. calibrate
    7. options

    options are additional options for the ADC configuration, and has the type adc_sequence_options.

    adc_sequence_options has four different additional configurations:

    1. interval_us
    2. callback
    3. user_data
    4. extra_samplings

    the callback configuration will be to a callback function which must be on the form:

    typedef enum adc_action (*adc_sequence_callback)(const struct device *dev, const struct adc_sequence *sequence, uint16_t sampling_index)

    When this have been configured, this callback function will be called after a requested sampling by the ADC is done.

    2.  I want to understand about the Zeyphr adc_context_on_sampling_done() API how it is working in drivers/adc/adc_context.h.

    The adc_context_on_sampling_done() function is not a part of the public ADC driver. It is only used for internal operations in the driver.

    Here is an example showcasing how the adc with callback can be used with the adc_read function:

    2705.adc.zip

    Does this answer your questions?

    Regards,
    Sigurd Hellesvik

Reply
  • Hi Swati

    All functions and variables I reference in the following text can be found in Zephyr ADC API reference.

    When you are calling the adc_read function, you need to configure the ADC using the adc_sequence argument.

    adc_sequence has seven different configurations for the adc. These are

    1. channels
    2. buffer
    3. buffer_size
    4. resolution
    5. oversampling
    6. calibrate
    7. options

    options are additional options for the ADC configuration, and has the type adc_sequence_options.

    adc_sequence_options has four different additional configurations:

    1. interval_us
    2. callback
    3. user_data
    4. extra_samplings

    the callback configuration will be to a callback function which must be on the form:

    typedef enum adc_action (*adc_sequence_callback)(const struct device *dev, const struct adc_sequence *sequence, uint16_t sampling_index)

    When this have been configured, this callback function will be called after a requested sampling by the ADC is done.

    2.  I want to understand about the Zeyphr adc_context_on_sampling_done() API how it is working in drivers/adc/adc_context.h.

    The adc_context_on_sampling_done() function is not a part of the public ADC driver. It is only used for internal operations in the driver.

    Here is an example showcasing how the adc with callback can be used with the adc_read function:

    2705.adc.zip

    Does this answer your questions?

    Regards,
    Sigurd Hellesvik

Children
No Data
Related