| __attribute__((section(".progmem"))) | __attribute__((section(".progmem"))) | ||||
| void printf_debug_init(void) | void printf_debug_init(void) | ||||
| { | { | ||||
| // turn on Serial4, run using 24 MHz clock (works if PLL3 off or bypassed) | |||||
| CCM_CCGR0 |= CCM_CCGR0_LPUART3(CCM_CCGR_ON); | |||||
| CCM_CCGR0 |= CCM_CCGR0_LPUART3(CCM_CCGR_ON); // turn on Serial4 | |||||
| IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06 = 2; // Arduino pin 17 | IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06 = 2; // Arduino pin 17 | ||||
| CCM_CSCDR1 = (CCM_CSCDR1 & ~CCM_CSCDR1_UART_CLK_PODF(0x3F)) | CCM_CSCDR1_UART_CLK_SEL; | |||||
| LPUART3_BAUD = LPUART_BAUD_OSR(25) | LPUART_BAUD_SBR(8); // ~115200 baud | LPUART3_BAUD = LPUART_BAUD_OSR(25) | LPUART_BAUD_SBR(8); // ~115200 baud | ||||
| LPUART3_CTRL = LPUART_CTRL_TE; | LPUART3_CTRL = LPUART_CTRL_TE; | ||||
| } | } |
| for (i=0; i < 176; i++) _VectorsRam[i] = &unused_interrupt_vector; | for (i=0; i < 176; i++) _VectorsRam[i] = &unused_interrupt_vector; | ||||
| SCB_VTOR = (uint32_t)_VectorsRam; | SCB_VTOR = (uint32_t)_VectorsRam; | ||||
| // Configure clocks | |||||
| // TODO: make sure all affected peripherals are turned off! | |||||
| // PIT & GPT timers to run from 24 MHz clock (independent of CPU speed) | // PIT & GPT timers to run from 24 MHz clock (independent of CPU speed) | ||||
| CCM_CSCMR1 = (CCM_CSCMR1 & ~CCM_CSCMR1_PERCLK_PODF(0x3F)) | CCM_CSCMR1_PERCLK_CLK_SEL; | CCM_CSCMR1 = (CCM_CSCMR1 & ~CCM_CSCMR1_PERCLK_PODF(0x3F)) | CCM_CSCMR1_PERCLK_CLK_SEL; | ||||
| // UARTs run from 24 MHz clock (works if PLL3 off or bypassed) | |||||
| CCM_CSCDR1 = (CCM_CSCDR1 & ~CCM_CSCDR1_UART_CLK_PODF(0x3F)) | CCM_CSCDR1_UART_CLK_SEL; | |||||
| // must enable PRINT_DEBUG_STUFF in debug/print.h | // must enable PRINT_DEBUG_STUFF in debug/print.h | ||||
| printf_init(); | printf_init(); |