1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
4 * 2019/7/25 - ROBIN KRENS
8 * Hardly a driver, but a driver nonetheless. Enables clock on
9 * a GPIOx range and sets the GPIOx pin in push-pull output mode.
10 * Basic on - off function (writing a 1 or zero 0)
13 * In the code below we enable GPIOC and use PC0 as output. But
14 * basically any GPIO range or pin could be used. Note that the
15 * output register is only word accessible.
24 #include <sys/robsys.h>
26 #include <lib/regfunc.h>
27 #include <lib/string.h>
29 #include <drivers/led.h>
34 regw_u8(RCC_APB2ENR, 0x1, 4, SETBIT); // enable GPIOC
35 regw_u32(GPIOC_CRL, 0x44444442, 0, OWRITE); // set PC0 pin to output mode
36 *GPIOC_ODR = 0xFFFF; // only writable in word mode