Arduino Core for STM32  1.0
wirish.h File Reference

This file contains basic (Arduino like) GPIO manipulation functions, delay, random, etc. More...

#include "interrupt.h"
#include <functional>
Include dependency graph for wirish.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define W_INT_HANDLING_MODE   2
 Interrupt GPIO handling mode. More...
 
#define W_OK   1
 Wirish status OK. More...
 
#define W_BAD_ARG   -1
 Wirish status Bad Arguments. More...
 
#define W_ERR   0
 Wirish status Error. More...
 
#define PIN_TO_PORT_PIN(Pin)   (0x01 << ((Pin)&0x0F))
 Converts Arduino like pin number (Pin) to Pin of port (PPin). More...
 
#define PIN_TO_PORT(Pin)   (GPIO_Conversion_Table[(Pin)>>4])
 Converts Arduino like pin number (Pin) to GPIO port. More...
 
#define MIN(a, b)   (((a)<(b))?(a):(b))
 Compares 2 values and returns lower one. More...
 
#define MAX(a, b)   (((a)>(b))?(a):(b))
 Compares 2 values and returns higher one. More...
 
#define Abs(a)   (((a)>=0)?(a):-(a))
 Absolute value of number. More...
 
#define lowByte(w)   ((w) & 0xFF)
 Extracts the low-order (rightmost) byte of a variable (e.g. More...
 
#define highByte(w)   (((w) >> 8) & 0xFF)
 Extracts the high-order (leftmost) byte of a word (or the second lowest byte of a larger data type). More...
 
#define bitRead(value, bit)   (((value) >> (bit)) & 0x01)
 Reads a bit of a number. More...
 
#define bitSet(value, bit)   ((value) |= (1UL << (bit)))
 Sets (writes a 1 to) a bit of a numeric variable. More...
 
#define bitClear(value, bit)   ((value) &= ~(1UL << (bit)))
 Clears (writes a 0 to) a bit of a numeric variable. More...
 
#define bitWrite(value, bit, bitvalue)
 Writes a bit of a numeric variable. More...
 
#define bit(b)   (1UL << (b))
 Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.). More...
 
#define millis()   HAL_GetTick()
 Returns the number of milliseconds passed since the STM board began running the current program. More...
 
#define delay(millis)   HAL_Delay(millis)
 Pauses the program for the amount of time (in milliseconds) specified as parameter. More...
 
#define WAIT_US_CALIBRATION   (18)
 
#define cli()   __disable_irq()
 
#define noInterrupts()   cli()
 Disables interrupts (you can re-enable them with interrupts()). More...
 
#define sei()   __enable_irq()
 
