Skip to content

Disable ADC missing #415

Open
Open

Description

@Reneg973

According to datasheet 4.9.3

The ADC can be disabled again at any time by clearing CS.EN, to save power.

The implemenation for this is missing.

What would be the accepted implementation, #if or #else?

static inline void adc_set_enabled(bool enable) {
#if 0
  adc_hw->cs = enable ? adc_hw->cs | ADC_CS_EN_BITS : adc_hw->cs &~ ADC_CS_EN_BITS;
#else
    if (enable)
        hw_set_bits(&adc_hw->cs, ADC_CS_EN_BITS)
    else
        hw_clear_bits(&adc_hw->cs, ADC_CS_EN_BITS);
#endif
}

Or maybe a 3rd variant?

Activity

  1. added this to the none milestone on May 31, 2021
  2. bruelltuete commented on Apr 24, 2022

    @bruelltuete
    Contributor

    I would call it adc_deinit(), similar to i2c_deinit().

  3. Reneg973 commented on Apr 26, 2022

    @Reneg973
    ContributorAuthor

    I would call it adc_deinit(), similar to i2c_deinit().

    Not really, I don't expect a deinit function to have a parameter. This function really can enable or disable the ADC, so it doesn't fit

  4. bruelltuete commented on Apr 26, 2022

    @bruelltuete
    Contributor

    I would call it adc_deinit(), similar to i2c_deinit().

    Not really, I don't expect a deinit function to have a parameter. This function really can enable or disable the ADC, so it doesn't fit

    Do you mean you don't like adc_deinit(bool enable)? Yeah me neither... it would just be adc_deinit() without param.

  5. Reneg973 commented on Apr 26, 2022

    @Reneg973
    ContributorAuthor

    I would call it adc_deinit(), similar to i2c_deinit().

    Not really, I don't expect a deinit function to have a parameter. This function really can enable or disable the ADC, so it doesn't fit

    Do you mean you don't like adc_deinit(bool enable)? Yeah me neither... it would just be adc_deinit() without param.

    No I think you are out of context. The point is with setting/resetting the flag you enable or disable the ADC conversion. It doesn't do any deinitialization. You can simply enable it by setting the bit again. The same applies for gpio_deinit(). There is no deinit on a GPIO.

  6. modified the milestones: none, back burner on Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions