void i2c_init(void) { bool status; // Enable peripheral except in deep sleep modes (e.g. LPM1, LPM2, LPM3) SysCtrlPeripheralEnable(I2C_PERIPHERAL); SysCtrlPeripheralSleepEnable(I2C_PERIPHERAL); SysCtrlPeripheralDeepSleepDisable(I2C_PERIPHERAL); // Reset peripheral previous to configuring it SysCtrlPeripheralReset(I2C_PERIPHERAL); // Configure the SCL pin GPIOPinTypeI2C(I2C_BASE, I2C_SCL); IOCPinConfigPeriphInput(I2C_BASE, I2C_SCL, IOC_I2CMSSCL); IOCPinConfigPeriphOutput(I2C_BASE, I2C_SCL, IOC_MUX_OUT_SEL_I2C_CMSSCL); // Configure the SDA pin GPIOPinTypeI2C(I2C_BASE, I2C_SDA); IOCPinConfigPeriphInput(I2C_BASE, I2C_SDA, IOC_I2CMSSDA); IOCPinConfigPeriphOutput(I2C_BASE, I2C_SDA, IOC_MUX_OUT_SEL_I2C_CMSSDA); // Configure the I2C clock status = (I2C_BAUDRATE == 400000 ? true : false); I2CMasterInitExpClk(SysCtrlClockGet(), status); // Enable the I2C module as master I2CMasterEnable(); }
void Spi::enable(uint32_t baudrate) { GpioConfig& miso = miso_.getGpioConfig(); GpioConfig& mosi = mosi_.getGpioConfig(); GpioConfig& clk = clk_.getGpioConfig(); // GpioConfig& ncs = ncs_.getGpioConfig(); // Store baudrate in configuration if (baudrate != 0) { config_.baudrate = baudrate; } // Enable peripheral except in deep sleep modes (e.g. LPM1, LPM2, LPM3) SysCtrlPeripheralEnable(config_.peripheral); SysCtrlPeripheralSleepEnable(config_.peripheral); SysCtrlPeripheralDeepSleepDisable(config_.peripheral); // Reset peripheral previous to configuring it SSIDisable(config_.base); // Set IO clock as SPI0 clock source SSIClockSourceSet(config_.base, config_.clock); // Configure the MISO, MOSI, CLK and nCS pins as peripheral IOCPinConfigPeriphInput(miso.port, miso.pin, miso.ioc); IOCPinConfigPeriphOutput(mosi.port, mosi.pin, mosi.ioc); IOCPinConfigPeriphOutput(clk.port, clk.pin, clk.ioc); // IOCPinConfigPeriphOutput(ncs.port, ncs.pin, ncs.ioc); // Configure MISO, MOSI, CLK and nCS GPIOs GPIOPinTypeSSI(miso.port, miso.pin); GPIOPinTypeSSI(mosi.port, mosi.pin); GPIOPinTypeSSI(clk.port, clk.pin); // GPIOPinTypeSSI(ncs.port, ncs.pin); // Configure the SPI0 clock SSIConfigSetExpClk(config_.base, SysCtrlIOClockGet(), config_.protocol, \ config_.mode, config_.baudrate, config_.datawidth); // Enable the SPI0 module SSIEnable(config_.base); }
void Spi::enable(uint32_t mode, uint32_t protocol, uint32_t datawidth, uint32_t baudrate) { // Store SPI mode, protoco, baudrate and datawidth mode_ = mode; protocol_ = protocol; baudrate_ = baudrate; datawidth_ = datawidth; // Enable peripheral except in deep sleep modes (e.g. LPM1, LPM2, LPM3) SysCtrlPeripheralEnable(peripheral_); SysCtrlPeripheralSleepEnable(peripheral_); SysCtrlPeripheralDeepSleepDisable(peripheral_); // Reset peripheral previous to configuring it SSIDisable(base_); // Set IO clock as SPI0 clock source SSIClockSourceSet(base_, clock_); // Configure the MISO, MOSI, CLK and nCS pins as peripheral IOCPinConfigPeriphInput(miso_.getPort(), miso_.getPin(), miso_.getIoc()); IOCPinConfigPeriphOutput(mosi_.getPort(), mosi_.getPin(), mosi_.getIoc()); IOCPinConfigPeriphOutput(clk_.getPort(), clk_.getPin(), clk_.getIoc()); // IOCPinConfigPeriphOutput(ncs_.getPort(), ncs_.getPin(), ncs_.getIoc()); // Configure MISO, MOSI, CLK and nCS GPIOs GPIOPinTypeSSI(miso_.getPort(), miso_.getPin()); GPIOPinTypeSSI(mosi_.getPort(), mosi_.getPin()); GPIOPinTypeSSI(clk_.getPort(), clk_.getPin()); // GPIOPinTypeSSI(ncs_.getPort(), ncs_.getPin()); // Configure the SPI0 clock SSIConfigSetExpClk(base_, SysCtrlIOClockGet(), protocol_, \ mode_, baudrate_, datawidth_); // Enable the SPI0 module SSIEnable(base_); }
/************************************************************************************************* * @fn HalUARTInitIsr() * * @brief Initialize the UART * * @param none * * @return none *************************************************************************************************/ void HalUARTInitIsr(void) { SysCtrlPeripheralEnable(HAL_UART_SYS_CTRL); /* Setup PB0 as UART_CTS, PD3 as UART_RTS * PA1 as UART_TX and PA0 as UART_RX */ IOCPinConfigPeriphOutput(GPIO_A_BASE, GPIO_PIN_1, IOC_MUX_OUT_SEL_UART1_TXD); IOCPinConfigPeriphInput(GPIO_A_BASE, GPIO_PIN_0, IOC_UARTRXD_UART1); GPIOPinTypeUARTInput(GPIO_A_BASE, GPIO_PIN_0); GPIOPinTypeUARTOutput(GPIO_A_BASE, GPIO_PIN_1); recRst(); }
/************************************************************************************************* * @fn sbUartInit() * * @brief Initialize the UART. * * @param none * * @return none */ void sbUartInit(void) { // // Set IO clock to the same as system clock // SysCtrlIOClockSet(SYS_CTRL_SYSDIV_32MHZ); // // Enable UART peripheral module // SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_UART0); // // Disable UART function // UARTDisable(UART0_BASE); // // Disable all UART module interrupts // UARTIntDisable(UART0_BASE, 0x1FFF); // // Set IO clock as UART clock source // UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); // // Map UART signals to the correct GPIO pins and configure them as // hardware controlled. // IOCPinConfigPeriphOutput(GPIO_A_BASE, GPIO_PIN_1, IOC_MUX_OUT_SEL_UART0_TXD); GPIOPinTypeUARTOutput(GPIO_A_BASE, GPIO_PIN_1); IOCPinConfigPeriphInput(GPIO_A_BASE, GPIO_PIN_0, IOC_UARTRXD_UART0); GPIOPinTypeUARTInput(GPIO_A_BASE, GPIO_PIN_0); // // Configure the UART for 115,200, 8-N-1 operation. // This function uses SysCtrlClockGet() to get the system clock // frequency. This could be also be a variable or hard coded value // instead of a function call. // UARTConfigSetExpClk(UART0_BASE, SysCtrlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART0_BASE); }
void uart_init() { // reset local variables memset(&uart_vars,0,sizeof(uart_vars_t)); // Disable UART function UARTDisable(UART0_BASE); // Disable all UART module interrupts UARTIntDisable(UART0_BASE, 0x1FFF); // Set IO clock as UART clock source UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); // Map UART signals to the correct GPIO pins and configure them as // hardware controlled. GPIO-A pin 0 and 1 IOCPinConfigPeriphOutput(GPIO_A_BASE, PIN_UART_TXD, IOC_MUX_OUT_SEL_UART0_TXD); GPIOPinTypeUARTOutput(GPIO_A_BASE, PIN_UART_TXD); IOCPinConfigPeriphInput(GPIO_A_BASE, PIN_UART_RXD, IOC_UARTRXD_UART0); GPIOPinTypeUARTInput(GPIO_A_BASE, PIN_UART_RXD); // Configure the UART for 115,200, 8-N-1 operation. // This function uses SysCtrlClockGet() to get the system clock // frequency. This could be also be a variable or hard coded value // instead of a function call. UARTConfigSetExpClk(UART0_BASE, SysCtrlIOClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // Enable UART hardware UARTEnable(UART0_BASE); // Disable FIFO as we only one 1byte buffer UARTFIFODisable(UART0_BASE); // Raise interrupt at end of tx (not by fifo) UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_EOT); // Register isr in the nvic and enable isr at the nvic UARTIntRegister(UART0_BASE, uart_isr_private); // Enable the UART0 interrupt IntEnable(INT_UART0); }
void Uart::enable(uint32_t baudrate) { // Get GpioConfig structures GpioConfig& rx = rx_.getGpioConfig(); GpioConfig& tx = tx_.getGpioConfig(); // Store baudrate in configuration if (baudrate != 0) { config_.baudrate = baudrate; } // Enable peripheral except in deep sleep modes (e.g. LPM1, LPM2, LPM3) SysCtrlPeripheralEnable(config_.peripheral); SysCtrlPeripheralSleepEnable(config_.peripheral); SysCtrlPeripheralDeepSleepDisable(config_.peripheral); // Disable peripheral previous to configuring it UARTDisable(config_.peripheral); // Set IO clock as UART clock source UARTClockSourceSet(config_.base, config_.clock); // Configure the UART RX and TX pins IOCPinConfigPeriphInput(rx.port, rx.pin, rx.ioc); IOCPinConfigPeriphOutput(tx.port, tx.pin, tx.ioc); // Configure the UART GPIOs GPIOPinTypeUARTInput(rx.port, rx.pin); GPIOPinTypeUARTOutput(tx.port, tx.pin); // Configure the UART UARTConfigSetExpClk(config_.base, SysCtrlIOClockGet(), config_.baudrate, config_.mode); // Disable FIFO as we only use a one-byte buffer UARTFIFODisable(config_.base); // Raise an interrupt at the end of transmission UARTTxIntModeSet(config_.base, UART_TXINT_MODE_EOT); // Enable UART hardware UARTEnable(config_.base); }
//***************************************************************************** // // This function sets up UART0 to be used for a console to display information // as the example is running. // //***************************************************************************** void InitConsole(void) { // // Map UART signals to the correct GPIO pins and configure them as // hardware controlled. // IOCPinConfigPeriphOutput(EXAMPLE_GPIO_UART_BASE, EXAMPLE_PIN_UART_TXD, IOC_MUX_OUT_SEL_UART0_TXD); GPIOPinTypeUARTOutput(EXAMPLE_GPIO_UART_BASE, EXAMPLE_PIN_UART_TXD); IOCPinConfigPeriphInput(EXAMPLE_GPIO_UART_BASE, EXAMPLE_PIN_UART_RXD, IOC_UARTRXD_UART0); GPIOPinTypeUARTInput(EXAMPLE_GPIO_UART_BASE, EXAMPLE_PIN_UART_RXD); // // Initialize the UART (UART0) for console I/O. // UARTStdioInit(0); }
void Uart::enable(uint32_t baudrate, uint32_t config, uint32_t mode) { // Store the UART baudrate, configuration and mode baudrate_ = baudrate; config_ = config; mode_ = mode; // Enable peripheral except in deep sleep modes (e.g. LPM1, LPM2, LPM3) SysCtrlPeripheralEnable(uart_.peripheral); SysCtrlPeripheralSleepEnable(uart_.peripheral); SysCtrlPeripheralDeepSleepDisable(uart_.peripheral); // Disable peripheral previous to configuring it UARTDisable(uart_.peripheral); // Set IO clock as UART clock source UARTClockSourceSet(uart_.base, uart_.clock); // Configure the UART RX and TX pins IOCPinConfigPeriphInput(rx_.getPort(), rx_.getPin(), rx_.getIoc()); IOCPinConfigPeriphOutput(tx_.getPort(), tx_.getPin(), tx_.getIoc()); // Configure the UART GPIOs GPIOPinTypeUARTInput(rx_.getPort(), rx_.getPin()); GPIOPinTypeUARTOutput(tx_.getPort(), tx_.getPin()); // Configure the UART UARTConfigSetExpClk(uart_.base, SysCtrlIOClockGet(), baudrate_, config_); // Disable FIFO as we only use a one-byte buffer UARTFIFODisable(uart_.base); // Raise an interrupt at the end of transmission UARTTxIntModeSet(uart_.base, mode_); // Enable UART hardware UARTEnable(uart_.base); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(hello_world_process, ev, data) { static struct etimer timer; static int count; PROCESS_BEGIN(); /* i2c_init(I2C_SCL_PORT, I2C_SCL_PIN, I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_NORMAL_BUS_SPEED);*/ etimer_set(&timer, CLOCK_CONF_SECOND * 1); count = 0; relay_enable(PORT_D,LED_RELAY_PIN); while(1) { PROCESS_WAIT_EVENT(); if(ev == PROCESS_EVENT_TIMER) { if(count %2 == 0){ //relay_on(PORT_D,LED_RELAY_PIN); int delayIndex; unsigned int pwmDutyCycle = 0x0000; // // Initialize the interrupt counter. // int g_ui32Counter = 0; // // Set the clocking to run directly from the external crystal/oscillator. // (no ext 32k osc, no internal osc) // SysCtrlClockSet(false, false, 32000000); // // Set IO clock to the same as system clock // SysCtrlIOClockSet(32000000); // // The Timer0 peripheral must be enabled for use. // SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_GPT0); // // Set up the serial console to use for displaying messages. This is // just for this example program and is not needed for Timer operation. // //InitConsole(); // // Display the example setup on the console. // UARTprintf("16-Bit Timer PWM ->"); UARTprintf("\n Timer = Timer0B"); UARTprintf("\n Mode = PWM with variable duty cycle"); // // Configure GPTimer0A as a 16-bit PWM Timer. // TimerConfigure(GPTIMER0_BASE, GPTIMER_CFG_SPLIT_PAIR | GPTIMER_CFG_A_PWM | GPTIMER_CFG_B_PWM); // // Set the GPTimer0B load value to 1sec by setting the timer load value // to SYSCLOCK / 255. This is determined by: // Prescaled clock = 16Mhz / 255 // Cycles to wait = 1sec * Prescaled clock TimerLoadSet(GPTIMER0_BASE, GPTIMER_A, SysCtrlClockGet() / 4000); TimerControlLevel(GPTIMER0_BASE, GPTIMER_A, false); // Configure GPIOPortA.0 as the Timer0_InputCapturePin.1 IOCPinConfigPeriphOutput(GPIO_A_BASE, GPIO_PIN_0, IOC_MUX_OUT_SEL_GPT0_ICP1); // Tell timer to use GPIOPortA.0 // Does Direction Selection and PAD Selection GPIOPinTypeTimer(GPIO_A_BASE, GPIO_PIN_0); // // Enable processor interrupts. // IntMasterEnable(); // // Enable GPTimer0B. // TimerEnable(GPTIMER0_BASE, GPTIMER_A); UARTprintf("\n"); // // Loop forever while the Timer0B runs. // while(1) { for (delayIndex = 0; delayIndex < 100000; delayIndex++); pwmDutyCycle += 0x0F; pwmDutyCycle &= 0xFFFF; TimerMatchSet(GPTIMER0_BASE, GPTIMER_A, pwmDutyCycle); UARTprintf("PWM DC Value: %04X -- %04X -- %04X\r", pwmDutyCycle, TimerValueGet(GPTIMER0_BASE, GPTIMER_A), TimerMatchGet(GPTIMER0_BASE, GPTIMER_A) ); } //SENSORS_ACTIVATE(cc2538_temp_sensor); // printf( "%d is temp\n",cc2538_temp_sensor.value); } else { //relay_off(PORT_D,LED_RELAY_PIN); } /* if(count %2 == 0) { relay_toggle(PORT_D,LED_RELAY_PIN); relay_status(PORT_D,LED_RELAY_PIN); } */ count ++; etimer_reset(&timer); } } PROCESS_END(); }
/************************************************************************************************* * @fn HalUARTOpenIsr() * * @brief Open a port based on the configuration * * @param port - UART port * config - contains configuration information * cBack - Call back function where events will be reported back * * @return Status of the function call *************************************************************************************************/ uint8 HalUARTOpenIsr(uint8 port, halUARTCfg_t *config) { if (uartRecord.configured) { HalUARTClose(port); } if (config->baudRate > HAL_UART_BR_115200) { return HAL_UART_BAUDRATE_ERROR; } if (((uartRecord.rx.pBuffer = osal_mem_alloc(config->rx.maxBufSize)) == NULL) || ((uartRecord.tx.pBuffer = osal_mem_alloc(config->tx.maxBufSize)) == NULL)) { if (uartRecord.rx.pBuffer != NULL) { osal_mem_free(uartRecord.rx.pBuffer); uartRecord.rx.pBuffer = NULL; } return HAL_UART_MEM_FAIL; } if(config->flowControl) { IOCPinConfigPeriphOutput(GPIO_D_BASE, GPIO_PIN_3, IOC_MUX_OUT_SEL_UART1_RTS); GPIOPinTypeUARTOutput(GPIO_D_BASE, GPIO_PIN_3); IOCPinConfigPeriphInput(GPIO_B_BASE, GPIO_PIN_0, IOC_UARTCTS_UART1); GPIOPinTypeUARTInput(GPIO_B_BASE, GPIO_PIN_0); } IntEnable(HAL_UART_INT_CTRL); uartRecord.configured = TRUE; uartRecord.baudRate = config->baudRate; uartRecord.flowControl = config->flowControl; uartRecord.flowControlThreshold = (config->flowControlThreshold > config->rx.maxBufSize) ? 0 : config->flowControlThreshold; uartRecord.idleTimeout = config->idleTimeout; uartRecord.rx.maxBufSize = config->rx.maxBufSize; uartRecord.tx.maxBufSize = config->tx.maxBufSize; uartRecord.intEnable = config->intEnable; uartRecord.callBackFunc = config->callBackFunc; UARTConfigSetExpClk(HAL_UART_PORT, SysCtrlClockGet(), UBRRTable[uartRecord.baudRate], (UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE)); /* FIFO level set to 1/8th for both RX and TX which is 2 bytes */ UARTFIFOLevelSet(HAL_UART_PORT, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTFIFOEnable(HAL_UART_PORT); /* Clear and enable UART TX, RX, CTS and Recieve Timeout interrupt */ UARTIntClear(HAL_UART_PORT, (UART_INT_RX | UART_INT_TX | UART_INT_CTS | UART_INT_RT )); UARTIntEnable(HAL_UART_PORT, (UART_INT_RX | UART_INT_TX | UART_INT_CTS | UART_INT_RT )); if(config->flowControl) { /* Enable hardware flow control by enabling CTS and RTS */ HWREG(HAL_UART_PORT + UART_O_CTL) |= (UART_CTL_CTSEN | UART_CTL_RTSEN ); } UARTEnable(HAL_UART_PORT); return HAL_UART_SUCCESS; }
/************************************************************************************************** * @fn npSpiInit * * @brief This function is called to set up the SPI interface. * * input parameters * * None. * * output parameters * * None. * * @return None. ************************************************************************************************** */ void npSpiInit(void) { uint32 ulDummy; if (ZNP_CFG1_UART == znpCfg1) { return; } /* Configure SRDY and deassert SRDY */ GPIOPinTypeGPIOOutput(HAL_SPI_SRDY_BASE, HAL_SPI_SRDY_PIN); GPIOPinWrite(HAL_SPI_SRDY_BASE, HAL_SPI_SRDY_PIN, HAL_SPI_SRDY_PIN); /* Configure MRDY and deassert MRDY */ GPIOPinTypeGPIOInput(HAL_SPI_MRDY_BASE, HAL_SPI_MRDY_PIN); GPIOPinWrite(HAL_SPI_MRDY_BASE, HAL_SPI_MRDY_PIN, HAL_SPI_MRDY_PIN); /* Enable SSI peripheral module */ SysCtrlPeripheralEnable(BSP_SPI_SSI_ENABLE_BM); /* Delay is essential for this customer */ SysCtrlDelay(32); /* Configure pin type */ GPIOPinTypeSSI(BSP_SPI_BUS_BASE, (BSP_SPI_MOSI | BSP_SPI_MISO | BSP_SPI_SCK | HAL_SPI_SS_PIN)); /* Map SSI signals to the correct GPIO pins and configure them as HW ctrl'd */ IOCPinConfigPeriphOutput(BSP_SPI_BUS_BASE, BSP_SPI_MISO, IOC_MUX_OUT_SEL_SSI0_TXD); IOCPinConfigPeriphInput(BSP_SPI_BUS_BASE, BSP_SPI_SCK, IOC_CLK_SSIIN_SSI0); IOCPinConfigPeriphInput(BSP_SPI_BUS_BASE, BSP_SPI_MOSI, IOC_SSIRXD_SSI0); IOCPinConfigPeriphInput(BSP_SPI_BUS_BASE, HAL_SPI_SS_PIN, IOC_SSIFSSIN_SSI0); /* Disable SSI function */ SSIDisable(BSP_SPI_SSI_BASE); /* Set system clock as SSI clock source */ SSIClockSourceSet(BSP_SPI_SSI_BASE, SSI_CLOCK_SYSTEM); /* Configure SSI module to Motorola/Freescale SPI mode 3 Slave: * Polarity = 1, observed in scope from MSP430 master * Phase = 1, observed in scope from MSP430 master * Word size = 8 bits * Clock = 2MHz, observed MSP430 master clock is 2049180Hz */ SSIConfigSetExpClk(BSP_SPI_SSI_BASE, SysCtrlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_SLAVE, 2000000UL, 8); /* Register SPI uDMA complete interrupt */ SSIIntRegister(BSP_SPI_SSI_BASE, &npSpiUdmaCompleteIsr); /* Enable uDMA complete interrupt for SPI RX and TX */ SSIDMAEnable(BSP_SPI_SSI_BASE, SSI_DMA_RX | SSI_DMA_TX); /* Configure SPI priority */ IntPrioritySet(INT_SSI0, HAL_INT_PRIOR_SSI0); IntPrioritySet(INT_GPIOB, HAL_INT_PRIOR_SSI_MRDY); /* Enable the SSI function */ SSIEnable(BSP_SPI_SSI_BASE); GPIOIntTypeSet(HAL_SPI_MRDY_BASE, HAL_SPI_MRDY_PIN, GPIO_BOTH_EDGES); GPIOPortIntRegister(HAL_SPI_MRDY_BASE, *npSpiMrdyIsr); GPIOPinIntEnable(HAL_SPI_MRDY_BASE, HAL_SPI_MRDY_PIN); /* Initialize uDMA for SPI */ npSpiUdmaInit(); }
//***************************************************************************** // // Configure the UART and perform reads and writes using polled I/O. // //***************************************************************************** int main(void) { char cThisChar; // // Set the clocking to run directly from the external crystal/oscillator. // (no ext 32k osc, no internal osc) // SysCtrlClockSet(false, false, SYS_CTRL_SYSDIV_32MHZ); // // Set IO clock to the same as system clock // SysCtrlIOClockSet(SYS_CTRL_SYSDIV_32MHZ); // // Enable UART peripheral module // SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_UART0); // // Disable UART function // UARTDisable(UART0_BASE); // // Disable all UART module interrupts // UARTIntDisable(UART0_BASE, 0x1FFF); // // Set IO clock as UART clock source // UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); // // Map UART signals to the correct GPIO pins and configure them as // hardware controlled. // IOCPinConfigPeriphOutput(EXAMPLE_GPIO_BASE, EXAMPLE_PIN_UART_TXD, IOC_MUX_OUT_SEL_UART0_TXD); GPIOPinTypeUARTOutput(EXAMPLE_GPIO_BASE, EXAMPLE_PIN_UART_TXD); IOCPinConfigPeriphInput(EXAMPLE_GPIO_BASE, EXAMPLE_PIN_UART_RXD, IOC_UARTRXD_UART0); GPIOPinTypeUARTInput(EXAMPLE_GPIO_BASE, EXAMPLE_PIN_UART_RXD); // // Configure the UART for 115,200, 8-N-1 operation. // This function uses SysCtrlClockGet() to get the system clock // frequency. This could be also be a variable or hard coded value // instead of a function call. // UARTConfigSetExpClk(UART0_BASE, SysCtrlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART0_BASE); // // Put a character to show start of example. This will display on the // terminal. // UARTCharPut(UART0_BASE, '!'); // // Enter a loop to read characters from the UART, and write them back // (echo). When a line end is received, the loop terminates. // do { // // Read a character using the blocking read function. This function // will not return until a character is available. // cThisChar = UARTCharGet(UART0_BASE); // // Write the same character using the blocking write function. This // function will not return until there was space in the FIFO and // the character is written. // UARTCharPut(UART0_BASE, cThisChar); // // Stay in the loop until either a CR or LF is received. // } while((cThisChar != '\n') && (cThisChar != '\r')); // // Put a character to show the end of the example. This will display on // the terminal. // UARTCharPut(UART0_BASE, '@'); // // Enter an infinite loop. // while(1) { } }