#define interrupts()   sei()
 Re-enables interrupts (after they’ve been disabled by noInterrupts(). More...
 
#define HIGH   0x1
 HIGH pin state, same as 1. More...
 
#define LOW   0x0
 LOW pin state, same as 0. More...
 
#define LSBFIRST   0
 Least Significant Bit First. More...
 
#define MSBFIRST   1
 Most Significant Bit First. More...
 
#define CHANGE   1
 GPIO interrupt will be triggered when pin state change. More...
 
#define FALLING   2
 GPIO interrupt will be triggered when pin state change from HIGH to LOW. More...
 
#define RISING   3
 GPIO interrupt will be triggered when pin state change from LOW to HIGH. More...
 
#define RESET_CAUSE_POWER_ON_POWER_DOWN_RESET   RESET_CAUSE_EXTERNAL_RESET_PIN_RESET
 Power-ON reset, Power-DOWN reset cause. More...
 

Typedefs

typedef enum WiringPinMode WiringPinMode
 
typedef enum reset_cause_e ResetCause
 Possible STM32 system reset causes. More...
 

Enumerations

enum  WiringPinMode {
  OUTPUT, OUTPUT_OPEN_DRAIN, INPUT, INPUT_ANALOG,
  INPUT_PULLUP, INPUT_PULLDOWN, INPUT_FLOATING
}
 Pin mode enumerations. More...
 
enum  reset_cause_e {
  RESET_CAUSE_UNKNOWN = 0, RESET_CAUSE_LOW_POWER_RESET = 1, RESET_CAUSE_WINDOW_WATCHDOG_RESET = 2, RESET_CAUSE_INDEPENDENT_WATCHDOG_RESET = 3,
  RESET_CAUSE_SOFTWARE_RESET = 4, RESET_CAUSE_EXTERNAL_RESET_PIN_RESET = 6, RESET_CAUSE_BROWNOUT_RESET = 7
}
 Possible STM32 system reset causes. More...
 

Functions

bool pinExists (GPIO_TypeDef *GPIOx, uint16_t PPin)
 Checks if pin is available on MCU. More...
 
bool pinExists (uint8_t Pin)
 Checks if pin is available on MCU. More...
 
bool enableGPIO (GPIO_TypeDef *GPIOx, bool enable)
 Enables/Disables GPIO port periphery. More...
 
uint8_t PortAndPinToPinNum (GPIO_TypeDef *GPIOx, uint16_t PPin)
 Converts GPIOx port and it's pin to Arduino like pin number. More...
 
bool canSetInterruptOnPin (uint8_t Pin)
 Checks if EXTI line, that belongs to Pin is not used by other pin's interrupt. More...
 
GPIO_TypeDef * getInterruptGPIOfromPin (uint16_t Pin)
 Gets, what GPIO is attached to EXTI line, that belongs to PPin. More...
 
bool isInterruptSetOnPin (uint8_t Pin)
 Checks Pin is used as interrupt. More...
 
uint8_t pinMode (GPIO_TypeDef *GPIOx, uint16_t PPin, WiringPinMode mode, uint32_t speed)
 Sets mode of selected pin. More...
 
void digitalWrite (GPIO_TypeDef *GPIOx, uint16_t PPin, bool val)
 Writes new state to pin or multiple pins. More...
 
uint16_t digitalRead (GPIO_TypeDef *GPIOx, uint16_t PPin)
 Reads state of pin or multiple pins. More...
 
void digitalToggle (GPIO_TypeDef *GPIOx, uint16_t PPin)
 Toggles pin state. More...
 
uint8_t pinMode (uint8_t Pin, WiringPinMode mode, uint32_t speed)
 Sets mode of selected pin. More...
 
uint8_t pinMode (uint8_t Pin, WiringPinMode mode)
 Sets mode of selected pin. More...
 
void digitalWrite (uint8_t Pin, bool val)
 Writes new state to pin. More...
 
bool digitalRead (uint8_t Pin)
 Reads state of pin. More...
 
void digitalToggle (uint8_t Pin)
 Toggles state of pin. More...
 
int8_t attachInterrupt (uint8_t Pin, std::function< void(void)>, int mode)
 Attaches interrupt to selected pin. More...
 
int8_t detachInterrupt (uint8_t Pin, bool disableEXTIwhenNotUsed=false)
 Detaches interrupt from selected pin and sets pin mode to INPUT. More...
 
void InterruptHandler (uint8_t lineFrom, uint8_t lineTo)
 Include this in every EXTI interrupt handler for lines 0-15. More...
 
int8_t isPinUsedByInt (uint8_t INTPPin)
 Checks if pin is not used for interrupt. More...
 
uint32_t getPinPullSetting (GPIO_TypeDef *GPIOx, uint8_t INTPin)
 This function should return actual pin pull setting (GPIO_NOPULL, GPIO_PULLUP, GPIO_PULLDOWN) More...
 
uint32_t getPinSpeedSetting (GPIO_TypeDef *GPIOx, uint8_t INTPin)
 This should return actual pin toggle speed setting. More...
 
bool WirishInit (void)
 Initializes some wirish functions. More...
 
void __attribute__ ((optimize("Ofast"))) delayMicrosecondsDWT(uint32_t microseconds)
 Pauses the program for the amount of time (in microseconds) specified as parameter. More...
 
unsigned long random (unsigned long from, unsigned long to)
 The random function generates pseudo-random numbers. More...
 
unsigned long random (unsigned long to)
 The random function generates pseudo-random numbers. More...
 
void randomSeed (unsigned long seed)
 Initializes the pseudo-random number generator, causing it to start at an arbitrary point in its random sequence. More...
 
const char * getResetCauseName ()
 Gets the system reset cause as an ASCII-printable name string from a reset cause type. More...
 
ResetCause getResetCause ()
 Reads the STM32 system reset cause. More...
 
void getDeviceLOTID (char *buffer)
 Returns device LOT ID as text. More...
 
uint8_t getDeviceWAFID ()
 Gets device wafer plate ID. More...
 
uint16_t getDeviceWAFX ()
 Returns device wafer plate X coordination. More...
 
uint16_t getDeviceWAFY ()
 Gets device wafer plate Y coordination. More...
 
uint32_t getFlashSize ()
 Gets flash size in bytes. More...
 

Variables

GPIO_TypeDef * GPIO_Conversion_Table []
 
ResetCause rst_cs
 

Detailed Description

This file contains basic (Arduino like) GPIO manipulation functions, delay, random, etc.

Macro Definition Documentation

◆ W_INT_HANDLING_MODE

#define W_INT_HANDLING_MODE   2

Interrupt GPIO handling mode.

◆ W_OK

#define W_OK   1

Wirish status OK.

◆ W_BAD_ARG

#define W_BAD_ARG   -1

Wirish status Bad Arguments.

◆ W_ERR

#define W_ERR   0

Wirish status Error.

◆ PIN_TO_PORT_PIN

#define PIN_TO_PORT_PIN (   Pin)    (0x01 << ((Pin)&0x0F))

Converts Arduino like pin number (Pin) to Pin of port (PPin).

Parameters
PinArduino like pin number.
Returns
Returns pin of port (PPin).

◆ PIN_TO_PORT

#define PIN_TO_PORT (   Pin)    (GPIO_Conversion_Table[(Pin)>>4])

Converts Arduino like pin number (Pin) to GPIO port.

Parameters
PinArduino like pin number.
Returns
Returns GPIO port (GPIO_TypeDef).

◆ MIN

#define MIN (   a,
 
)    (((a)<(b))?(a):(b))

