diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2018-01-16 00:02:56 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2018-01-16 00:02:56 -0700 |
commit | 92c50db2b05818157d46e09f4dec4fa1e96f960b (patch) | |
tree | c264b9d183e9c69fb8434712347a5680a41edf3a /system-clock/src/spin.c | |
parent | 6d3197d768bf13c1402c1305050ea355f8c79fec (diff) | |
download | stm32l4-92c50db2b05818157d46e09f4dec4fa1e96f960b.tar.gz stm32l4-92c50db2b05818157d46e09f4dec4fa1e96f960b.tar.bz2 stm32l4-92c50db2b05818157d46e09f4dec4fa1e96f960b.zip |
able to set the clock speed in MHz.
Diffstat (limited to 'system-clock/src/spin.c')
-rw-r--r-- | system-clock/src/spin.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/system-clock/src/spin.c b/system-clock/src/spin.c index f233054..f17f678 100644 --- a/system-clock/src/spin.c +++ b/system-clock/src/spin.c @@ -6,20 +6,21 @@ #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(LONG_DELAY); + delay(base * 2); } else { - delay(SHORT_DELAY); + delay(base); } pin_off(out_pin); - delay(SHORT_DELAY); + delay(base); } -void spin(uint8_t c) +void spin(uint32_t base, uint8_t c) { uint8_t code; __IO gpio_port_t* port_b = enable_gpio(GPIO_PORT_B); @@ -27,24 +28,24 @@ void spin(uint8_t c) for(;;) { code = c; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); code <<= 1; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); code <<= 1; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); code <<= 1; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); code <<= 1; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); code <<= 1; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); code <<= 1; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); code <<= 1; - flash_bit(pin3, code & 0x80); + flash_bit(base, pin3, code & 0x80); - delay(LONG_DELAY * 4); + delay(base * 4); } } |