diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 41 |
1 files changed, 24 insertions, 17 deletions
@@ -5,6 +5,7 @@ #include "ch573/pwr.h" #include "ch573/uart.h" #include "clock.h" +#include "spi.h" #include "system.h" #define GPIO_PORT_A ch573_gpio__gpio_port_a @@ -124,28 +125,34 @@ static void fast_delay() */ int main(void) { - GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 8); - GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 8); - GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8); + printf("Running SPI.\n"); - GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 11); - GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 11); + enable_spi(); - GPIO_PORT.dir.set(GPIO_PORT_A, DIR_IN, 10); - GPIO_PORT.pd_drv.set(GPIO_PORT_A, PD_DRV_OPEN_DRAIN, 11); + run_spi(); - set_system_clock_6Mhz(); - uint32_t reg = (*(uint32_t*)0x40001008); - reg &= ~0x1f; - reg |= 10; - enter_safe_mode(); - (*(uint32_t*)0x40001008) = reg; + // GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 8); + // GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 8); + // GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8); + // GPIO_PORT.dir.set(GPIO_PORT_A, DIR_OUT, 11); + // GPIO_PORT.pd_drv.set(GPIO_PORT_A, 0, 11); - for (int i = 0;; ++i) { - GPIO_PORT.out.set(GPIO_PORT_A, ON, 8); - GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8); - } + // GPIO_PORT.dir.set(GPIO_PORT_A, DIR_IN, 10); + // GPIO_PORT.pd_drv.set(GPIO_PORT_A, PD_DRV_OPEN_DRAIN, 11); + + // set_system_clock_6Mhz(); + // uint32_t reg = (*(uint32_t*)0x40001008); + // reg &= ~0x1f; + // reg |= 10; + // enter_safe_mode(); + // (*(uint32_t*)0x40001008) = reg; + + + // for (int i = 0;; ++i) { + // GPIO_PORT.out.set(GPIO_PORT_A, ON, 8); + // GPIO_PORT.out.set(GPIO_PORT_A, OFF, 8); + // } // clock_cfg_t cfg; // for (int i = 0;; ++i) { |