Compares 2 values and returns lower one.

Parameters
aFirst value
bSecond value
Returns
Returns lower one value.

◆ MAX

#define MAX (   a,
 
)    (((a)>(b))?(a):(b))

Compares 2 values and returns higher one.

Parameters
aFirst value
bSecond value
Returns
Returns higher one value.

◆ Abs

#define Abs (   a)    (((a)>=0)?(a):-(a))

Absolute value of number.

Parameters
avalue
Returns
Returns absolute value.

◆ lowByte

#define lowByte (   w)    ((w) & 0xFF)

Extracts the low-order (rightmost) byte of a variable (e.g.

a word).

Parameters
wA value of any type.
Returns
Returns low-order (rightmost) byte.

◆ highByte

#define highByte (   w)    (((w) >> 8) & 0xFF)

Extracts the high-order (leftmost) byte of a word (or the second lowest byte of a larger data type).

Parameters
wA value of any type.
Returns
Returns high-order (leftmost) byte.

◆ bitRead

#define bitRead (   value,
  bit 
)    (((value) >> (bit)) & 0x01)

Reads a bit of a number.

Parameters
valueThe number from which to read.
bitWhich bit to read, starting at 0 for the least-significant (rightmost) bit.
Returns
Returns read bit.

◆ bitSet

#define bitSet (   value,
  bit 
)    ((value) |= (1UL << (bit)))

Sets (writes a 1 to) a bit of a numeric variable.

Parameters
valueThe numeric variable whose bit to set.
bitWhich bit to set, starting at 0 for the least-significant (rightmost) bit.
Returns
Returns new value.

◆ bitClear

#define bitClear (   value,
  bit 
)    ((value) &= ~(1UL << (bit)))

Clears (writes a 0 to) a bit of a numeric variable.

