The Hardware Abstraction Layer for STM32F1 microcontrollers defines utilities to make code more portable across several architecture variations.
: 72MHz ( -- ) \ set the main clock to 72 MHz, keep baud rate at 115200 : 8MHz ( -- ) \ set the main clock back to 8 MHz, keep baud rate at 115200
: systick-hz ( u -- ) \ enable systick interrupt at given frequency : micros ( -- n ) \ return elapsed microseconds, this wraps after some 2000s : millis ( -- u ) \ return elapsed milliseconds, this wraps after 49 days : us ( n -- ) \ microsecond delay using a busy loop, this won't switch tasks : ms ( n -- ) \ millisecond delay, multi-tasker aware (may switch tasks!)
: baud ( u -- u ) \ calculate baud rate divider, based on current clock rate : list ( -- ) \ list all words in dictionary, short form
: chipid ( -- u1 u2 u3 3 ) \ unique chip ID as N values on the stack : hwid ( -- u ) \ a "fairly unique" hardware ID as single 32-bit int : flash-kb ( -- u ) \ return size of flash memory in KB : flash-pagesize ( addr - u ) \ return size of flash page at given address
8000000 variable clock-hz \ the system clock is 8 MHz after reset