From 92c50db2b05818157d46e09f4dec4fa1e96f960b Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 16 Jan 2018 00:02:56 -0700 Subject: able to set the clock speed in MHz. --- system-clock/src/spin.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'system-clock/src/spin.c') 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); } } -- cgit