Parameters
valueThe numeric variable whose bit to set.
bitWhich bit to clear, starting at 0 for the least-significant (rightmost) bit.
Returns
Returns new value.

◆ bitWrite

#define bitWrite (   value,
  bit,
  bitvalue 
)
Value:
(bitvalue ? bitSet(value, bit) : \
bitClear(value, bit))

Writes a bit of a numeric variable.

Parameters
valueThe numeric variable to which to write.
bitWhich bit of the number to write, starting at 0 for the least-significant (rightmost) bit.
bitvalueThe value to write to the bit (0 or 1).
Returns
Returns new value.

◆ bit

#define bit (   b)    (1UL << (b))

Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.).

Parameters
bThe bit whose value to compute
Returns
The value of the bit.

◆ millis

#define millis ( )    HAL_GetTick()

Returns the number of milliseconds passed since the STM board began running the current program.

This number will overflow (go back to zero), after approximately 50 days.

Returns
Number of milliseconds passed since the program started.
Examples
HarwareSerialExample, and Wirish.

◆ delay

#define delay (   millis)    HAL_Delay(millis)

Pauses the program for the amount of time (in milliseconds) specified as parameter.

(There are 1000 milliseconds in a second.)

Parameters
millisThe number of milliseconds to pause.
Examples
HarwareSerialExample, HarwareSPIExample, and Wirish.

◆ WAIT_US_CALIBRATION

#define WAIT_US_CALIBRATION   (18)

◆ cli

#define cli ( )    __disable_irq()

◆ noInterrupts

#define noInterrupts ( )    cli()

Disables interrupts (you can re-enable them with interrupts()).

Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code.

◆ sei

#define sei ( )    __enable_irq()

◆ interrupts

#define interrupts ( )    sei()

