Reading analog channel MANUALLY

Gericom:

rs1485:
As I said, we don't have access to those libraries. I.e. no adc_init and the other.

I would appreciate if you could copy the implementations of those 2 functions.
However, you say "like this" so I assume that you are only guessing.

I am not guessing as I am using it myself, but I am not sure of that kind of things are actually initialize by default. Anyway, here are the functions.
adc_init:

/**
  • \brief Initialize the given ADC with the specified ADC clock and startup time.

  • \param p_adc Pointer to an ADC instance.

  • \param ul_mck Main clock of the device (value in Hz).

  • \param ul_adc_clock Analog-to-Digital conversion clock (value in Hz).

  • \param uc_startup ADC start up time. Please refer to the product datasheet

  • for details.

  • \return 0 on success.
    */
    uint32_t adc_init(Adc *p_adc, const uint32_t ul_mck,
    const uint32_t ul_adc_clock, const uint8_t uc_startup)
    {
    uint32_t ul_prescal;

    /*  Reset the controller. */
    p_adc->ADC_CR = ADC_CR_SWRST;

    /* Reset Mode Register. */
    p_adc->ADC_MR = 0;

    /* Reset PDC transfer. */
    p_adc->ADC_PTCR = (ADC_PTCR_RXTDIS | ADC_PTCR_TXTDIS);
    p_adc->ADC_RCR = 0;
    p_adc->ADC_RNCR = 0;

    ul_prescal = ul_mck / (2 * ul_adc_clock) - 1;
    p_adc->ADC_MR |= ADC_MR_PRESCAL(ul_prescal) |
    ((uc_startup << ADC_MR_STARTUP_Pos) &
    ADC_MR_STARTUP_Msk);
    return 0;
    }



And adc_configure_timing:


/**

  • \brief Configure ADC timing.
  • \param p_adc Pointer to an ADC instance.
  • \param uc_tracking ADC tracking time = uc_tracking / ADC clock.
  • \param uc_settling Analog settling time = (uc_settling + 1) / ADC clock.
  • \param uc_transfer Data transfer time = (uc_transfer * 2 + 3) / ADC clock.
    */
    void adc_configure_timing(Adc *p_adc, const uint8_t uc_tracking,
    const enum adc_settling_time_t settling,const uint8_t uc_transfer)
    {
    p_adc->ADC_MR |= ADC_MR_TRANSFER(uc_transfer)
    | settling | ADC_MR_TRACKTIM(uc_tracking);
    }

Thanks!
Can you tell me what PDC stands for?
One more thing I would like to know is the function "AnalogRead" because that's what comes up whenever I try to google. I would be very thankful if you can paste the code of AnalogRead too!