HWA
Bare metal programming with style
hwa/st/stm32/examples/05-2-uart/main.c

Use of the UART.

main.c
/* This file is part of the HWA project.
* Copyright (c) 2021 Christophe Duparquet.
* All rights reserved. Read LICENSE.TXT for details.
*/
#include BOARD_H
#define AHBHZ HW_DEVICE_HSIHZ // AHB frequency
#define APBHZ AHBHZ
#define UART usart2
#define UART_TX (porta,2)
int main ( )
{
hwa( begin, reset );
/* Power the controllers we use
*/
/* hwa( power, (LED3,port), on ); */
hwa( power, (UART_TX,port), on );
hwa( power, UART, on );
hwa( commit );
hwa( configure, UART_TX, function, (UART,tx), mode, digital_output );
hwa( configure, UART,
mode, uart,
divider, AHBHZ/10000, // 10 kbps
/* clockhz, APBHZ, */
/* bps, 100000, */
/* tol, 0.01, */
databits, 8,
parity, none,
stopbits, 1,
receiver, off,
transmitter, on,
run, yes );
hwa( commit );
// Sleep between IRQs.
//
// for(;;) hw( wait, irq );
for (;;) {
while ( hw(read,(UART,txe)) != 1 ) {}
hw_waste_cycles( 0.003*AHBHZ );
hw( write, (UART,dr), '.' );
// hw( write, (UART,dr), '\x7F' );
// hw_waste_cycles( 0.02*AHBHZ );
// hw( toggle, UART_TX );
}
}
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
hw_waste_cycles
#define hw_waste_cycles(n)
Definition: hwa_2.h:98