Re-enables interrupts (after they’ve been disabled by noInterrupts().

Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code.

◆ HIGH

#define HIGH   0x1

HIGH pin state, same as 1.

Examples
HarwareSPIExample.

◆ LOW

#define LOW   0x0

LOW pin state, same as 0.

Examples
HarwareSPIExample.

◆ LSBFIRST

#define LSBFIRST   0

Least Significant Bit First.

◆ MSBFIRST

#define MSBFIRST   1

Most Significant Bit First.

◆ CHANGE

#define CHANGE   1

GPIO interrupt will be triggered when pin state change.

See also
attachInterrupt()
Examples
Wirish.

◆ FALLING

#define FALLING   2

GPIO interrupt will be triggered when pin state change from HIGH to LOW.

See also
attachInterrupt()

◆ RISING

#define RISING   3

GPIO interrupt will be triggered when pin state change from LOW to HIGH.

See also
attachInterrupt()

◆ RESET_CAUSE_POWER_ON_POWER_DOWN_RESET

#define RESET_CAUSE_POWER_ON_POWER_DOWN_RESET   RESET_CAUSE_EXTERNAL_RESET_PIN_RESET

Power-ON reset, Power-DOWN reset cause.

Typedef Documentation

◆ WiringPinMode

◆ ResetCause

typedef enum reset_cause_e ResetCause

Possible STM32 system reset causes.

Enumeration Type Documentation

◆ WiringPinMode

Pin mode enumerations.

Enumerator
OUTPUT 

Basic digital output: when the pin is HIGH, the voltage is held at +3.3v (Vcc) and when it is LOW, it is pulled down to ground.

OUTPUT_OPEN_DRAIN 

In open drain mode, the pin indicates "low" by accepting current flow to ground and "high" by providing increased impedance.

An example use would be to connect a pin to a bus line (which is pulled up to a positive voltage by a separate supply through a large resistor). When the pin is high, not much current flows through to ground and the line stays at positive voltage; when the pin is low, the bus "drains" to ground with a small amount of current constantly flowing through the large resistor from the external supply. In this mode, no current is ever actually sourced from the pin.

INPUT 

Basic digital input.

The pin voltage is sampled; when it is closer to 3.3v (Vcc) the pin status is high, and when it is closer to 0v (ground) it is low. If no external circuit is pulling the pin voltage to high or low, it will tend to randomly oscillate and be very sensitive to noise (e.g., a breath of air across the pin might cause the state to flip).

INPUT_ANALOG 

This is a special mode for when the pin will be used for analog (not digital) reads.

Enables ADC conversion to be performed on the voltage at the pin.

INPUT_PULLUP 

The state of the pin in this mode is reported the same way as with INPUT, but the pin voltage is gently "pulled up" towards +3.3v.

This means the state will be high unless an external device is specifically pulling the pin down to ground, in which case the "gentle" pull up will not affect the state of the input.

INPUT_PULLDOWN 

The state of the pin in this mode is reported the same way as with INPUT, but the pin voltage is gently "pulled down" towards 0v.

This means the state will be low unless an external device is specifically pulling the pin up to 3.3v, in which case the "gentle" pull down will not affect the state of the input.

INPUT_FLOATING 

Synonym for INPUT.

◆ reset_cause_e

Possible STM32 system reset causes.

Enumerator
RESET_CAUSE_UNKNOWN 

Unknown reset cause.

RESET_CAUSE_LOW_POWER_RESET 

Low power reset cause.

RESET_CAUSE_WINDOW_WATCHDOG_RESET 

Window watchdog reset cause.

RESET_CAUSE_INDEPENDENT_WATCHDOG_RESET 

Independent watchdog reset cause.

RESET_CAUSE_SOFTWARE_RESET 

Software reset cause.

RESET_CAUSE_EXTERNAL_RESET_PIN_RESET 

External reset pin reset cause.

RESET_CAUSE_BROWNOUT_RESET 

Brownout reset cause.

Function Documentation

◆ pinExists() [1/2]

bool pinExists ( GPIO_TypeDef *  GPIOx,
uint16_t  PPin 
)

Checks if pin is available on MCU.

Parameters
GPIOxGPIO port periphery.
PPinPin of that port to convert (GPIO_PIN_0, GPIO_PIN_1, ...). Do not use combined pins (e.g. GPIO_PIN_0 | GPIO_PIN_1)
Returns
Returns true if pin is available on MCU.

◆ pinExists() [2/2]

bool pinExists ( uint8_t  Pin)

Checks if pin is available on MCU.

Parameters
PinArduino like pin number.
Returns
Returns true if pin is available on MCU.
Here is the call graph for this function:

◆ enableGPIO()

bool enableGPIO ( GPIO_TypeDef *  GPIOx,
bool  enable 
)

Enables/Disables GPIO port periphery.

Parameters
GPIOxGPIO port periphery.
enableIf true, periphery will be enabled, else disabled.
Returns
Returns true when GPIO periphery was enabled successfully.

◆ PortAndPinToPinNum()

uint8_t PortAndPinToPinNum ( GPIO_TypeDef *  GPIOx,
uint16_t  PPin 
)

Converts GPIOx port and it's pin to Arduino like pin number.

Parameters
GPIOxGPIO port.
PPinPin of that port to convert (GPIO_PIN_0, GPIO_PIN_1, ...). Do not use combined pins (e.g. GPIO_PIN_0 | GPIO_PIN_1)
Returns
Returns Arduino like pin number (Pin).

◆ canSetInterruptOnPin()

bool canSetInterruptOnPin ( uint8_t  Pin)

Checks if EXTI line, that belongs to Pin is not used by other pin's interrupt.

Parameters
PinArduino like pin number.
Returns
Returns true if you can set interrupt on Pin.
Here is the call graph for this function:

◆ getInterruptGPIOfromPin()

GPIO_TypeDef* getInterruptGPIOfromPin ( uint16_t  Pin)

Gets, what GPIO is attached to EXTI line, that belongs to PPin.

Parameters
PinArduino like pin number.
Returns
Returns pointer to GPIO_TypeDef which is attached to EXTI line, that belongs to PPin. It can return NULL when no interrupt is attached at EXTI line, that belongs to PPin.

◆ isInterruptSetOnPin()

bool isInterruptSetOnPin ( uint8_t  Pin)

Checks Pin is used as interrupt.

Parameters
PinArduino like pin number.
Returns
Returns true Pin is used as interrupt.
Note
This function looks same as negation of canSetInterruptOnPin(), but there is big difference. Assume we have attached interrupt on pin PA1:
//GPIOA
bool val = !canSetInterruptOnPin(PA1) // val == true
bool val = isInterruptSetOnPin(PA1) // val == true
//GPIOB
bool val = !canSetInterruptOnPin(PB1) // val == true
bool val = isInterruptSetOnPin(PB1) // val == false
Here is the call graph for this function:

◆ pinMode() [1/3]

uint8_t pinMode ( GPIO_TypeDef *  GPIOx,
uint16_t  PPin,
WiringPinMode  mode,
uint32_t  speed 
)

Sets mode of selected pin.

Parameters
GPIOxGPIO port.
PPinPin of that port (GPIO_PIN_0, GPIO_PIN_1, ...).
modePin mode that will be set.
See also
WiringPinMode
Parameters
speedToggle speed of pin. Available values: GPIO_SPEED_FREQ_LOW, GPIO_SPEED_FREQ_MEDIUM, GPIO_SPEED_FREQ_HIGH, GPIO_SPEED_FREQ_VERY_HIGH (only some MCUs supports this speed setting))
Returns
W_OK when pin is successfully set.
Examples
HarwareSerialExample, and Wirish.
Here is the call graph for this function:

