Arduino Core for STM32  1.0
wirish.h
Go to the documentation of this file.
1 #ifndef _wirish_h
2 #define _wirish_h
3 
11 #if defined(STM32F030x6)
12 #include <stm32f030x6.h>
13 #include "stm32f0xx_hal.h"
14 #define LED_BUILTIN (PA2)
15 
16 #elif defined(STM32F070x6)
17 #include <stm32f070x6.h>
18 #include "stm32f0xx_hal.h"
19 
20 #elif defined(STM32F070xB)
21 #include <stm32f070xb.h>
22 #include "stm32f0xx_hal.h"
23 
24 #elif defined(STM32F031x6)
25 #include <stm32f031x6.h>
26 #include "stm32f0xx_hal.h"
27 
28 #elif defined(STM32F103xB)
29 #include <stm32f103xb.h>
30 #include "stm32f1xx_hal.h"
31 #define LED_BUILTIN (PC13)
32 
33 #elif defined(STM32L031xx)
34 #include <stm32l031xx.h>
35 #include "stm32l0xx_hal.h"
36 #define LED_BUILTIN (PB3)
37 
38 //Nucleo L031 pin mapping
39 #define D0 PA10
40 #define D1 PA9
41 #define D2 PA12
42 #define D3 PB0
43 #define D4 PB7
44 #define D5 PB6
45 #define D6 PB1
46 #define D9 PA8
47 #define D10 PA11
48 #define D11 PB5
49 #define D12 PB4
50 #define D13 PB3
51 #define A0 PA0
52 #define A1 PA1
53 #define A2 PA3
54 #define A3 PA4
55 #define A4 PA5
56 #define A5 PA6
57 #define A6 PA7
58 #define A7 PA2
59 
60 #elif defined(STM32L432xx)
61 #include <stm32l432xx.h>
62 #include "stm32l4xx_hal.h"
63 #define LED_BUILTIN (PB3)
64 
65 //Nucleo L432 pin mapping
66 #define D0 PA10
67 #define D1 PA9
68 #define D2 PA12
69 #define D3 PB0
70 #define D4 PB7
71 #define D5 PB6
72 #define D6 PB1
73 #define D9 PA8
74 #define D10 PA11
75 #define D11 PB5
76 #define D12 PB4
77 #define D13 PB3
78 #define A0 PA0
79 #define A1 PA1
80 #define A2 PA3
81 #define A3 PA4
82 #define A4 PA5
83 #define A5 PA6
84 #define A6 PA7
85 #define A7 PA2
86 
87 #else
88 #error "Library for your chip is not included"
89 #endif
90 
91 #if defined(USE_HAL_DRIVER) && !defined(STM32)
92 #define STM32
93 #endif
94 
95 #if !defined(HAL_GPIO_MODULE_ENABLED)
96 #error "GPIO is disabled in .ioc file, modify at least one pin to use wirish file"
97 #endif
98 
99 
100 #ifndef W_INT_HANDLING_MODE
101 
104 #define W_INT_HANDLING_MODE 2
105 #endif
106 
107 
108 #include "interrupt.h"
109 #include <functional>
110 
114 #define W_OK 1
115 
119 #define W_BAD_ARG -1
120 
124 #define W_ERR 0
125 
126 // Pin name definitions - BEGIN
127 #if defined(GPIOA)
128 #define PA0 0x00
129 #define PA1 0x01
130 #define PA2 0x02
131 #define PA3 0x03
132 #define PA4 0x04
133 #define PA5 0x05
134 #define PA6 0x06
135 #define PA7 0x07
136 #define PA8 0x08
137 #define PA9 0x09
138 #define PA10 0x0A
139 #define PA11 0x0B
140 #define PA12 0x0C
141 #define PA13 0x0D
142 #define PA14 0x0E
143 #define PA15 0x0F
144 
145 #define PA00 PA0
146 #define PA01 PA1
147 #define PA02 PA2
148 #define PA03 PA3
149 #define PA04 PA4
150 #define PA05 PA5
151 #define PA06 PA6
152 #define PA07 PA7
153 #define PA08 PA8
154 #define PA09 PA9
155 #endif
156 
157 #if defined(GPIOB)
158 #define PB0 0x10
159 #define PB1 0x11
160 #define PB2 0x12
161 #define PB3 0x13
162 #define PB4 0x14
163 #define PB5 0x15
164 #define PB6 0x16
165 #define PB7 0x17
166 #define PB8 0x18
167 #define PB9 0x19
168 #define PB10 0x1A
169 #define PB11 0x1B
170 #define PB12 0x1C
171 #define PB13 0x1D
172 #define PB14 0x1E
173 #define PB15 0x1F
174 
175 #define PB00 PB0
176 #define PB01 PB1
177 #define PB02 PB2
178 #define PB03 PB3
179 #define PB04 PB4
180 #define PB05 PB5
181 #define PB06 PB6
182 #define PB07 PB7
183 #define PB08 PB8
184 #define PB09 PB9
185 #endif
186 
187 #if defined(GPIOC)
188 #define PC0 0x20
189 #define PC1 0x21
190 #define PC2 0x22
191 #define PC3 0x23
192 #define PC4 0x24
193 #define PC5 0x25
194 #define PC6 0x26
195 #define PC7 0x27
196 #define PC8 0x28
197 #define PC9 0x29
198 #define PC10 0x2A
199 #define PC11 0x2B
200 #define PC12 0x2C
201 #define PC13 0x2D
202 #define PC14 0x2E
203 #define PC15 0x2F
204 
205 #define PC00 PC0
206 #define PC01 PC1
207 #define PC02 PC2
208 #define PC03 PC3
209 #define PC04 PC4
210 #define PC05 PC5
211 #define PC06 PC6
212 #define PC07 PC7
213 #define PC08 PC8
214 #define PC09 PC9
215 #endif
216 
217 #if defined(GPIOD)
218 #define PD0 0x30
219 #define PD1 0x31
220 #define PD2 0x32
221 #define PD3 0x33
222 #define PD4 0x34
223 #define PD5 0x35
224 #define PD6 0x36
225 #define PD7 0x37
226 #define PD8 0x38
227 #define PD9 0x39
228 #define PD10 0x3A
229 #define PD11 0x3B
230 #define PD12 0x3C
231 #define PD13 0x3D
232 #define PD14 0x3E
233 #define PD15 0x3F
234 
235 #define PD00 PD0
236 #define PD01 PD1
237 #define PD02 PD2
238 #define PD03 PD3
239 #define PD04 PD4
240 #define PD05 PD5
241 #define PD06 PD6
242 #define PD07 PD7
243 #define PD08 PD8
244 #define PD09 PD9
245 #endif
246 
247 #if defined(GPIOE)
248 #define PE0 0x40
249 #define PE1 0x41
250 #define PE2 0x42
251 #define PE3 0x43
252 #define PE4 0x44
253 #define PE5 0x45
254 #define PE6 0x46
255 #define PE7 0x47
256 #define PE8 0x48
257 #define PE9 0x49
258 #define PE10 0x4A
259 #define PE11 0x4B
260 #define PE12 0x4C
261 #define PE13 0x4D
262 #define PE14 0x4E
263 #define PE15 0x4F
264 
265 #define PE00 PE0
266 #define PE01 PE1
267 #define PE02 PE2
268 #define PE03 PE3
269 #define PE04 PE4
270 #define PE05 PE5
271 #define PE06 PE6
272 #define PE07 PE7
273 #define PE08 PE8
274 #define PE09 PE9
275 #endif
276 
277 #if defined(GPIOF)
278 #define PF0 0x50
279 #define PF1 0x51
280 #define PF2 0x52
281 #define PF3 0x53
282 #define PF4 0x54
283 #define PF5 0x55
284 #define PF6 0x56
285 #define PF7 0x57
286 #define PF8 0x58
287 #define PF9 0x59
288 #define PF10 0x5A
289 #define PF11 0x5B
290 #define PF12 0x5C
291 #define PF13 0x5D
292 #define PF14 0x5E
293 #define PF15 0x5F
294 
295 #define PF00 PF0
296 #define PF01 PF1
297 #define PF02 PF2
298 #define PF03 PF3
299 #define PF04 PF4
300 #define PF05 PF5
301 #define PF06 PF6
302 #define PF07 PF7
303 #define PF08 PF8
304 #define PF09 PF9
305 #endif
306 
307 #if defined(GPIOG)
308 #define PG0 0x60
309 #define PG1 0x61
310 #define PG2 0x62
311 #define PG3 0x63
312 #define PG4 0x64
313 #define PG5 0x65
314 #define PG6 0x66
315 #define PG7 0x67
316 #define PG8 0x68
317 #define PG9 0x69
318 #define PG10 0x6A
319 #define PG11 0x6B
320 #define PG12 0x6C
321 #define PG13 0x6D
322 #define PG14 0x6E
323 #define PG15 0x6F
324 
325 #define PG00 PG0
326 #define PG01 PG1
327 #define PG02 PG2
328 #define PG03 PG3
329 #define PG04 PG4
330 #define PG05 PG5
331 #define PG06 PG6
332 #define PG07 PG7
333 #define PG08 PG8
334 #define PG09 PG9
335 #endif
336 
337 #if defined(GPIOH)
338 #define PH0 0x70
339 #define PH1 0x71
340 #define PH2 0x72
341 #define PH3 0x73
342 #define PH4 0x74
343 #define PH5 0x75
344 #define PH6 0x76
345 #define PH7 0x77
346 #define PH8 0x78
347 #define PH9 0x79
348 #define PH10 0x7A
349 #define PH11 0x7B
350 #define PH12 0x7C
351 #define PH13 0x7D
352 #define PH14 0x7E
353 #define PH15 0x7F
354 
355 #define PH00 PH0
356 #define PH01 PH1
357 #define PH02 PH2
358 #define PH03 PH3
359 #define PH04 PH4
360 #define PH05 PH5
361 #define PH06 PH6
362 #define PH07 PH7
363 #define PH08 PH8
364 #define PH09 PH9
365 #endif
366 
367 #if defined(GPIOI)
368 #define PI0 0x80
369 #define PI1 0x81
370 #define PI2 0x82
371 #define PI3 0x83
372 #define PI4 0x84
373 #define PI5 0x85
374 #define PI6 0x86
375 #define PI7 0x87
376 #define PI8 0x88
377 #define PI9 0x89
378 #define PI10 0x8A
379 #define PI11 0x8B
380 #define PI12 0x8C
381 #define PI13 0x8D
382 #define PI14 0x8E
383 #define PI15 0x8F
384 
385 #define PI00 PI0
386 #define PI01 PI1
387 #define PI02 PI2
388 #define PI03 PI3
389 #define PI04 PI4
390 #define PI05 PI5
391 #define PI06 PI6
392 #define PI07 PI7
393 #define PI08 PI8
394 #define PI09 PI9
395 #endif
396 
397 #if defined(GPIOJ)
398 #define PJ0 0x90
399 #define PJ1 0x91
400 #define PJ2 0x92
401 #define PJ3 0x93
402 #define PJ4 0x94
403 #define PJ5 0x95
404 #define PJ6 0x96
405 #define PJ7 0x97
406 #define PJ8 0x98
407 #define PJ9 0x99
408 #define PJ10 0x9A
409 #define PJ11 0x9B
410 #define PJ12 0x9C
411 #define PJ13 0x9D
412 #define PJ14 0x9E
413 #define PJ15 0x9F
414 
415 #define PJ00 PJ0
416 #define PJ01 PJ1
417 #define PJ02 PJ2
418 #define PJ03 PJ3
419 #define PJ04 PJ4
420 #define PJ05 PJ5
421 #define PJ06 PJ6
422 #define PJ07 PJ7
423 #define PJ08 PJ8
424 #define PJ09 PJ9
425 #endif
426 
427 #if defined(GPIOK)
428 #define PK0 0xA0
429 #define PK1 0xA1
430 #define PK2 0xA2
431 #define PK3 0xA3
432 #define PK4 0xA4
433 #define PK5 0xA5
434 #define PK6 0xA6
435 #define PK7 0xA7
436 #define PK8 0xA8
437 #define PK9 0xA9
438 #define PK10 0xAA
439 #define PK11 0xAB
440 #define PK12 0xAC
441 #define PK13 0xAD
442 #define PK14 0xAE
443 #define PK15 0xAF
444 
445 #define PK00 PK0
446 #define PK01 PK1
447 #define PK02 PK2
448 #define PK03 PK3
449 #define PK04 PK4
450 #define PK05 PK5
451 #define PK06 PK6
452 #define PK07 PK7
453 #define PK08 PK8
454 #define PK09 PK9
455 #endif
456 
457 #if defined(GPIOL) || defined(GPIOM) || defined(GPION) || defined(GPIOO) || defined(GPIOP) || defined(GPIOQ) || defined(GPIOR) || defined(GPIOS) || defined(GPIOT) || defined(GPIOU) || defined(GPIOV) || defined(GPIOW) || defined(GPIOX) || defined(GPIOY) || defined(GPIOZ)
458 #warning "Some GPIOx ports have not got defined pin names!"
459 #endif
460 // Pin name definitions - END
461 
466 typedef enum WiringPinMode {
518  /*PWM,*/
521  /*PWM_OPEN_DRAIN,*/
525 } WiringPinMode;
526 
527 //GPIO_TypeDef* PIN_TO_PORT (uint8_t pin);
528 
535 bool pinExists(GPIO_TypeDef *GPIOx, uint16_t PPin);
536 
542 bool pinExists(uint8_t Pin);
543 
550 bool enableGPIO(GPIO_TypeDef* GPIOx, bool enable);
551 
557 #define PIN_TO_PORT_PIN(Pin) (0x01 << ((Pin)&0x0F)) //Arduino like pin to Pin of port
558 
564 #define PIN_TO_PORT(Pin) (GPIO_Conversion_Table[(Pin)>>4]) //Arduino like pin to Port
565 
566 extern GPIO_TypeDef *GPIO_Conversion_Table[];
567 
574 uint8_t PortAndPinToPinNum(GPIO_TypeDef *GPIOx, uint16_t PPin);
575 
581 bool canSetInterruptOnPin(uint8_t Pin);
582 
589 GPIO_TypeDef* getInterruptGPIOfromPin(uint16_t Pin);
590 
607 bool isInterruptSetOnPin(uint8_t Pin);
608 
618 uint8_t pinMode(GPIO_TypeDef *GPIOx, uint16_t PPin, WiringPinMode mode, uint32_t speed);
619 
626 inline void digitalWrite(GPIO_TypeDef *GPIOx, uint16_t PPin, bool val){
627  HAL_GPIO_WritePin(GPIOx, PPin, (GPIO_PinState)val);
628 }
629 
636 inline uint16_t digitalRead(GPIO_TypeDef *GPIOx, uint16_t PPin){
637  return (uint16_t)HAL_GPIO_ReadPin(GPIOx, PPin);
638 }
639 
645 inline void digitalToggle(GPIO_TypeDef *GPIOx, uint16_t PPin){
646  HAL_GPIO_TogglePin(GPIOx, PPin);
647 }
648 
649 //---Arduino like functions BEGIN
650 
659 uint8_t pinMode(uint8_t Pin, WiringPinMode mode, uint32_t speed);
660 
668 uint8_t inline pinMode(uint8_t Pin, WiringPinMode mode){
669  return pinMode(Pin, mode, GPIO_SPEED_FREQ_LOW);
670 }
671 
677 inline void digitalWrite(uint8_t Pin, bool val){
678  HAL_GPIO_WritePin(PIN_TO_PORT(Pin), PIN_TO_PORT_PIN(Pin), (GPIO_PinState)val);
679 }
680 
686 inline bool digitalRead(uint8_t Pin){
687  GPIO_TypeDef *GPIOx = PIN_TO_PORT(Pin);
688  uint16_t PPin = PIN_TO_PORT_PIN(Pin);
689  /* Check the parameters */
690  assert_param(IS_GPIO_PIN_AVAILABLE(GPIOx, PPin));
691  return (GPIOx->IDR & PPin) != (uint32_t)GPIO_PIN_RESET;
692 }
693 
698 inline void digitalToggle(uint8_t Pin){
699  digitalWrite(Pin,!digitalRead(Pin));
700 }
701 
712 int8_t attachInterrupt(uint8_t Pin, std::function<void(void)>, int mode);
713 
722 int8_t detachInterrupt(uint8_t Pin, bool disableEXTIwhenNotUsed = false);
723 
730 void InterruptHandler(uint8_t lineFrom, uint8_t lineTo);
731 
739 int8_t isPinUsedByInt(uint8_t INTPPin);
740 
748 uint32_t getPinPullSetting(GPIO_TypeDef *GPIOx, uint8_t INTPin);
749 
757 uint32_t getPinSpeedSetting(GPIO_TypeDef *GPIOx, uint8_t INTPin);
758 
759 //#define min(a,b) (((a)<(b))?(a):(b))
760 //#define max(a,b) (((a)>(b))?(a):(b))
761 
762 #if !defined(min)
763 
769 #define MIN(a,b) (((a)<(b))?(a):(b))
770 #endif
771 #if !defined(max)
772 
778 #define MAX(a,b) (((a)>(b))?(a):(b))
779 #endif
780 #if !defined(Abs)
781 
787 #define Abs(a) (((a)>=0)?(a):-(a))
788 #endif
789 
790 
796 #define lowByte(w) ((w) & 0xFF)
797 
803 #define highByte(w) (((w) >> 8) & 0xFF)
804 
811 #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
812 
819 #define bitSet(value, bit) ((value) |= (1UL << (bit)))
820 
827 #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
828 
836 #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : \
837  bitClear(value, bit))
838 
844 #define bit(b) (1UL << (b))
845 
851 #define millis() HAL_GetTick()
852 /*unsigned long inline millis(void){
853  return HAL_GetTick();
854 }*/
855 
860 #define delay(millis) HAL_Delay(millis)
861 //void delay(unsigned long millis);
862 
868 bool WirishInit(void);
869 
870 #ifdef DWT
871 //TODO add here calibration value for DWT
872 #else
873 //Value established by measuring to 16-18, it has to be measured more properly
874 #define WAIT_US_CALIBRATION (18) //It says, how many cycles (Not clock cycles) are used by calling this functions
875 //Ticks needed for calling this method ticks = WAIT_US_CALIBRATION * 3; (asm line takes 3 ticks for one cycle)
876 //Also minumum wait time is t = (WAIT_US_CALIBRATION * 3 + 2)/SystemCoreClock [seconds]
877 #endif
878 
879 #if defined(DWT) || defined(DOXYGEN_FORCED) //We can use Data Watchpoint and Trace Register (DWT) and it's cycle counter
880 
888 void __attribute__((optimize("Ofast"))) delayMicrosecondsDWT(uint32_t microseconds);
889 #endif //defined(DWT) || defined(DOXYGEN_FORCED)
890 
899 void __attribute__((optimize("Ofast"))) delayMicroseconds(int32_t microseconds);
900 
906 inline uint32_t __attribute__((optimize("Ofast"))) micros(){
907 /*#ifdef DWT //We can use Data Watchpoint and Trace Register (DWT) and it's cycle counter
908  return cyccnt / (SystemCoreClock / 1000000); //TODO result may be truncated
909 
910 #else //For MCUs, that does not have DWT*/
911  uint32_t load = SysTick->LOAD;
912  volatile uint32_t ms = uwTick; //This is set to volatile to not remove if statement bellow by optimization
913  uint32_t initVal = SysTick->VAL;
914  if(ms != uwTick){ //This solves situation, when storing uwTick SysTick->VAL overflowed, it can cause 1ms error
915  //We know, SysTick->VAL overflowed, so values have to be captured again
916  initVal = SysTick->VAL;
917  ms = uwTick;
918  }
919  return ms*1000UL + ((load-initVal)*1000)/(load+1);
920 //#endif //DWT
921 }
922 
929 inline uint64_t __attribute__((optimize("Ofast"))) micros64(){
930 /*#ifdef DWT //We can use Data Watchpoint and Trace Register (DWT) and it's cycle counter
931  return cyccnt / (SystemCoreClock / 1000000); //TODO result may be truncated
932 
933 #else //For MCUs, that does not have DWT*/
934  uint32_t load = SysTick->LOAD;
935  volatile uint32_t ms = uwTick; //This is set to volatile to not remove if statement bellow by optimization
936  uint32_t initVal = SysTick->VAL;
937  if(ms != uwTick){ //This solves situation, when storing uwTick SysTick->VAL overflowed, it can cause 1ms error
938  //We know, SysTick->VAL overflowed, so values have to be captured again
939  initVal = SysTick->VAL;
940  ms = uwTick;
941  }
942  return ((uint64_t)ms)*1000ULL + (((uint64_t)(load-initVal))*1000ULL)/(load+1);
943 //#endif //DWT
944 }
945 
949 #define cli() __disable_irq()
950 
957 #define noInterrupts() cli()
958 
959 #define sei() __enable_irq()
960 
967 #define interrupts() sei()
968 
969 
970 //extern void attachInterrupt(uint8_t, void (*)(void), int mode);
971 
978 unsigned long random(unsigned long from, unsigned long to);
979 
985 unsigned long random(unsigned long to);
986 
992 void randomSeed(unsigned long seed);
993 
997 #define HIGH 0x1
998 
1002 #define LOW 0x0
1003 
1007 #define LSBFIRST 0
1008 
1012 #define MSBFIRST 1
1013 
1018 #define CHANGE 1
1019 
1024 #define FALLING 2
1025 
1030 #define RISING 3
1031 
1032 //---Arduino like functions END
1033 
1034 #ifndef RCC_FLAG_PORRST
1035 
1036 #define RESET_CAUSE_POWER_ON_POWER_DOWN_RESET RESET_CAUSE_EXTERNAL_RESET_PIN_RESET
1037 #endif
1038 
1042 typedef enum reset_cause_e{
1053 #ifdef RCC_FLAG_PORRST
1054 
1056 #endif
1057 
1061 #ifdef RCC_FLAG_FWRST
1062 
1063  RESET_CAUSE_FIREWALL_RESET = 8,
1064 #endif
1065 #ifdef RCC_FLAG_OBLRST
1066 
1067  RESET_CAUSE_OPT_BYTE_LDR_RESET = 9,
1068 #endif
1069 } ResetCause;
1070 
1071 extern ResetCause rst_cs;
1072 
1078 const char* getResetCauseName();
1079 
1085  return rst_cs;
1086 }
1087 
1092 inline void getDeviceLOTID(char* buffer){
1093  buffer[0] = *((const char*) (UID_BASE + 5));
1094  buffer[1] = *((const char*) (UID_BASE + 6));
1095  buffer[2] = *((const char*) (UID_BASE + 7));
1096  buffer[3] = ' ';
1097  buffer[4] = *((const char*) (UID_BASE + 8));
1098  buffer[5] = *((const char*) (UID_BASE + 9));
1099  buffer[6] = *((const char*) (UID_BASE + 10));
1100  buffer[7] = 0;
1101 }
1102 
1103 
1108 inline uint8_t getDeviceWAFID(){
1109  return *((volatile uint8_t *)(UID_BASE + 4));
1110 }
1111 
1116 inline uint16_t getDeviceWAFX(){
1117  return *((volatile uint16_t *)(UID_BASE));
1118 }
1119 
1124 inline uint16_t getDeviceWAFY(){
1125  return *((volatile uint16_t *)(UID_BASE + 2));
1126 }
1127 
1132 inline uint32_t getFlashSize(){
1133  return *((volatile uint16_t *)(FLASHSIZE_BASE)) * 1024;
1134 }
1135 
1136 #endif
INPUT_PULLUP
@ INPUT_PULLUP
The state of the pin in this mode is reported the same way as with INPUT, but the pin voltage is gent...
Definition: wirish.h:500
RESET_CAUSE_POWER_ON_POWER_DOWN_RESET
#define RESET_CAUSE_POWER_ON_POWER_DOWN_RESET
Power-ON reset, Power-DOWN reset cause.
Definition: wirish.h:1036
getPinPullSetting
uint32_t getPinPullSetting(GPIO_TypeDef *GPIOx, uint8_t INTPin)
This function should return actual pin pull setting (GPIO_NOPULL, GPIO_PULLUP, GPIO_PULLDOWN)
Definition: wirish.cpp:581
getPinSpeedSetting
uint32_t getPinSpeedSetting(GPIO_TypeDef *GPIOx, uint8_t INTPin)
This should return actual pin toggle speed setting.
Definition: wirish.cpp:628
OUTPUT_OPEN_DRAIN
@ OUTPUT_OPEN_DRAIN
In open drain mode, the pin indicates "low" by accepting current flow to ground and "high" by providi...
Definition: wirish.h:471
reset_cause_e
reset_cause_e
Possible STM32 system reset causes.
Definition: wirish.h:1042
PIN_TO_PORT
#define PIN_TO_PORT(Pin)
Converts Arduino like pin number (Pin) to GPIO port.
Definition: wirish.h:564
INPUT
@ INPUT
Basic digital input.
Definition: wirish.h:487
RESET_CAUSE_UNKNOWN
@ RESET_CAUSE_UNKNOWN
Unknown reset cause.
Definition: wirish.h:1044
RESET_CAUSE_INDEPENDENT_WATCHDOG_RESET
@ RESET_CAUSE_INDEPENDENT_WATCHDOG_RESET
Independent watchdog reset cause.
Definition: wirish.h:1050
INPUT_ANALOG
@ INPUT_ANALOG
This is a special mode for when the pin will be used for analog (not digital) reads.
Definition: wirish.h:495
RESET_CAUSE_WINDOW_WATCHDOG_RESET
@ RESET_CAUSE_WINDOW_WATCHDOG_RESET
Window watchdog reset cause.
Definition: wirish.h:1048
rst_cs
ResetCause rst_cs
Definition: wirish.cpp:1134
GPIO_Conversion_Table
GPIO_TypeDef * GPIO_Conversion_Table[]
Definition: wirish.cpp:13
enableGPIO
bool enableGPIO(GPIO_TypeDef *GPIOx, bool enable)
Enables/Disables GPIO port periphery.
Definition: wirish.cpp:309
randomSeed
void randomSeed(unsigned long seed)
Initializes the pseudo-random number generator, causing it to start at an arbitrary point in its rand...
Definition: wirish.cpp:1029
getDeviceLOTID
void getDeviceLOTID(char *buffer)
Returns device LOT ID as text.
Definition: wirish.h:1092
interrupt.h
This file contains override weak GPIO interrupt functions.
RESET_CAUSE_LOW_POWER_RESET
@ RESET_CAUSE_LOW_POWER_RESET
Low power reset cause.
Definition: wirish.h:1046
ResetCause
enum reset_cause_e ResetCause
Possible STM32 system reset causes.
pinExists
bool pinExists(GPIO_TypeDef *GPIOx, uint16_t PPin)
Checks if pin is available on MCU.
Definition: wirish.cpp:73
random
unsigned long random(unsigned long from, unsigned long to)
The random function generates pseudo-random numbers.
Definition: wirish.cpp:1013
getFlashSize
uint32_t getFlashSize()
Gets flash size in bytes.
Definition: wirish.h:1132
InterruptHandler
void InterruptHandler(uint8_t lineFrom, uint8_t lineTo)
Include this in every EXTI interrupt handler for lines 0-15.
Definition: wirish.cpp:908
getDeviceWAFID
uint8_t getDeviceWAFID()
Gets device wafer plate ID.
Definition: wirish.h:1108
RESET_CAUSE_SOFTWARE_RESET
@ RESET_CAUSE_SOFTWARE_RESET
Software reset cause.
Definition: wirish.h:1052
OUTPUT
@ OUTPUT
Basic digital output: when the pin is HIGH, the voltage is held at +3.3v (Vcc) and when it is LOW,...
Definition: wirish.h:467
getInterruptGPIOfromPin
GPIO_TypeDef * getInterruptGPIOfromPin(uint16_t Pin)
Gets, what GPIO is attached to EXTI line, that belongs to PPin.
Definition: wirish.cpp:471
getDeviceWAFX
uint16_t getDeviceWAFX()
Returns device wafer plate X coordination.
Definition: wirish.h:1116
getDeviceWAFY
uint16_t getDeviceWAFY()
Gets device wafer plate Y coordination.
Definition: wirish.h:1124
INPUT_FLOATING
@ INPUT_FLOATING
Synonym for INPUT.
Definition: wirish.h:516
__attribute__
void __attribute__((optimize("Ofast"))) delayMicrosecondsDWT(uint32_t microseconds)
Pauses the program for the amount of time (in microseconds) specified as parameter.
Definition: wirish.h:906
PortAndPinToPinNum
uint8_t PortAndPinToPinNum(GPIO_TypeDef *GPIOx, uint16_t PPin)
Converts GPIOx port and it's pin to Arduino like pin number.
Definition: wirish.cpp:176
digitalRead
uint16_t digitalRead(GPIO_TypeDef *GPIOx, uint16_t PPin)
Reads state of pin or multiple pins.
Definition: wirish.h:636
INPUT_PULLDOWN
@ INPUT_PULLDOWN
The state of the pin in this mode is reported the same way as with INPUT, but the pin voltage is gent...
Definition: wirish.h:508
pinMode
uint8_t pinMode(GPIO_TypeDef *GPIOx, uint16_t PPin, WiringPinMode mode, uint32_t speed)
Sets mode of selected pin.
Definition: wirish.cpp:250
canSetInterruptOnPin
bool canSetInterruptOnPin(uint8_t Pin)
Checks if EXTI line, that belongs to Pin is not used by other pin's interrupt.
Definition: wirish.cpp:459
PIN_TO_PORT_PIN
#define PIN_TO_PORT_PIN(Pin)
Converts Arduino like pin number (Pin) to Pin of port (PPin).
Definition: wirish.h:557
digitalWrite
void digitalWrite(GPIO_TypeDef *GPIOx, uint16_t PPin, bool val)
Writes new state to pin or multiple pins.
Definition: wirish.h:626
RESET_CAUSE_BROWNOUT_RESET
@ RESET_CAUSE_BROWNOUT_RESET
Brownout reset cause.
Definition: wirish.h:1060
WirishInit
bool WirishInit(void)
Initializes some wirish functions.
Definition: wirish.cpp:931
detachInterrupt
int8_t detachInterrupt(uint8_t Pin, bool disableEXTIwhenNotUsed=false)
Detaches interrupt from selected pin and sets pin mode to INPUT.
Definition: wirish.cpp:738
digitalToggle
void digitalToggle(GPIO_TypeDef *GPIOx, uint16_t PPin)
Toggles pin state.
Definition: wirish.h:645
getResetCause
ResetCause getResetCause()
Reads the STM32 system reset cause.
Definition: wirish.h:1084
attachInterrupt
int8_t attachInterrupt(uint8_t Pin, std::function< void(void)>, int mode)
Attaches interrupt to selected pin.
Definition: wirish.cpp:669
getResetCauseName
const char * getResetCauseName()
Gets the system reset cause as an ASCII-printable name string from a reset cause type.
Definition: wirish.cpp:1088
isPinUsedByInt
int8_t isPinUsedByInt(uint8_t INTPPin)
Checks if pin is not used for interrupt.
WiringPinMode
WiringPinMode
Pin mode enumerations.
Definition: wirish.h:466
RESET_CAUSE_EXTERNAL_RESET_PIN_RESET
@ RESET_CAUSE_EXTERNAL_RESET_PIN_RESET
External reset pin reset cause.
Definition: wirish.h:1058
isInterruptSetOnPin
bool isInterruptSetOnPin(uint8_t Pin)
Checks Pin is used as interrupt.
Definition: wirish.cpp:557