void UART_Init(long lBaudrate, int iBits, int pins){ if(pins == 12){ if((pADI_GP0->GPCON & 0x003C) == 0) DioCfg(pADI_GP0, pADI_GP0->GPCON | 0x003C); else DioCfg(pADI_GP0, 0x003C); a = 12; }else if(pins == 67){ if((pADI_GP0->GPCON & 0x9000) == 0) DioCfg(pADI_GP0, pADI_GP0->GPCON | 0x9000); else DioCfg(pADI_GP0, 0x9000); a = 67; } UrtCfg(pADI_UART, lBaudrate, iBits, 0); // Baud rate for 9600, 8-bits UrtMod(pADI_UART, COMMCR_DTR, 0); // <<<<< Modem Bits UrtIntCfg(pADI_UART, COMIEN_ERBFI | COMIEN_ETBEI); /* Enables UART interrupt source */ NVIC_EnableIRQ(UART_IRQn); // Enable UART IRQ }
/** @brief UART initialization @param lBaudrate - UART baud rate @return none **/ void UART_Init(long lBaudrate) { DioCfg(pADI_GP0, 0x003C); /* Configure P0.1/P0.2 for UART */ UrtCfg(pADI_UART, lBaudrate, COMLCR_WLS_8BITS, COMLCR_STOP_EN); /* Configure UART bus */ UrtMod(pADI_UART, 0, 0); /* Modem Bits */ UrtIntCfg(pADI_UART, COMIEN_ERBFI | COMIEN_ETBEI); /* Enables UART interrupt source */ }
void UARTClass::Init() { DioCfgPin(pADI_GP0, PIN6, 1); // P0.6 as UART RXD DioCfgPin(pADI_GP0, PIN7, 2); // P0.7 as UART TXD UrtCfg(pADI_UART, B115200, COMLCR_WLS_8BITS, 0); UrtMod(pADI_UART, COMMCR_DTR, 0); UrtIntCfg(pADI_UART, COMIEN_ERBFI | COMIEN_ETBEI); NVIC_EnableIRQ(UART_IRQn); }
void UART_Init(long lBaudrate, int iBits) { //DioCfg(pADI_GP0, 0x9000); /* Configure P0.6/P0.7 for UART */ DioCfgPin(pADI_GP0, PIN6, 1); // P0.6 as UART RXD DioCfgPin(pADI_GP0, PIN7, 2); // P0.7 as UART TXD UrtCfg(pADI_UART, lBaudrate, iBits, 0); /* Configure UART bus */ UrtMod(pADI_UART, COMMCR_DTR, 0); /* Modem Bits */ UrtIntCfg(pADI_UART, COMIEN_ERBFI | COMIEN_ETBEI); /* Enables UART interrupt source */ NVIC_EnableIRQ(UART_IRQn); /* Enable UART IRQ */ }
void init(uint32_t baud_rate) { if (m_handle_uart == (timer_handle_type)-1){ //300ms m_handle_uart = t_timer_manage.hard_timer_register(300, SV_TIMER_FLAG_ONE_SHOT, transceiver_uart0::byte_timer_timeout, this, "byte timer"); ASSERT(m_handle_uart != (timer_handle_type)-1); } //Select IO pins for UART. #ifdef def_HALF_DUPLEX_RS485 DioCfgPin(pADI_GP0,PIN4,0); //Set P0.4 as UART RTS //DioPulPin(pADI_GP0,PIN4,0); DioOcePin(pADI_GP0,PIN4,1); DioOenPin(pADI_GP0,PIN4,1); #endif #ifdef def_RUN_IN_EVB // Configure P0.1/P0.2 for UART pADI_GP0->GPCON = ((pADI_GP0->GPCON)&(~(BIT2|BIT3|BIT4|BIT5)))|0x3C; #else DioCfgPin(pADI_GP0,PIN6,1); //Set P0.6 as UART RXD DioCfgPin(pADI_GP0,PIN7,2); //Set P0.7 as UART TXD #endif UrtCfg(pADI_UART, baud_rate, COMLCR_WLS_8BITS, 0); // setup baud rate for 9600, 8-bits UrtMod(pADI_UART, COMMCR_DTR, 0); // Setup modem bits // Setup UART IRQ sources UrtIntCfg(pADI_UART, COMIEN_ERBFI | COMIEN_ELSI | COMIEN_EDSSI #ifdef def_DMA_SEND |COMIEN_EDMAT); #else );