◆ digitalWrite() [1/2]

void digitalWrite ( GPIO_TypeDef *  GPIOx,
uint16_t  PPin,
bool  val 
)
inline

Writes new state to pin or multiple pins.

Parameters
GPIOxGPIO port.
PPinPin of that port (GPIO_PIN_0, GPIO_PIN_1, ...).
valBoolean state that will be written to the pin or multiple pins on same GPIO port.
Examples
HarwareSPIExample, and Wirish.

◆ digitalRead() [1/2]

uint16_t digitalRead ( GPIO_TypeDef *  GPIOx,
uint16_t  PPin 
)
inline

Reads state of pin or multiple pins.

Parameters
GPIOxGPIO port.
PPinPin of that port (GPIO_PIN_0, GPIO_PIN_1, ...).
Returns
Bool state of pin or multiple pins on same GPIO port.
Examples
Wirish.

◆ digitalToggle() [1/2]

void digitalToggle ( GPIO_TypeDef *  GPIOx,
uint16_t  PPin 
)
inline

Toggles pin state.

Parameters
GPIOxGPIO port.
PPinPin of that port (GPIO_PIN_0, GPIO_PIN_1, ...).
Examples
HarwareSerialExample, and Wirish.

◆ pinMode() [2/3]

uint8_t pinMode ( uint8_t  Pin,
WiringPinMode  mode,
uint32_t  speed 
)

Sets mode of selected pin.

Parameters
PinArduino like pin number.
modePin mode that will be set.
See also
WiringPinMode
Parameters
speedToggle speed of pin. Available values: GPIO_SPEED_FREQ_LOW, GPIO_SPEED_FREQ_MEDIUM, GPIO_SPEED_FREQ_HIGH, GPIO_SPEED_FREQ_VERY_HIGH (only some MCUs supports this speed setting))
Returns
W_OK when pin is successfully set.
Here is the call graph for this function:

◆ pinMode() [3/3]

uint8_t pinMode ( uint8_t  Pin,
WiringPinMode  mode 
)
inline

Sets mode of selected pin.

Parameters
PinArduino like pin number.
modePin mode that will be set.
See also
WiringPinMode
Returns
W_OK when pin is successfully set.
Here is the call graph for this function:

◆ digitalWrite() [2/2]

void digitalWrite ( uint8_t  Pin,
bool  val 
)
inline

Writes new state to pin.

Parameters
PinArduino like pin number.
valBoolean state that will be written to the pin.

◆ digitalRead() [2/2]

bool digitalRead ( uint8_t  Pin)
inline

Reads state of pin.

