forked from SlashDevin/NeoSWSerial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWork_cheat_sheet.txt
More file actions
74 lines (62 loc) · 3.17 KB
/
Work_cheat_sheet.txt
File metadata and controls
74 lines (62 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Available functions for Arduino Nano Matter:
getSilabsPortFromArduinoPin
getSilabsPinFromArduinoPin
GPIOINT_CallbackRegisterExt
GPIOINT_CallbackUnRegister
digitalPinToInterrupt
GPIO_PinModeSet
pinToPinName
analogRead
analogWrite
digitalRead
digitalWrite
pinMode
millis
micros
delay
Missing functions for Arduino Nano Matter:
Added: digitalPinToBitMask // returns the bitmask of a specified pin (A0, D5..)
Added: digitalPinToPort // returns the port (PB, PD...) of a specified pin (A0, D5..)
Added: portInputRegister // returns an input port register of the specified port => PD, PB, PC..., this register contains input values
Added: portOutputRegister // returns an output port register of the specified port.
digitalPinToPCMSK // quickly get the proper register (PCMSK0, PCMSK1, or PCMSK2) given the number of the Arduino pin. PCMSKx -> controls which pin from specific port can produce interrupt
// ATMEL: PCMSKx -> controls which pin from specific port can produce interrupt
// ARM(SiliconLabs): GPIO_IEN -> enable specific interrupt
digitalPinToPCICR // quickly get the proper register PCICR -> Possible to enable interrupts for bunch of pins (port) containing my rxPin
// ATMEL: Enable interrupts for bunch of pins (port)
// ARM(SiliconLabs): GPIO_EXTIPSELL -> Enables interrupts for bunch of pins (port)
cli() // Clear interrupt global enable flag bit (disable all interrupts).
-> possible to use use __disable_irq like:
void ImportantFunction1(void) {
/* Important function 1 */
uint32_t prim;
/* Do some stuff here which can be interrupted */
/* Read PRIMASK register, check interrupt status before you disable them */
/* Returns 0 if they are enabled, or non-zero if disabled */
prim = __get_PRIMASK();
/* Disable interrupts */
__disable_irq();
/* Do some stuff here which can not be interrupted */
/* Call subfunction */
ImportantFunction2();
/* Do some stuff here which can not be interrupted */
/* This part is still interrupt safe because ImportantFunction2 will not enable interrupts */
/* Enable interrupts back */
if (!prim) {
__enable_irq();
}
/* Do some stuff here which can be interrupted */
}
-> Why is so complicated to disable interrupts:
If interrupts were enabled and something interrupts you between the __get_PRIMASK() and the __disable_irq()
and disables IRQs itself, it will restore conditions before it finishes so my 'old_primask' variable will still be valid."
sei() // Set interrupt global enable flag bit (re-enable interrupts after being disabled).
Missing registers for Arduino Nano Matter:
SREG // SREG is the processor Status REGister. Global Interrupt Enable bit, carry and zero bit and so on...
TCNT0
PCI_FLAG_REGISTER // Pin Change interrupt flag register
Files where to inspire about:
- AppData\Local\Arduino15\packages\SiliconLabs\hardware\silabs\2.2.0
Interrupts -> Kody\NeoSWSerial\SiliconLabsSrc\cores\silabs\Interrupt.cpp
Pin to... -> Kody\NeoSWSerial\SiliconLabsSrc\cores\silabs\pinToIndex.cpp, SiliconLabsSrc\variants\nano_matter\pins_arduino.h
Pin mapping -> Kody\NeoSWSerial\SiliconLabsSrc\cores\silabs\pinDefinitions.h