change uart_init to take a baud so you don't need a second call to

setbaud
This commit is contained in:
Mariano Alvira 2012-10-24 13:22:20 -04:00
parent e7e149d354
commit b3e2f30674
20 changed files with 18 additions and 27 deletions

View file

@ -152,6 +152,7 @@ static volatile struct UART_struct * const UART2 = (void *) (UART2_BASE);
#endif /* REG_NO_COMPAT */ #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); void uart_setbaud(volatile struct UART_struct * uart, uint32_t baud);
extern volatile uint32_t u1_head, u1_tail; extern volatile uint32_t u1_head, u1_tail;

View file

@ -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 */ /* enable the uart so we can set the gpio mode */
/* see Section 11.5.1.2 Alternate Modes */ /* see Section 11.5.1.2 Alternate Modes */
/* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */ /* 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); enable_irq(UART2);
} }
uart_setbaud(uart, baud);
} }

View file

@ -45,7 +45,6 @@ int main(void)
uint8_t c; uint8_t c;
trim_xtal(); trim_xtal();
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
adc_init(); adc_init();

View file

@ -52,8 +52,7 @@ void main(void) {
/* trim the reference osc. to 24MHz */ /* trim the reference osc. to 24MHz */
trim_xtal(); trim_xtal();
uart_init(UART1); uart_init(UART1, 115200);
uart_setbaud(UART1, 115200);
vreg_init(); vreg_init();

View file

@ -64,7 +64,6 @@ void main(void) {
/* trim the reference osc. to 24MHz */ /* trim the reference osc. to 24MHz */
trim_xtal(); trim_xtal();
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
vreg_init(); vreg_init();

View file

@ -99,7 +99,6 @@ void main(void) {
/* trim the reference osc. to 24MHz */ /* trim the reference osc. to 24MHz */
trim_xtal(); trim_xtal();
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
vreg_init(); vreg_init();

View file

@ -84,7 +84,6 @@ void main(void) {
volatile uint32_t state = SCAN_X; volatile uint32_t state = SCAN_X;
volatile uint32_t addr,data; volatile uint32_t addr,data;
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
disable_irq(UART1); disable_irq(UART1);

View file

@ -46,12 +46,18 @@ void main(void) {
uint32_t buf[READ_NBYTES/4]; uint32_t buf[READ_NBYTES/4];
uint32_t i; uint32_t i;
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
print_welcome("nvm-read"); print_welcome("nvm-read");
vreg_init(); 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) 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); err = nvm_read(NVM_INTERFACE, type, (uint8_t *)buf, READ_ADDR, READ_NBYTES);
printf("nvm_read returned: 0x%02x\r\n", err); printf("nvm_read returned: 0x%02x\r\n", err);
for(i=0; i<READ_NBYTES/4; i++) { for(i=0; i<16/4; i++) {
printf("0x%08x\r\n", (unsigned int)buf[i]); printf("0x%08x\r\n", (unsigned int)buf[i]);
} }

View file

@ -46,7 +46,6 @@ void main(void) {
uint32_t buf[WRITE_NBYTES/4]; uint32_t buf[WRITE_NBYTES/4];
uint32_t i; uint32_t i;
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
print_welcome("nvm-write"); print_welcome("nvm-write");

View file

@ -117,7 +117,6 @@ void main(void) {
/* trim the reference osc. to 24MHz */ /* trim the reference osc. to 24MHz */
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS); pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
vreg_init(); vreg_init();

View file

@ -76,8 +76,7 @@ int main(void)
int mi; int mi;
// char buf[80]; // char buf[80];
uart_init(UART1); uart_init(UART1, 115200);
uart_setbaud(UART1, 115200);
print_size(int8_t); print_size(int8_t);
print_size(uint8_t); print_size(uint8_t);

View file

@ -46,7 +46,6 @@ int main(void)
int x = 32768; int x = 32768;
trim_xtal(); trim_xtal();
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
rtc_init(); rtc_init();

View file

@ -62,7 +62,6 @@ void main(void) {
/* trim the reference osc. to 24MHz */ /* trim the reference osc. to 24MHz */
trim_xtal(); trim_xtal();
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
vreg_init(); vreg_init();

View file

@ -70,7 +70,6 @@ void main(void) {
/* trim the reference osc. to 24MHz */ /* trim the reference osc. to 24MHz */
trim_xtal(); trim_xtal();
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
vreg_init(); vreg_init();

View file

@ -42,7 +42,6 @@
void main(void) { void main(void) {
volatile uint8_t *data; volatile uint8_t *data;
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
for(data = DUMP_BASE; data < ((uint8_t *)(DUMP_BASE+DUMP_LEN)); data++) { for(data = DUMP_BASE; data < ((uint8_t *)(DUMP_BASE+DUMP_LEN)); data++) {

View file

@ -41,7 +41,6 @@
void main(void) { void main(void) {
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
*mem32(0x00401ffc) = 0x01234567; *mem32(0x00401ffc) = 0x01234567;

View file

@ -41,10 +41,8 @@
void main(void) { void main(void) {
uart_init(UART1); uart_init(UART1, 115200);
uart_init(UART2); uart_init(UART2, 115200);
uart_setbaud(UART1, 115200);
uart_setbaud(UART2, 115200);
while(1) { while(1) {
if(uart1_can_get()) { if(uart1_can_get()) {

View file

@ -41,9 +41,7 @@
void main(void) { void main(void) {
// uart1_init(INC,MOD,SAMP); uart_init(UART1, 115200);
uart_init(UART1);
uart_setbaud(UART1, 1200);
while(1) { while(1) {
if(uart1_can_get()) { if(uart1_can_get()) {

View file

@ -46,7 +46,6 @@
void main(void) { void main(void) {
volatile uint32_t i; volatile uint32_t i;
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
printf("reset\n\r"); printf("reset\n\r");

View file

@ -48,7 +48,6 @@ int main(void)
ctune = 0; ctune = 0;
ftune = 0; ftune = 0;
uart_init(UART1);
uart_init(UART1, 115200); uart_init(UART1, 115200);
print_welcome("pwm test\r\n"); print_welcome("pwm test\r\n");