Parameters
PinArduino like pin number.
Returns
Boolean state of pin.

◆ digitalToggle() [2/2]

void digitalToggle ( uint8_t  Pin)
inline

Toggles state of pin.

Parameters
PinArduino like pin number.
Here is the call graph for this function:

◆ attachInterrupt()

int8_t attachInterrupt ( uint8_t  Pin,
std::function< void(void)>  ,
int  mode 
)

Attaches interrupt to selected pin.

Parameters
PinArduino like pin.
handlerFunction, that will be called when interrupt is triggered.
modeMode of interrupt (RISING, FALLING, CHANGE).
Note
Every STM MCU has only 16 EXTI lines. Every line is connected to pins with same PPin number on every GPIO. It means, you cannot attach interrupt to pin PA1 and PB1 at same time. You have to choose another pin, for example PB2 or PA2.
When you attach interrupt on some pin, it will be set to INPUT mode automatically.
Returns
W_OK when interrupt was attached successfully.
Examples
Wirish.
Here is the call graph for this function:

◆ detachInterrupt()

int8_t detachInterrupt ( uint8_t  Pin,
bool  disableEXTIwhenNotUsed = false 
)

Detaches interrupt from selected pin and sets pin mode to INPUT.

Parameters
PinArduino like pin number.
disableEXTIwhenNotUsedTrue if you want to disable group of EXTI lines when they are not used yet. It can save energy, but it can also disable GPIO interrupt, that is set using .ioc file.
Note
When you detach interrupt on some pin, it will be set to INPUT mode automatically.
Returns
W_OK when interrupt was detached successfully.
Here is the call graph for this function:

◆ InterruptHandler()

void InterruptHandler ( uint8_t  lineFrom,
uint8_t  lineTo 
)

Include this in every EXTI interrupt handler for lines 0-15.

Parameters
lineFromSpecify first handler line
lineToSpecify last handler line
See also
interrupt.h

◆ isPinUsedByInt()

int8_t isPinUsedByInt ( uint8_t  INTPPin)

Checks if pin is not used for interrupt.

It also check if pin with same number on different port is not used for interrupt. (e.g. when port PA01 is interrupt, ports PB01, PC01, PD01,... cannot be used as interrupt.

Parameters
INTPPinArduino like pin number or INTPin number (0-15).
Returns
Returns false when interrupt can be used for that port.

◆ getPinPullSetting()

uint32_t getPinPullSetting ( GPIO_TypeDef *  GPIOx,
uint8_t  INTPin 
)

This function should return actual pin pull setting (GPIO_NOPULL, GPIO_PULLUP, GPIO_PULLDOWN)

Parameters
GPIOxGPIO port.
INTPinInterrupt pin number (0-15).
Note
On some MCUs, when pin mode is set to OUTPUT, pull register is cleared and this method returns always GPIO_NOPULL.
Returns
Actual pin pull setting (GPIO_NOPULL, GPIO_PULLUP, GPIO_PULLDOWN).

◆ getPinSpeedSetting()

uint32_t getPinSpeedSetting ( GPIO_TypeDef *  GPIOx,
uint8_t  INTPin 
)

This should return actual pin toggle speed setting.

Parameters
GPIOxGPIO port.
INTPinInterrupt pin number (0-15).
Note
On some MCUs, when pin mode is set to INPUT, speed register is cleared and this method returns always GPIO_SPEED_FREQ_LOW.
Returns
Actual pin toggle speed setting.

◆ WirishInit()

bool WirishInit ( void  )

Initializes some wirish functions.

Note
This method is automatically called before main method, so you don't have to include it in your program.
Returns
Returns true when initialization was done correctly.

◆ __attribute__()

uint64_t __attribute__ ( (optimize("Ofast"))  )
inline

Pauses the program for the amount of time (in microseconds) specified as parameter.

Returns the number of microseconds since the MCU began running the current program.

(There are 1 million microseconds in a second.) Main advantage of this function is, that any interrupt does not stop delay counter. Main disadvantage is that it's resolution is not as good as delayMicroseconds resolution and also calculation takes more time.

Parameters
microsecondsThe number of microseconds to pause.
Note
Minimum possible pause time, when system core clock is set to 4MHz is 5.25 µs (21 ticks).
This function can be used only when your MCU supports DWT.

(There are 1 million microseconds in a second.) Main advantage of this function is, that it have really good resolution (only 3 ticks) and fast calculation time (around 23 ticks). Main disadvantage is that interrupt can extend delay time, when code is interrupted during delay.

Parameters
microsecondsThe number of microseconds to pause.
Note
Minimum possible pause time, when system core clock is set to 4MHz is 5.25 µs (21 ticks).
Warning
This functions works properly only when SysTick timer ticks every 1ms (default setting by HAL library).
Note
Whole method takes around 44 ticks. 4MHz => 11us
Warning
This functions works properly only when SysTick timer ticks every 1ms (default setting by HAL library).
This functions works properly only when SysTick timer ticks every 1ms (default setting by HAL library).
Returns
Returns the number of microseconds since the MCU began running the current program as 64 bit number. This value also overflows at same time as millis() method (around 49 days)

◆ random() [1/2]

unsigned long random ( unsigned long  from,
unsigned long  to 
)

The random function generates pseudo-random numbers.

Parameters
fromLower bound of the random value, inclusive (optional).
toUpper bound of the random value, exclusive.
Returns
A random number between from and to-1 or professionally said random number in interval <from,to).
Examples
HarwareSerialExample.

