diff options
Diffstat (limited to '03-refactor/src/main.c')
-rw-r--r-- | 03-refactor/src/main.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/03-refactor/src/main.c b/03-refactor/src/main.c index 0545087..562fda9 100644 --- a/03-refactor/src/main.c +++ b/03-refactor/src/main.c @@ -73,21 +73,39 @@ int enable_usart1(uint32_t baud_rate) asm volatile(" cpsie i "); } +void dwn() { + int val = 19; + + while (val > 1) { + usart_printf(&USART2, "Value: 0x%02x\r\n", val); + if ((val & 1) == 0) { + val /= 2; + } else { + val = val * 3 + 1; + } + } + usart_printf(&USART2, "Value: 0x%02x\r\n", val); +} + /* 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); + // __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); enable_usart2(115200); - pin_on(pin3); - usart_transmit_str(&USART2, "Hello, World\n"); + // pin_on(pin3); + dwn(); + usart_printf(&USART2, "Hello, %d!\r\n", -15); for(;;); } + +void do_thing(void(*fn)()) { + fn(); +} |