STM32 wiring extensions: analog resolution and frequency, digitalToggle(), noTone(), attachInterrupt() and timing helper macros.
More...
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include "api/Common.h"
#include "api/deprecated-avr-comp/avr/dtostrf.h"
#include "api/itoa.h"
#include "clock.h"
#include "dwt.h"
#include "interrupt.h"
#include <board.h>
#include "HardwareTimer.h"
#include "WSerial.h"
|
|
#define | DEFAULT 1 |
| | Default analog reference, kept for AVR compatibility.
|
|
#define | EXTERNAL 0 |
| | External analog reference, kept for AVR compatibility.
|
| #define | interrupts() |
| | Enable all interrupts.
|
| #define | noInterrupts() |
| | Disable all interrupts.
|
| #define | _BV(bit) |
| | Value of a bit mask with only the given bit set.
|
| #define | cbi(reg, bitmask) |
| | Clear the bits of bitmask in the register pointed to by reg.
|
| #define | sbi(reg, bitmask) |
| | Set the bits of bitmask in the register pointed to by reg.
|
| #define | clockCyclesPerMicrosecond() |
| | Number of CPU clock cycles per microsecond.
|
| #define | clockCyclesToMicroseconds(a) |
| | Convert a number of CPU clock cycles to microseconds.
|
| #define | microsecondsToClockCycles(a) |
| | Convert a number of microseconds to CPU clock cycles.
|
|
| void | analogReadResolution (int res) |
| | Set the resolution of analogRead return values.
|
| void | analogWriteResolution (int res) |
| | Set the resolution of analogWrite parameters.
|
| void | analogWriteFrequency (uint32_t freq) |
| | Set the frequency of analogWrite.
|
| void | digitalToggle (pin_size_t pinNumber) |
| | Toggle the value from a specified digital pin.
|
| void | noTone (uint8_t _pin, bool destruct) |
| | Stop tone generation on pin.
|
| void | attachInterrupt (pin_size_t pin, callback_function_t callback, PinStatus mode) |
| | Attach a callback function to an external interrupt on a pin.
|
STM32 wiring extensions: analog resolution and frequency, digitalToggle(), noTone(), attachInterrupt() and timing helper macros.
◆ _BV
Value:
Value of a bit mask with only the given bit set.
◆ cbi
| #define cbi |
( |
| reg, |
|
|
| bitmask ) |
Value:
Clear the bits of bitmask in the register pointed to by reg.
◆ clockCyclesPerMicrosecond
| #define clockCyclesPerMicrosecond |
( |
| ) |
|
Value:( SystemCoreClock / 1000000L )
Number of CPU clock cycles per microsecond.
◆ clockCyclesToMicroseconds
| #define clockCyclesToMicroseconds |
( |
| a | ) |
|
Value:( ((a) * 1000L) / (SystemCoreClock / 1000L) )
Convert a number of CPU clock cycles to microseconds.
◆ interrupts
Value:
Enable all interrupts.
◆ microsecondsToClockCycles
| #define microsecondsToClockCycles |
( |
| a | ) |
|
Value:( (a) * (SystemCoreClock / 1000000L) )
Convert a number of microseconds to CPU clock cycles.
◆ noInterrupts
Value:
Disable all interrupts.
◆ sbi
| #define sbi |
( |
| reg, |
|
|
| bitmask ) |
Value:
Set the bits of bitmask in the register pointed to by reg.
◆ analogReadResolution()
| void analogReadResolution |
( |
int | res | ) |
|
|
extern |
Set the resolution of analogRead return values.
Default is 10 bits (range from 0 to 1023).
- Note
- The ADC is configured with the closest supported hardware resolution (capped to the maximum of the ADC) and the result is scaled to the requested resolution. Values outside the range 1 to 32 call Error_Handler().
- See also
- analogRead(), analogWriteResolution()
- Parameters
-
| res | Number of bits of the resolution, from 1 to 32. |
◆ analogWriteFrequency()
| void analogWriteFrequency |
( |
uint32_t | freq | ) |
|
|
extern |
◆ analogWriteResolution()
| void analogWriteResolution |
( |
int | res | ) |
|
|
extern |
Set the resolution of analogWrite parameters.
Default is 8 bits (range from 0 to 255).
- Note
- The PWM hardware resolution is capped to 16 bits and the value is scaled accordingly. Values outside the range 1 to 32 call Error_Handler().
- See also
- analogWrite(), analogReadResolution(), analogWriteFrequency()
- Parameters
-
| res | Number of bits of the resolution, from 1 to 32. |
◆ attachInterrupt()
| void attachInterrupt |
( |
pin_size_t | pin, |
|
|
callback_function_t | callback, |
|
|
PinStatus | mode ) |
|
extern |
Attach a callback function to an external interrupt on a pin.
- Note
- LOW and HIGH level triggers are only available on series supporting level interrupts, otherwise they fall back to FALLING and RISING respectively.
- Parameters
-
| pin | The pin to attach the interrupt to. |
| callback | Function called when the interrupt fires. It takes no arguments. |
| mode | Trigger mode: CHANGE, RISING, FALLING, LOW or HIGH. |
◆ digitalToggle()
| void digitalToggle |
( |
pin_size_t | pinNumber | ) |
|
|
extern |
Toggle the value from a specified digital pin.
- Parameters
-
| pinNumber | The number of the digital pin you want to toggle. |
◆ noTone()
| void noTone |
( |
uint8_t | _pin, |
|
|
bool | destruct ) |
|
extern |
Stop tone generation on pin.
- Parameters
-
| _pin | The pin on which to stop tone generation. |
| destruct | If true, the tone timer is deinitialized and deleted. If false, it is only paused. |