|
STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
|
← STM32duino documentation
|
Analog input (ADC) and analog output (PWM or DAC) functions. More...
Macros | |
| #define | MAX_PWM_RESOLUTION 16 |
| #define | MAX_ADC_RESOLUTION 12 |
Functions | |
| static uint32_t | mapResolution (uint32_t value, uint32_t from, uint32_t to) |
| Map a value from one resolution to another. | |
| void | analogReadResolution (int res) |
| Set the resolution of analogRead return values. | |
| void | analogReference (uint8_t mode) |
| Set the analog reference voltage. | |
| int | analogRead (pin_size_t pinNumber) |
| Read the analog value of a pin, scaled to the resolution set by analogReadResolution(). | |
| void | analogWriteResolution (int res) |
| Set the resolution of analogWrite parameters. | |
| void | analogWriteFrequency (uint32_t freq) |
| Set the frequency of analogWrite. | |
| void | analogWrite (pin_size_t pinNumber, int value) |
| Write an analog value to a pin, using PWM or DAC if the pin supports it. | |
Variables | |
| uint32_t | g_anOutputPinConfigured [MAX_NB_PORT] = {0} |
| static int | _writeResolution = PWM_RESOLUTION |
| static int | _internalWriteResolution |
| static uint32_t | _writeFreq = PWM_FREQUENCY |
| static int | _readResolution = ADC_RESOLUTION |
| static int | _internalReadResolution |
Analog input (ADC) and analog output (PWM or DAC) functions.
| int analogRead | ( | pin_size_t | pinNumber | ) |
Read the analog value of a pin, scaled to the resolution set by analogReadResolution().
The initialization of the analog pin is done through this function.
| pinNumber | Analog pin number, e.g. A0 or PA0. |
| void analogReadResolution | ( | int | res | ) |
Set the resolution of analogRead return values.
Default is 10 bits (range from 0 to 1023).
| res | Number of bits of the resolution, from 1 to 32. |
| void analogReference | ( | uint8_t | mode | ) |
Set the analog reference voltage.
Not supported on this core, the call has no effect.
| mode | Reference mode, ignored. |
| void analogWrite | ( | pin_size_t | pinNumber, |
| int | value | ||
| ) |
Write an analog value to a pin, using PWM or DAC if the pin supports it.
Output only works on the pins with Hardware Timer (PWM) or DAC support. For the other pins, it defaults to digital output: the value is scaled to 8 bits and the pin is set HIGH if it is 128 or more, LOW otherwise. The DAC takes precedence over PWM when a pin supports both.
| pinNumber | Pin number to write to. |
| value | Value to write, scaled to the resolution set by analogWriteResolution(). |
| void analogWriteFrequency | ( | uint32_t | freq | ) |
Set the frequency of analogWrite.
Default is PWM_FREQUENCY (1000) in Hertz.
| freq | PWM frequency in Hertz. |
| void analogWriteResolution | ( | int | res | ) |
Set the resolution of analogWrite parameters.
Default is 8 bits (range from 0 to 255).
| res | Number of bits of the resolution, from 1 to 32. |
|
inlinestatic |
Map a value from one resolution to another.
| value | Value to convert. |
| from | Resolution of value, in bits. |
| to | Target resolution, in bits. |
|
static |
|
static |