aboutsummaryrefslogtreecommitdiff
path: root/docs/internals_gpio_control.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/internals_gpio_control.md')
-rw-r--r--docs/internals_gpio_control.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/internals_gpio_control.md b/docs/internals_gpio_control.md
index 48eaf8875..7c2228949 100644
--- a/docs/internals_gpio_control.md
+++ b/docs/internals_gpio_control.md
@@ -21,3 +21,22 @@ The following functions can provide basic control of GPIOs and are found in `qua
21## Advanced Settings :id=advanced-settings 21## Advanced Settings :id=advanced-settings
22 22
23Each microcontroller can have multiple advanced settings regarding its GPIO. This abstraction layer does not limit the use of architecture-specific functions. Advanced users should consult the datasheet of their desired device and include any needed libraries. For AVR, the standard avr/io.h library is used; for STM32, the ChibiOS [PAL library](http://chibios.sourceforge.net/docs3/hal/group___p_a_l.html) is used. 23Each microcontroller can have multiple advanced settings regarding its GPIO. This abstraction layer does not limit the use of architecture-specific functions. Advanced users should consult the datasheet of their desired device and include any needed libraries. For AVR, the standard avr/io.h library is used; for STM32, the ChibiOS [PAL library](http://chibios.sourceforge.net/docs3/hal/group___p_a_l.html) is used.
24
25## Atomic Operation
26
27The above functions are not always guaranteed to work atomically. Therefore, if you want to prevent interruptions in the middle of operations when using multiple combinations of the above functions, use the following `ATOMIC_BLOCK_FORCEON` macro.
28
29eg.
30```c
31void some_function() {
32 // some process
33 ATOMIC_BLOCK_FORCEON {
34 // Atomic Processing
35 }
36 // some process
37}
38```
39
40`ATOMIC_BLOCK_FORCEON` forces interrupts to be disabled before the block is executed, without regard to whether they are enabled or disabled. Then, after the block is executed, the interrupt is enabled.
41
42Note that `ATOMIC_BLOCK_FORCEON` can therefore be used if you know that interrupts are enabled before the execution of the block, or if you know that it is OK to enable interrupts at the completion of the block.