void GPS_Configure(void) { //send the string to always change the baud //printf("about to change the baud"); //char *NMEA_String="$PMTK251,115200*1F\r\n\0"; GPS_PutString(MEDIATEK_CHANGE_BAUD); while (!GPS_IsTransmitEmpty()); //disable the uart and change baud and then re-enable UARTEnable(UART2, UART_DISABLE_FLAGS(UART_PERIPHERAL | UART_TX | UART_RX)); UARTSetDataRate(UART2, F_PB, 115200); UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_TX | UART_RX)); #ifdef DEBUG_VERBOSE printf("UART at Higher BaudRate\r\n"); #endif //while(!GPS_IsReceiveEmpty()); while (GPS_GetChar() != '$'); GPS_PutString(MEDIATEK_NMEA); while (!GPS_IsTransmitEmpty()); while (!GPS_IsReceiveEmpty()) { GPS_GetChar(); } while (GPS_GetChar() != '$'); GPS_PutString(MEDIATEK_REFRESH_RATE); printf("GPS Should be at 115200"); }
void InitApp(void) { /* Initialize peripherals */ // Configure UART modules UARTConfigure(UART_CMD_MODULE_ID, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART_CMD_MODULE_ID, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART_CMD_MODULE_ID, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART_CMD_MODULE_ID, GetPeripheralClock(), DESIRED_CMD_BAUDRATE); UARTEnable(UART_CMD_MODULE_ID, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); UARTConfigure(UART_WIFI_MODULE_ID, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART_WIFI_MODULE_ID, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART_WIFI_MODULE_ID, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART_WIFI_MODULE_ID, GetPeripheralClock(), DESIRED_WIFI_BAUDRATE); UARTEnable(UART_WIFI_MODULE_ID, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); // Configure UART Interrupts INTEnable(INT_SOURCE_UART_RX(UART_CMD_MODULE_ID), INT_ENABLED); INTSetVectorPriority(INT_VECTOR_UART(UART_CMD_MODULE_ID), INT_PRIORITY_LEVEL_2); INTSetVectorSubPriority(INT_VECTOR_UART(UART_CMD_MODULE_ID), INT_SUB_PRIORITY_LEVEL_0); INTEnable(INT_SOURCE_UART_RX(UART_WIFI_MODULE_ID), INT_ENABLED); INTSetVectorPriority(INT_VECTOR_UART(UART_WIFI_MODULE_ID), INT_PRIORITY_LEVEL_1); INTSetVectorSubPriority(INT_VECTOR_UART(UART_WIFI_MODULE_ID), INT_SUB_PRIORITY_LEVEL_0); // Make the requests to Wifi service - they will be picked up when the service needs them ConnectToAccessPoint(&routerConnection, &DefaultWifiService); SendHttpRequest(&DnsDynamicHttpRequest, &DefaultWifiService); }
/****************************************************************************** * UART-0 Configuration VCP (Virtual Com Port) * ---------------------------------------------------------------------------- * UART 0 -> Port A -> Pins PA0(Tx) & PA1(Rx) * 9600-8N1 * ******************************************************************************/ void PSO_UART0Config() { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); /* Enable UART Module 0 */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); /* Enable GPIO Port A for UART-0 use */ GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); /* UART-0 interrupt configuration */ UARTDisable(UART0_BASE); UARTFIFOEnable(UART0_BASE); IntEnable(INT_UART0); UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX7_8); UARTIntEnable(UART0_BASE, UART_INT_RX); // | UART_INT_RT UARTEnable(UART0_BASE); UARTFIFOEnable(UART0_BASE); }
void uartprinntf() { // // Initionalize system clock. // xSysCtlPeripheralClockSourceSet( 10000000, xSYSCTL_XTAL_6MHZ ); SysCtlDelay(10000); xSPinTypeUART(UART0RX,PB0); xSPinTypeUART(UART0TX,PB1); xSysCtlPeripheralReset(xSYSCTL_PERIPH_UART0); xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART0); SysCtlPeripheralClockSourceSet(SYSCTL_PERIPH_UART_S_EXT12M); // // Config 8 bit word length, 1 stop bit, // and none parity bit, receive FIFO 1 byte. // UARTConfigSetExpClk(UART0_BASE, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART0_BASE, (UART_BLOCK_UART | UART_BLOCK_TX | UART_BLOCK_RX)); UARTBufferWrite(UART0_BASE, "NUC1xx.UART.BAUDRATE EXAMPLE \r\n", sizeof("NUC1xx.UART.BAUDRATE EXAMPLE \r\n")); }
int zigbee_init(unsigned long baud) { int result; charZigbee.TxQueueLength = 10; charZigbee.RxQueueLength = 20; charZigbee.QueueWait = 0; charZigbee.PortBase = UART2_BASE; result = prepare_device(&charZigbee); if(result){ printf("Zigbee queue creation fail\n"); return result; } SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); GPIOPinTypeUART(GPIO_PORTG_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART2_BASE, SysCtlClockGet(), baud, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); IntRegister(INT_UART2, zigbee_isr); UARTIntDisable(UART2_BASE, 0xFFFFFFFF); IntPrioritySet(INT_UART2,configKERNEL_INTERRUPT_PRIORITY); IntEnable(INT_UART2); UARTEnable(UART2_BASE); UARTFIFODisable(UART2_BASE); UARTIntEnable(UART2_BASE, UART_INT_TX | UART_INT_RX); return result; }
//***************************************************************************** // // Initializes the UART update interface. // //***************************************************************************** void UpdateUARTInit(void) { // // Set the flash programming speed based on the processor speed. // FlashUsecSet(50); // // Enable the peripherals used by the UART. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // // Configure the UART Tx and Rx pins for use by the UART. // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Configure and enable the UART for 115,200, 8-N-1 operation. // UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART0_BASE); // // Enable the UART receive interrupts. // UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); IntEnable(INT_UART0); }
void SERIAL_Init(void) { transmitBuffer = (struct CircBuffer*) &outgoingUart; //set up buffer for receive newCircBuffer(transmitBuffer); receiveBuffer = (struct CircBuffer*) &incomingUart; //set up buffer for transmit newCircBuffer(receiveBuffer); UARTConfigure(UART1, 0x00); UARTSetDataRate(UART1, F_PB, 115200); UARTSetFifoMode(UART1, UART_INTERRUPT_ON_RX_NOT_EMPTY | UART_INTERRUPT_ON_TX_BUFFER_EMPTY); INTSetVectorPriority(INT_UART_1_VECTOR, INT_PRIORITY_LEVEL_4); //set the interrupt priority //RPC5R = 1; PPSOutput(1, RPC5, U1TX); PORTSetPinsDigitalIn(IOPORT_C, BIT_3); //U1RXRbits.U1RXR = 0b111; PPSInput(3, U1RX, RPC3); UARTEnable(UART1, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_TX | UART_RX)); INTEnable(INT_U1RX, INT_ENABLED); //INTSetFlag(INT_U1RX); //INTEnable(INT_U1TX, INT_ENABLED); //PutChar('z'); }
void ConfigureXBeeUART(void) { // // Enable the GPIO Peripheral used by the UART. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); // // Enable UART2 // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3); // // Configure GPIO Pins for UART mode. // GPIOPinConfigure(GPIO_PC6_U3RX); GPIOPinConfigure(GPIO_PC7_U3TX); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7); // // Use the internal 16MHz oscillator as the UART clock source. // UARTClockSourceSet(UART3_BASE, UART_CLOCK_PIOSC); UARTConfigSetExpClk(UART3_BASE, 16000000, SERIAL_SPEED, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART3_BASE); }
xComPortHandle xComOpen( tCOMPort ePort, tBaud eWantedBaud, tParity eWantedParity, tDataBits eWantedDataBits, tStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength ) { Init(); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); UARTEnable(UART0_BASE); }
void serial_init(void) { // Initialisation du fifo de réception InitFifo ( &descrFifoRX, FIFO_RX_SIZE, fifoRX, 0 ); // Initialisation du fifo d'émission InitFifo ( &descrFifoTX, FIFO_TX_SIZE, fifoTX, 0 ); // Utilisation des fonctions séparées (XC32) // ========================================= UARTConfigure(UART2, UART_ENABLE_HIGH_SPEED | UART_ENABLE_PINS_TX_RX_ONLY ); // UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_BUFFER_EMPTY | UART_INTERRUPT_ON_RX_HALF_FULL ); // Remarque HALF_FULL ne fonctionne pas // Pour INT RX au 3/4 UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_BUFFER_EMPTY | UART_INTERRUPT_ON_RX_3_QUARTER_FULL ); // Pour INT RX dés que min 1 char // UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_BUFFER_EMPTY | UART_INTERRUPT_ON_RX_NOT_EMPTY ); UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UINT32 ActualBaudRate = UARTSetDataRate(UART2, PB_FREQ, 9600); UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); // Configuration Int UART2 avec les fonctions séparées // =================================================== // Configure UART RX Interrupt INTEnable(INT_SOURCE_UART_RX(UART2), INT_ENABLED); INTSetVectorPriority(INT_VECTOR_UART(UART2), INT_PRIORITY_LEVEL_5); INTSetVectorSubPriority(INT_VECTOR_UART(UART2), INT_SUB_PRIORITY_LEVEL_0); } // InitComm
//***************************************************************************** // // Initializes the RemoTI UART driver interface to a remote network processor. // // \param ui32Base is the base address of the UART peripheral to be used. // Caller must call SysCtlPeripheralEnable for this UART peripheral prior to // calling this init funciton. // // This function will initialize the ring buffers used for transmit and receive // of data to and from the RNP. It also configures the UART peripheral for a // default setting. Enables receive interrupts. Transmit interrupts are // enabled when a transmit is in progress. Master interrupt enable must be // turned on by the application. // // \note Users of this driver are also responsible to assign // RemoTIUARTIntHandler() as the interrupt routine associated with the UART // peripheral of choice. // // \return None. // //***************************************************************************** void RemoTIUARTInit(uint32_t ui32Base) { // // Save the UART peripheral base address for later use. // g_ui32UARTBase = ui32Base; // // Initialize the TX and RX ring buffers for storage of our data. // RingBufInit(&g_rbRemoTIRxRingBuf, g_pui8RxBuf, REMOTI_UART_TX_BUF_SIZE); RingBufInit(&g_rbRemoTITxRingBuf, g_pui8TxBuf, REMOTI_UART_TX_BUF_SIZE); // // Configure UART clock settings. // UARTConfigSetExpClk(ui32Base, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE | UART_FLOWCONTROL_NONE)); // // Configure the UART FIFO. Enable the UART and Enable RX interrupts. // UARTFIFOLevelSet(ui32Base, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTEnable(ui32Base); UARTFIFODisable(ui32Base); UARTIntEnable(ui32Base, UART_INT_RX); }
//***************************************************************************** // // Initializes the logging interface. // //***************************************************************************** void LogInit(void) { // // Enable the peripherals used to perform logging. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // // Configure the UART pins appropriately. // GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3); // // Configure the UART for 115,200, 8-N-1 operation. // UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART1_BASE); // // Enable the UART interrupt. // UARTIntEnable(UART1_BASE, UART_INT_TX); IntEnable(INT_UART1); // // Write a log message to indicate that the application has started. // LogWrite("Application started"); }
//****************************************************************************** //Public Function Definitions //****************************************************************************** void FIFOUART1_initialize() { UARTConfigure(UART1, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetLineControl(UART1, UART_DATA_SIZE_8_BITS | //Sets the data transfer size to 8-bits per frame.� UART_PARITY_NONE | //Disables parity bit generation.� UART_STOP_BITS_1); //1 stop bit per frame (default).� UARTSetDataRate(UART1, GetPeripheralClock(), FIFOUART1_BAUD_RATE); //Interrupt Stuff INTSetVectorPriority(INT_UART_1_VECTOR, INT_PRIORITY_LEVEL_5); INTSetVectorSubPriority(INT_UART_1_VECTOR, INT_SUB_PRIORITY_LEVEL_0); INTClearFlag(INT_U1RX); INTClearFlag(INT_U1TX); //configure what triggers UART1 itnerrupts UARTSetFifoMode(UART1, UART_INTERRUPT_ON_TX_BUFFER_EMPTY | //TX interrupt will occur when the TX buffer is empty.� UART_INTERRUPT_ON_RX_NOT_EMPTY); //RX interrupt will occur whenever the RX buffer has any data.� //Enable UART1 Rx Interrupt INTEnable(INT_U1RX, INT_ENABLED); //Enable UART1 Tx Interrupt //INTEnable(INT_U1TX, INT_ENABLED); UARTEnable(UART1, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); }
void NU32_EnableUART2Interrupt(void) { // turn off the module to change the settings UARTEnable(UART2, UART_ENABLE_FLAGS(UART_DISABLE)); // Configure UART1 RX Interrupt // UARTConfigure(UART2, UART_ENABLE_PINS_CTS_RTS ); UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_DONE | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART2, SYSCLK, 115200); UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); INTEnable(INT_U2RX, INT_ENABLED); INTSetVectorPriority(INT_UART_2_VECTOR, INT_PRIORITY_LEVEL_2); INTSetVectorSubPriority(INT_UART_2_VECTOR, INT_SUB_PRIORITY_LEVEL_0); }
void initUART2(){ UARTConfigure(UART2, UART_ENABLE_PINS_TX_RX_ONLY);//configure uart for rx and tx UARTSetFifoMode(UART2, UART_INTERRUPT_ON_RX_NOT_EMPTY);//configure for interrupts UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1);//set uart line options UARTSetDataRate(UART2, getPBusClock(), UART_BAUD);//data rate 9600 baud and pbus 10MHz UARTEnable(UART2, UART_PERIPHERAL | UART_RX | UART_TX | UART_ENABLE); //enable the uart for tx rx while(!UARTTransmitterIsReady(UART2)); }
//***************************************************************************** // //! Something should do after the test execute of xuart001 test. //! //! \return None. // //***************************************************************************** static void xuart005TearDown(void) { UARTConfigSetExpClk(UART0_BASE, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART0_BASE, (UART_BLOCK_UART | UART_BLOCK_TX | UART_BLOCK_RX)); }
//****************************************************** // void OpenUart ( const UARTx,long BaudRate) // Overture d'un port serie // @param : UARTx : choix du port // UART1,UART2,UART3,UART4,UART5,UART6 // BaudeRate : Vitesse du port serie // 1200,2400,4800,9600,19200,38400,57600,115200 // //****************************************************** void OpenUart ( const UARTx,long BaudRate) { UARTConfigure(UARTx, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UARTx, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UARTx, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UARTx, GetPeripheralClock(), BAUDERATE); UARTEnable(UARTx, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); }
void setupSerial(void) { UARTConfigure(UART2, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART2, PBCLK, BAUDRATE); UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); SendDataBuffer("\n\r***Radiometer Serial port configured***\n\r", sizeof("\n\r***Radiometer Serial port configured***\n\r")); return; }
//Enable LCD UART Protocol void enable_LCD() { //Baud rate = 9600, uart1 enabled, base clock chosen and uart configuration at a buffer size of 8 UARTConfigSetExpClk(b1, SysCtlClockGet(), 9600, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); UARTEnable(b1); changeCursorUnderscore(); clearDisplay(); }
void initUART(void) { PORTFbits.RF4 = 1; //U2RX PORTFbits.RF5 = 0; //U2TX UARTConfigure(UART2, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART2, 0); UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART2, SYS_CLOCK, 115200); UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); }
// Serial virtual void SerialBegin(int serialDevice, int baudrate) { if (serialDevice == 0) { MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioInit(0); UARTEnable(UART0_BASE); } }
//============================================================================// //== UART初始化函数 ==// //============================================================================// //==入口参数: 无 ==// //==出口参数: 无 ==// //==返回值: 无 ==// //============================================================================// void UARTInit(void) { SysCtlPeripheralEnable(GPIO_PERIPH); //使能UART所在GPIO端口 SysCtlPeripheralEnable(UART_PERIPH); //使能UART外设 GPIOPinTypeUART(GPIO_USE_BASE, GPIO_PINS); //使能UART所在引脚 UARTConfigSet(UART_USE_BASE, BAUDRATE, UART_CONFIG_WLEN_8| UART_CONFIG_STOP_ONE| UART_CONFIG_PAR_NONE); UARTEnable(UART_USE_BASE); //使能UART }
void UART2_57600(void) { // Disable UART Receive/Transmit UARTDisable(UART2_BASE, UART_TX | UART_RX); // Configure UART Baud 57600 UARTConfigSet(UART2_BASE, 57600, UART_CONFIG_SAMPLE_RATE_DEFAULT | UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_1); // Enable UART Receive and Transmit UARTEnable(UART2_BASE, UART_TX | UART_RX); }
void setup() { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5); //Configure pins due to bit banging //Transfer pin to lcd GPIOPinConfigure(GPIO_PB1_U1TX); //Receiving pin from usb GPIOPinConfigure(GPIO_PE4_U5RX); //Transfer pin to usb GPIOPinConfigure(GPIO_PE5_U5TX); //LED pin GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); //lcd pin GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_1); //usb pins GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5); //Initialize the UART. //Baud rate - Data bits - turn off parity - stop bits --- 9600 - 8 - Off - 1 UARTConfigSetExpClk(b1, SysCtlClockGet(), 9600, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); UARTEnable(b1); UARTConfigSetExpClk(b5, SysCtlClockGet(), 9600, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); UARTEnable(b5); toggleLED(); changeCursorUnderscore(); clearDisplay(); putPhrase("Hello World!"); SysCtlDelay(3000000); clearDisplay(); //Test terminal UARTCharPut(b5, 'h'); UARTCharPut(b5, 'e'); UARTCharPut(b5, 'l'); UARTCharPut(b5, 'l'); UARTCharPut(b5, 'o'); }
/** * Initialises the UART for use * @param None * @returns None */ void uart_initialise (void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk (UART0_BASE, SysCtlClockGet (), 38400, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE); UARTEnable(UART0_BASE); }
void setup_UART2 (unsigned int pb_clock) //UART associated with the PmodCLS { // OpenUART2( config1, config2, ubrg) OpenUART2 (UART_EN | UART_IDLE_CON | UART_RX_TX | UART_DIS_WAKE | UART_DIS_LOOPBACK | UART_DIS_ABAUD | UART_NO_PAR_8BIT | UART_1STOPBIT | UART_IRDA_DIS | UART_MODE_FLOWCTRL | UART_DIS_BCLK_CTS_RTS | UART_NORMAL_RX | UART_BRGH_SIXTEEN, UART_TX_PIN_LOW | UART_RX_ENABLE | UART_TX_ENABLE | UART_INT_TX | UART_INT_RX_CHAR | UART_ADR_DETECT_DIS | UART_RX_OVERRUN_CLEAR, mUARTBRG(pb_clock, DESIRED_BAUD_RATE)); UARTEnable(UART2, UART_DISABLE_FLAGS(UART_RX )); }
int main(void) { char cThisChar; SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL |SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN ); //Para el SW1 /*SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIODirModeSet(GPIO_PORTF_BASE, 0xFF, GPIO_DIR_MODE_IN); GPIOPinIntEnable(GPIO_PORTB_BASE, 0xFF); IntEnable(INT_GPIOF);*/ SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTFIFOLevelSet(UART1_BASE,UART_FIFO_TX7_8,UART_FIFO_RX7_8); UARTIntClear(UART1_BASE, UART_INT_TX | UART_INT_RX); UARTIntEnable(UART1_BASE, UART_INT_RX); UARTFIFOEnable(UART1_BASE); IntMasterEnable(); UARTEnable(UART1_BASE); IntEnable(INT_UART1); for(n=0; n<sizeof(buferA); n++){ UARTCharPut(UART1_BASE, buferA[n]);} for(m=0; m<sizeof(buferC); m++){ UARTCharPut(UART1_BASE, buferC[m]);} while(1){;} }
void SerialInit() { GPIOPinTypeUART (GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk (UART0_BASE, SysCtlClockGet(), 115200ul, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTFIFOEnable (UART0_BASE); UARTEnable (UART0_BASE); }
void setup(bool use_interrupt = false, INT_PRIORITY int_priority = INT_PRIORITY_DISABLED, UART_CONFIGURATION uart_config = (UART_CONFIGURATION)UART_ENABLE_PINS_TX_RX_ONLY, UART_FIFO_MODE interrupt_modes = (UART_FIFO_MODE)0, UART_LINE_CONTROL_MODE line_control_modes = (UART_LINE_CONTROL_MODE)(UART_DATA_SIZE_8_BITS|UART_PARITY_NONE|UART_STOP_BITS_1), UART_ENABLE_MODE enable_modes = (UART_ENABLE_MODE)(UART_PERIPHERAL|UART_RX|UART_TX)) { UARTConfigure(module, uart_config); UARTSetFifoMode(module, interrupt_modes); UARTSetLineControl(module, line_control_modes); UARTSetDataRate(module, param::pbus_hz(), baud); UARTEnable(module, (UART_ENABLE_MODE) UART_ENABLE_FLAGS(enable_modes)); if (use_interrupt) { INT_VECTOR int_vect; INT_SOURCE int_src; switch(module) { case UART1: int_vect = INT_UART_1_VECTOR; int_src = INT_U1RX; break; case UART2: int_vect = INT_UART_2_VECTOR; int_src = INT_U2RX; break; case UART3: int_vect = INT_UART_3_VECTOR; int_src = INT_U3RX; break; case UART4: int_vect = INT_UART_4_VECTOR; int_src = INT_U4RX; break; case UART5: int_vect = INT_UART_5_VECTOR; int_src = INT_U5RX; break; case UART6: int_vect = INT_UART_6_VECTOR; int_src = INT_U6RX; break; case UART_NUMBER_OF_MODULES: default: return; // WTF } INTEnable(int_src, INT_ENABLED); INTSetVectorPriority(int_vect, int_priority); INTSetVectorSubPriority(int_vect, INT_SUB_PRIORITY_LEVEL_0); } }
void uartStart(void) { unsigned int intFlags = 0; unsigned int config = 0; /* Enabling the PSC for UART2.*/ /* roger, crash PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_UART2, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); */ /* Setup PINMUX */ UARTPinMuxSetup(2, FALSE); /* Enabling the transmitter and receiver*/ UARTEnable(SOC_UART_2_REGS); /* 1 stopbit, 8-bit character, no parity */ config = UART_WORDL_8BITS; /* Configuring the UART parameters*/ UARTConfigSetExpClk(SOC_UART_2_REGS, SOC_UART_2_MODULE_FREQ, BAUD_115200, config, UART_OVER_SAMP_RATE_16); /* Enabling the FIFO and flushing the Tx and Rx FIFOs.*/ UARTFIFOEnable(SOC_UART_2_REGS); /* Setting the UART Receiver Trigger Level*/ UARTFIFOLevelSet(SOC_UART_2_REGS, UART_RX_TRIG_LEVEL_1); /* ** Enable AINTC to handle interrupts. Also enable IRQ interrupt in ARM ** processor. */ /* Do int from config, not by starterware SetupInt(); */ /* Configure AINTC to receive and handle UART interrupts. */ /* Do int from config, not by starterware ConfigureIntUART(); */ /* Preparing the 'intFlags' variable to be passed as an argument.*/ /* intFlags |= (UART_INT_LINE_STAT | \ UART_INT_TX_EMPTY | \ UART_INT_RXDATA_CTI); */ intFlags |= (UART_INT_LINE_STAT | \ UART_INT_RXDATA_CTI); /* Enable the Interrupts in UART.*/ UARTIntEnable(SOC_UART_2_REGS, intFlags); }