◆ random() [2/2]

unsigned long random ( unsigned long  to)

The random function generates pseudo-random numbers.

Parameters
toUpper bound of the random value, exclusive.
Returns
A random number between 0 and to-1 or professionally said random number in interval <0,to).
Here is the call graph for this function:

◆ randomSeed()

void randomSeed ( unsigned long  seed)

Initializes the pseudo-random number generator, causing it to start at an arbitrary point in its random sequence.

This sequence, while very long, and random, is always the same.

Parameters
seedNumber to initialize the pseudo-random sequence.

◆ getResetCauseName()

const char* getResetCauseName ( )

Gets the system reset cause as an ASCII-printable name string from a reset cause type.

Parameters
reset_causeThe previously-obtained system reset cause
Returns
A null-terminated ASCII name string describing the system reset cause

◆ getResetCause()

ResetCause getResetCause ( )
inline

Reads the STM32 system reset cause.

Returns
Returns the system reset cause.

◆ getDeviceLOTID()

void getDeviceLOTID ( char *  buffer)
inline

Returns device LOT ID as text.

Parameters
Pointerto buffer, where LOT ID will be copied. Buffer has to be 8 bytes long.

◆ getDeviceWAFID()

uint8_t getDeviceWAFID ( )
inline

Gets device wafer plate ID.

Returns
Returns device wafer plate ID.

◆ getDeviceWAFX()

uint16_t getDeviceWAFX ( )
inline

Returns device wafer plate X coordination.

Returns
Returns device wafer plate X coordination.

◆ getDeviceWAFY()

uint16_t getDeviceWAFY ( )
inline

Gets device wafer plate Y coordination.

Returns
Returns device wafer plate Y coordination.

◆ getFlashSize()

uint32_t getFlashSize ( )
inline

Gets flash size in bytes.

Returns
Returns flash size in bytes.

Variable Documentation

◆ GPIO_Conversion_Table

GPIO_TypeDef* GPIO_Conversion_Table[]

◆ rst_cs

ResetCause rst_cs
bitClear
#define bitClear(value, bit)
Clears (writes a 0 to) a bit of a numeric variable.
Definition: wirish.h:827
bit
#define bit(b)
Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.).
Definition: wirish.h:844
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
bitSet
#define bitSet(value, bit)
Sets (writes a 1 to) a bit of a numeric variable.
Definition: wirish.h:819
isInterruptSetOnPin
bool isInterruptSetOnPin(uint8_t Pin)
Checks Pin is used as interrupt.
Definition: wirish.cpp:557