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, (LED1,port), on );
hwa( commit );
hwa( configure, LED1,
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
LED1
#define LED1
X.
Definition: bluepill.h:56
LED
#define LED
X.
Definition: bluepill.h:55