mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Adding Documents
Added documents for - GPIO handling - tasks, interrupts, etc used for Espruino
This commit is contained in:
parent
62efa8654d
commit
278c67b871
74
targets/esp32/docs/GPIOHandling.md
Normal file
74
targets/esp32/docs/GPIOHandling.md
Normal file
@ -0,0 +1,74 @@
|
||||
GPIO
|
||||
====
|
||||
ESP32 has a lot of GPIOs and supports different protocols etc. In this document we focus on simple GPIO binary handling. Documents for SPI, Analog, PWM etc. will follow.
|
||||
|
||||
###Available GPIOs / pins###
|
||||
Even having GPIO named from 0 to 39, does not mean, we have all available. Some of them don't even exist, and only a few are available on DevkitC.
|
||||
|
||||
| CPU pin | GPIO | Devkit C|
|
||||
| --- | --- | --- |
|
||||
| 5 | 36 | X |
|
||||
| 6 | 37 | |
|
||||
| 7 | 38 | |
|
||||
| 8 | 39 | X |
|
||||
| 10 | 34 | X |
|
||||
| 11 | 35 | X |
|
||||
| 12 | 32 | X |
|
||||
| 13 | 33 | X |
|
||||
| 14 | 25 | X |
|
||||
| 15 | 26 | X |
|
||||
| 16 | 27 | X |
|
||||
| 17 | 14 | X |
|
||||
| 18 | 12 | X |
|
||||
| 20 | 13 | X |
|
||||
| 21 | 15 | X |
|
||||
| 22 | 2 | X|
|
||||
| 23 | 0 | X|
|
||||
| 24 | 4 | X|
|
||||
| 25 | 16 | X |
|
||||
| 27 | 17 | X |
|
||||
| 28 | 9 | |
|
||||
| 29 | 10 | |
|
||||
| 30 | 11 | |
|
||||
| 31 | 6 | |
|
||||
| 32 | 7 | |
|
||||
| 33 | 8 | |
|
||||
| 34 | 5 | X |
|
||||
| 35 | 18 | X |
|
||||
| 36 | 23 | X |
|
||||
| 38 | 19 | X |
|
||||
| 39 | 22 | X |
|
||||
| 40 | 32 | |
|
||||
| 41 | 10 | |
|
||||
| 42 | 21 | X |
|
||||
|
||||
###Binary I/O###
|
||||
Espruino/targets/esp32/jshardware.c is the main connection between Espruino Core and special sources to handle ESP32 specific commands.
|
||||
For simple GPIO handling we have to fill following functions. For more information/detailed please go to source
|
||||
|
||||
| Function | Description |
|
||||
| --- | --- |
|
||||
| jshPinSetState | Set the state of the specific pin. |
|
||||
| jshPinGetState | return current State of pin |
|
||||
| jshPinSetValue | set the value of pin |
|
||||
| jshPinGetValue | get the value of pin |
|
||||
|
||||
###Interrupts###
|
||||
For commands like setWatch fast response of changes on pin is a must. Fastest way is catching interrupts. Following functions will do this particular job
|
||||
|
||||
| Function | Description |
|
||||
| --- | --- |
|
||||
| in jshInit | add a line to register GPIO interrupts (gpio_isr_register) |
|
||||
| gpio_intr_test | function to handle interrupts, calls jshPushIOWatchEvent for each changed pin that is enabled for interrupt |
|
||||
| jshGetWatchedPinState | Get the state of the pin associated with the event flag. Take care on parameter its IOEventFlags not pin |
|
||||
| jshPinWatch | Enables or disables interrupt for pin |
|
||||
| jshIsEventForPin | Determine if a given event is associated with a given pin |
|
||||
|
||||
###General functions###
|
||||
Please have in mind, there are pins and IOEventFlags. Handling them is simple, we only have to add EV_EXTIO. There are some definitions in Espruino Core. In jshardware.c we handle it this way. May be in future we find a better way.
|
||||
|
||||
| Function | Description |
|
||||
| --- | --- |
|
||||
| pinToEV_EXTI | maps a pin to an event |
|
||||
| | maping an event to a pin is done by subtracting EV_EXTI0 from IOEventFlag |
|
||||
| pinToESP32Pin | converts a number to a gpio_num_t |
|
||||
21
targets/esp32/docs/TasksInterruptsEtc.md
Normal file
21
targets/esp32/docs/TasksInterruptsEtc.md
Normal file
@ -0,0 +1,21 @@
|
||||
Internals
|
||||
===
|
||||
RTOS and the SDK for ESP32 bring up some new screws and bolts.
|
||||
In this document, we will list at least some of them.
|
||||
|
||||
##Tasks##
|
||||
Rtos supports a simple form of tasks. These tasks get a priority on start and some other information.
|
||||
|
||||
| Task | Stack | Priority |
|
||||
| --- | --- | --- |
|
||||
| espruinoTask | 10000 | 5 |
|
||||
|
||||
|
||||
##Interrupt Level##
|
||||
Each realtime OS uses interrupts, and so does RTOS. There are some predefined or reserved for future use. For more info see esp-idf/components/esp32/include/soc/soc.h line 259ff..
|
||||
In this list we have all interrupts handled for Espruino
|
||||
|
||||
| Intr num | level | descripton |
|
||||
| --- | --- | --- |
|
||||
| 18 | 1 | GPIO interrupt used for setWatch |
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user