HWA
Bare metal programming with style
hwa/st/stm32/examples/03-1-systick/main.c

This program blinks a LED using the SysTick timer.

main.c
/* This file is part of the HWA project.
* Copyright (c) 2017 Christophe Duparquet.
* All rights reserved. Read LICENSE.TXT for details.
*/
#include BOARD_H
#define AHBHZ HW_DEVICE_HSIHZ // The HSI runs at 8 MHz
#define PERIOD 0.5 // Blinking period
int main ( )
{
hwa( begin, reset );
/* Configure the GPIO pin
*/
hwa( power, (LED,port), on );
hwa( commit );
hwa( configure, LED,
mode, digital_output,
frequency, lowest );
/* Configure the system tick timer
*/
hwa( configure, systick,
clock, ahb/8,
reload, PERIOD/2 * AHBHZ/8 - 1,
run, yes );
hwa( commit );
for(;;) {
if ( hw( read, (systick,irq) ) ) /* Reading the flag clears it */
hw( toggle, LED );
}
}
hwa
#define hwa(...)
hwa( action, object [,...] ) stores an action for an object into a HWA context.
Definition: hwa_macros.h:552
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523
LED
#define LED
X.
Definition: bluepill.h:55