Пример #1
0
void SpiUartDevice::initUart(unsigned long baudrate) 
{
    configureUart(baudrate);
    
    if(!uartConnected())
	{ 
        while(1) 
		{
            // Lock up if we fail to initialise SPI UART bridge.
        }; 
    }
}
Пример #2
0
void SpiUartDevice::initUart(unsigned long baudrate) {
  /*
   * Initialise the UART.
   *
   * If initialisation fails this method does not return.
   */

  // Initialise and test SC16IS750
  configureUart(baudrate);

  if(!uartConnected()){ 
    while(1) {
      // Lock up if we fail to initialise SPI UART bridge.
    };
  }

  // The SPI UART bridge is now successfully initialised.
}
Пример #3
0
void initUART(unsigned long baudrate)
{
	
	//setBaudRate(baudrate);
	//writeRegister(0x03, 0xBF); // access EFR register
	//writeRegister(0x02, 0xD0); // enable enhanced registers
	//writeRegister(0x03, 0x07); // 8 data bit, 2 stop bit, no parity
	//writeRegister(0x02, 0x06); // reset TXFIFO, reset RXFIFO, non FIFO mode
	//writeRegister(0x02, 0x01); // enable FIFO mode  
	
	//if(!uartConnected()) {SET_BIT(PORTB, 1); while(1);}
	//Line Control Register: Enable Writing DLH & DLL
  //& set no Parity, 2 stop bit, and 8 bit word length
  writeRegister(LCR,0x83);
  
  //Division registers DLL & DLH
  // Write '96' to get 9600 baud rate
  //Assumes you have the version with the ~14MHz crystal
  // (16x9600 = 153600 = 14.7456Mhz/96)
  // (16x38400 = 614400 = 14.7456Mhz/24)
  // (16x115200 = 1843200 = 14.7456Mhz/8)
  writeRegister(DLL,baudrate);
  writeRegister(DLH,0x00); 
  
  //Line Control Register: Disnable Writing DLH & DLL
  //Same setup 
  writeRegister(LCR,0x03);
  
  //Modem Control Register
  //Normal Operating Mode
   writeRegister(MCR,0x00);
 
  //FIFO Control Register: Enable the FIFO and no other features
  writeRegister(FCR,0x07);
  
  if (!uartConnected()) flashLED(RED);  
}