diff --git a/lib/include/uart.h b/lib/include/uart.h index 1532f74b0..08ce15bd2 100644 --- a/lib/include/uart.h +++ b/lib/include/uart.h @@ -152,6 +152,7 @@ static volatile struct UART_struct * const UART2 = (void *) (UART2_BASE); #endif /* REG_NO_COMPAT */ +void uart_init(volatile struct UART_struct * uart, uint32_t baud); void uart_setbaud(volatile struct UART_struct * uart, uint32_t baud); extern volatile uint32_t u1_head, u1_tail; diff --git a/lib/uart.c b/lib/uart.c index e76ec0010..1cc5c41ec 100644 --- a/lib/uart.c +++ b/lib/uart.c @@ -65,7 +65,7 @@ void uart_setbaud(volatile struct UART_struct * uart, uint32_t baud) { }; } -void uart_init(volatile struct UART_struct * uart) { +void uart_init(volatile struct UART_struct * uart, uint32_t baud) { /* enable the uart so we can set the gpio mode */ /* see Section 11.5.1.2 Alternate Modes */ /* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */ @@ -113,5 +113,8 @@ void uart_init(volatile struct UART_struct * uart) { enable_irq(UART2); } + + uart_setbaud(uart, baud); + } diff --git a/tests/adc.c b/tests/adc.c index 949913b12..92fec985e 100644 --- a/tests/adc.c +++ b/tests/adc.c @@ -45,7 +45,6 @@ int main(void) uint8_t c; trim_xtal(); - uart_init(UART1); uart_init(UART1, 115200); adc_init(); diff --git a/tests/asm.c b/tests/asm.c index 1718142f9..087afba72 100644 --- a/tests/asm.c +++ b/tests/asm.c @@ -52,8 +52,7 @@ void main(void) { /* trim the reference osc. to 24MHz */ trim_xtal(); - uart_init(UART1); - uart_setbaud(UART1, 115200); + uart_init(UART1, 115200); vreg_init(); diff --git a/tests/autoack-rx.c b/tests/autoack-rx.c index 9f00667bc..03de59249 100644 --- a/tests/autoack-rx.c +++ b/tests/autoack-rx.c @@ -64,7 +64,6 @@ void main(void) { /* trim the reference osc. to 24MHz */ trim_xtal(); - uart_init(UART1); uart_init(UART1, 115200); vreg_init(); diff --git a/tests/autoack-tx.c b/tests/autoack-tx.c index d9067e8fd..205c18a49 100644 --- a/tests/autoack-tx.c +++ b/tests/autoack-tx.c @@ -99,7 +99,6 @@ void main(void) { /* trim the reference osc. to 24MHz */ trim_xtal(); - uart_init(UART1); uart_init(UART1, 115200); vreg_init(); diff --git a/tests/flasher.c b/tests/flasher.c index 16c2eac70..e04495490 100644 --- a/tests/flasher.c +++ b/tests/flasher.c @@ -84,7 +84,6 @@ void main(void) { volatile uint32_t state = SCAN_X; volatile uint32_t addr,data; - uart_init(UART1); uart_init(UART1, 115200); disable_irq(UART1); diff --git a/tests/nvm-read.c b/tests/nvm-read.c index 68229cf9c..c100f07db 100644 --- a/tests/nvm-read.c +++ b/tests/nvm-read.c @@ -46,12 +46,18 @@ void main(void) { uint32_t buf[READ_NBYTES/4]; uint32_t i; - uart_init(UART1); uart_init(UART1, 115200); print_welcome("nvm-read"); vreg_init(); +// buck_init(); + while(CRM->STATUSbits.VREG_1P5V_RDY == 0) { continue; } + while(CRM->STATUSbits.VREG_1P8V_RDY == 0) { continue; } + + printf("Sys cntl %08x\n\r", (unsigned int)CRM->SYS_CNTL); + printf("vreg cntl %08x\n\r", (unsigned int)CRM->VREG_CNTL); + printf("crm status %08x\n\r", (unsigned int)CRM->STATUS); if(NVM_INTERFACE == gNvmInternalInterface_c) { @@ -75,7 +81,7 @@ void main(void) { err = nvm_read(NVM_INTERFACE, type, (uint8_t *)buf, READ_ADDR, READ_NBYTES); printf("nvm_read returned: 0x%02x\r\n", err); - for(i=0; i