diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2018-01-23 23:14:31 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2018-01-23 23:14:31 -0700 |
commit | 7aa10db46c13ad8adc88aadff39b8cf6b15db09d (patch) | |
tree | b1e34a6703de33250b0bd97d34999b687a36a00f /01-system-clock/src/main.c | |
parent | acd8afd83da625d36ef39bc01717f29f3b689952 (diff) | |
download | stm32l4-7aa10db46c13ad8adc88aadff39b8cf6b15db09d.tar.gz stm32l4-7aa10db46c13ad8adc88aadff39b8cf6b15db09d.tar.bz2 stm32l4-7aa10db46c13ad8adc88aadff39b8cf6b15db09d.zip |
rename folders to give notion of progression
Diffstat (limited to '01-system-clock/src/main.c')
-rw-r--r-- | 01-system-clock/src/main.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/01-system-clock/src/main.c b/01-system-clock/src/main.c new file mode 100644 index 0000000..7912bf2 --- /dev/null +++ b/01-system-clock/src/main.c @@ -0,0 +1,36 @@ +#include "clock.h" +#include "delay.h" +#include "gpio.h" +#include "spin.h" + +volatile uint32_t delay_amt = 20000000 / 4; + +/* Main function. This gets executed from the interrupt vector defined above. */ +int main() +{ + /* Enable the GPIO port B. */ + + __IO gpio_port_t* port_b = enable_gpio(GPIO_PORT_B); + gpio_output_pin_t pin3 = set_gpio_pin_output(port_b, PIN_3); + gpio_output_pin_t pin1 = set_gpio_pin_output(port_b, PIN_1); + + /* Enable a higher clock frequency. */ + set_system_clock_MHz(80); + + uint32_t count = 0; + while (1) { + /* Set the GPIO pin to high. */ + pin_off(pin1); + pin_off(pin3); + delay(delay_amt); + + /* Set the GPIO pin to low. */ + if (count % 4 == 0) { + pin_on(pin1); + } + pin_on(pin3); + delay(delay_amt); + + ++count; + } +} |