Arduino Core for STM32  1.0
Wirish
  1. LED blinking
    #include "wirish.h"
    //Make sure, you have connected your LED in series with resistor and MCU pin.
    #define LED_PIN PA1 //LED is connected to pin PA1
    //This method have to be called in main function in main.c file
    void app(void)
    {
    //Setting pin mode of LED_PIN to OUTPUT
    pinMode(LED_PIN,OUTPUT);
    //Infinite loop
    while (1)
    {
    //Toggling pin status (where LED is connected) every 500ms.
    digitalToggle(LED_PIN);
    //Blocking processor for 500ms
    delay(500);
    }
    }
  2. NonBlocking LED blinking
    #include "wirish.h"
    //Make sure, you have connected your LED in series with resistor and MCU pin.
    #define LED_PIN PA1 //LED is connected to pin PA1
    unsigned long next_toggle_millis = 0;
    //This method have to be called in main function in main.c file
    void app(void)
    {
    //Setting pin mode of LED_PIN to OUTPUT
    pinMode(LED_PIN,OUTPUT);
    //Infinite loop
    while (1)
    {
    //Checking if milliseconds from program start exceeded next_toggle_millis value
    if(next_toggle_millis <= millis()){
    //Toggling pin status (where LED is connected) every 500ms.
    digitalToggle(LED_PIN);
    //Assigning new value to next_toggle_millis. The value is time in ms, when pin status will be toggled again.
    next_toggle_millis = millis() + 500; //milliseconds from program start + 500ms
    }
    //There you can call your function, while led is blinking.
    }
    }
  3. LED blinking with button
    #include "wirish.h"
    //Make sure, you have connected your LED in series with resistor and MCU pin.
    #define LED_PIN PA1 //LED is connected to pin PA1
    //Connection: PA1------LED-----100Ohm_RESISTOR------GND
    #define BUTTON_PIN PA2 //button is connected to pin PA2
    //Connection: PA2------BUTTON------3V3
    //This method have to be called in main function in main.c file
    void app(void)
    {
    //Setting pin mode of LED_PIN to OUTPUT
    pinMode(LED_PIN,OUTPUT);
    //Setting pin mode of BUTTON_PIN to INPUT_PULLDOWN
    //It will connects PULLDOWN resistor between BUTTON_PIN and GND
    pinMode(BUTTON_PIN,INPUT_PULLDOWN);
    //Infinite loop
    while (1)
    {
    //Reading button pin state
    bool buttonState = digitalRead(BUTTON_PIN);
    //Writing LED pin state
    digitalWrite(LED_PIN, buttonState);
    }
    }
  4. LED blinking with button using interrupts
    #include "wirish.h"
    //Make sure, you have connected your LED in series with resistor and MCU pin.
    #define LED_PIN PA1 //LED is connected to pin PA1
    //Connection: PA1------LED-----100Ohm_RESISTOR------GND
    #define BUTTON_PIN PA2 //button is connected to pin PA2
    //Connection: PA2------BUTTON------3V3
    //This function will be called when BUTTON_PIN state will change
    void buttonTouchedHandler(){
    //Reading button pin state
    bool buttonState = digitalRead(BUTTON_PIN);
    //Writing LED pin state
    digitalWrite(LED_PIN, buttonState);
    }
    //This method have to be called in main function in main.c file
    void app(void)
    {
    //Setting pin mode of LED_PIN to OUTPUT
    pinMode(LED_PIN,OUTPUT);
    //Setting pin mode of BUTTON_PIN to INPUT_PULLDOWN
    //It will connects PULLDOWN resistor between BUTTON_PIN and GND
    pinMode(BUTTON_PIN,INPUT_PULLDOWN);
    //Attaching interrupt to BUTTON_PIN, setting callback function and setting interrupt mode to CHANGE
    attachInterrupt(BUTTON_PIN, buttonTouchedHandler, CHANGE);
    //Infinite loop
    while (1)
    {
    //Nothing to do here
    }
    }
Note
Those examples works only with c++, but STM32CubeIDE does not allow you to change main.c to main.cpp, so you have to create own c++ file, and include it in main.h. In your cpp file create function, that will be called in main() function. In this case, function name is app() and is called in main() function between tags USER CODE BEGIN 2 and USER CODE END 2.
See also
Wirish documentation
wirish.h
WiringPinMode
millis
#define millis()
Returns the number of milliseconds passed since the STM board began running the current program.
Definition: wirish.h:851
delay
#define delay(millis)
Pauses the program for the amount of time (in milliseconds) specified as parameter.
Definition: wirish.h:860
CHANGE
#define CHANGE
GPIO interrupt will be triggered when pin state change.
Definition: wirish.h:1018
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
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
wirish.h
This file contains basic (Arduino like) GPIO manipulation functions, delay, random,...
pinMode
uint8_t pinMode(GPIO_TypeDef *GPIOx, uint16_t PPin, WiringPinMode mode, uint32_t speed)
Sets mode of selected pin.
Definition: wirish.cpp:250
digitalWrite
void digitalWrite(GPIO_TypeDef *GPIOx, uint16_t PPin, bool val)
Writes new state to pin or multiple pins.
Definition: wirish.h:626
digitalToggle
void digitalToggle(GPIO_TypeDef *GPIOx, uint16_t PPin)
Toggles pin state.
Definition: wirish.h:645
attachInterrupt
int8_t attachInterrupt(uint8_t Pin, std::function< void(void)>, int mode)
Attaches interrupt to selected pin.
Definition: wirish.cpp:669