From b3e2f306743f2b92c27b245354b7c61cf4821ebb Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Wed, 24 Oct 2012 13:22:20 -0400 Subject: [PATCH] change uart_init to take a baud so you don't need a second call to setbaud --- lib/include/uart.h | 1 + lib/uart.c | 5 ++++- tests/adc.c | 1 - tests/asm.c | 3 +-- tests/autoack-rx.c | 1 - tests/autoack-tx.c | 1 - tests/flasher.c | 1 - tests/nvm-read.c | 10 ++++++++-- tests/nvm-write.c | 1 - tests/per.c | 1 - tests/printf.c | 3 +-- tests/pwm.c | 1 - tests/rftest-rx.c | 1 - tests/rftest-tx.c | 1 - tests/romimg.c | 1 - tests/sleep.c | 1 - tests/u1u2-loopback.c | 6 ++---- tests/uart1-loopback.c | 4 +--- tests/wdt.c | 1 - tests/xtal-trim.c | 1 - 20 files changed, 18 insertions(+), 27 deletions(-) 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