diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-11-23 19:41:05 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-11-23 19:41:05 -0700 |
commit | 60b1e3055c179312eef809fe1d01f58042b64d5f (patch) | |
tree | c620b5ca1eab2d05c9396637db50d0a110328d29 /02-usart/src/kern/spin.c | |
parent | 2a6ae24ba769892993ec7a173c564f59feb06495 (diff) | |
download | stm32l4-60b1e3055c179312eef809fe1d01f58042b64d5f.tar.gz stm32l4-60b1e3055c179312eef809fe1d01f58042b64d5f.tar.bz2 stm32l4-60b1e3055c179312eef809fe1d01f58042b64d5f.zip |
Add new GPIO subsystem.
This gpio subsystem keeps track of the GPIO pins which
have been reserved and takes care of the housekeeping
with keeping them running.
This gpio subsystem also knows which alternate functions
belong to which pins, so it can automatically configure
the pins for the alternate functions.
Diffstat (limited to '02-usart/src/kern/spin.c')
-rw-r--r-- | 02-usart/src/kern/spin.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/02-usart/src/kern/spin.c b/02-usart/src/kern/spin.c deleted file mode 100644 index 7c4f6eb..0000000 --- a/02-usart/src/kern/spin.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "kern/spin.h" -#include "kern/delay.h" -#include "arch/stm32l4xxx/peripherals/gpio.h" - -#define SHORT_DELAY 200000 -#define LONG_DELAY (SHORT_DELAY * 2) - -static void flash_bit( - uint32_t base, gpio_output_pin_t out_pin, - uint8_t bit /* 0 => 0, non-zero => 1 */) -{ - pin_on(out_pin); - if (bit) { - delay(base * 2); - } else { - delay(base); - } - pin_off(out_pin); - delay(base); -} - -void spin(uint32_t base, uint8_t c) -{ - uint8_t code; - __IO gpio_port_t* port_b = enable_gpio(GPIO_PORT_B); - gpio_output_pin_t pin3 = set_gpio_pin_output(port_b, PIN_3); - - for (;;) { - code = c; - flash_bit(base, pin3, code & 0x80); - code <<= 1; - flash_bit(base, pin3, code & 0x80); - code <<= 1; - flash_bit(base, pin3, code & 0x80); - code <<= 1; - flash_bit(base, pin3, code & 0x80); - - code <<= 1; - flash_bit(base, pin3, code & 0x80); - code <<= 1; - flash_bit(base, pin3, code & 0x80); - code <<= 1; - flash_bit(base, pin3, code & 0x80); - code <<= 1; - flash_bit(base, pin3, code & 0x80); - - delay(base * 4); - } -} |