static void UART2_RxTxHandler(void)
{
	uint32_t IntStatus, byteCnt, timeout = 1000000;
	uint8_t c;
	IntStatus = UARTIntStatus(UART2_BASE, true);
	UARTIntClear(UART2_BASE, IntStatus);
	if(IntStatus & UART_INT_TX)
	{
		byteCnt = RINGBUF_GetFill(&long_Uart2_TxRingBuf);
		if (byteCnt)
		{
			RINGBUF_Get(&long_Uart2_TxRingBuf, &c);
			UARTCharPutNonBlocking(UART2_BASE, c);
			if (byteCnt == 1)
			{
				UARTIntDisable(UART2_BASE, UART_INT_TX);
			}
		}
		else
		{
			UARTIntDisable(UART2_BASE, UART_INT_TX);
		}
	}
	else if (IntStatus & (UART_INT_RX | UART_INT_RT))
	{
		while(!UARTCharsAvail(UART2_BASE) && (timeout--));
		c = UARTCharGet(UART2_BASE);
		RINGBUF_Put(&long_Uart0_RxRingBuf,c);
	}
	else
	{
		c = UARTCharGet(UART2_BASE);
	}
}
Beispiel #2
0
/******************************************************************************
*																			  *
* \brief  Read as many characters from the UART FIFO as we can and move the   *
*         into the CDC transmit buffer.\n                                     *
*                                                                             *
* \param none.																  *
*																		      *
* \return UART error flags read during data reception.                        *
*                                                                             *
******************************************************************************/
static int ReadUARTData(void)
{
    int lChar, lErrors;
    unsigned char ucChar;
    unsigned int ulSpace;

    
    /* Clear our error indicator. */
    
    lErrors = 0;

    
    /* How much space do we have in the buffer? */
    
    ulSpace = USBBufferSpaceAvailable((tUSBBuffer *)&g_sTxBuffer);

    
    /* Read data from the UART FIFO until there is none left or we run
       out of space in our receive buffer.
    */
    while(ulSpace && UARTCharsAvail(USB_UART_BASE))
    {
        
        /* Read a character from the UART FIFO into the ring buffer if no
           errors are reported.
        */
        lChar = UARTCharGetNonBlocking(USB_UART_BASE);

        
        /* If the character did not contain any error notifications,
           copy it to the output buffer.
        */
        if(!(lChar & ~0xFF))
        {
            ucChar = (unsigned char)(lChar & 0xFF);
            USBBufferWrite((tUSBBuffer *)&g_sTxBuffer,
                           (unsigned char *)&ucChar, 1);

            
            /* Decrement the number of bytes we know the buffer can accept. */
            
            ulSpace--;
        }
        else
        {
            
           /* Update our error accumulator. */
            
           lErrors |= lChar;
        }

        /* Update our count of bytes received via the UART. */
        
        g_ulUARTRxCount++;
    }

    /* Pass back the accumulated error indicators. */
    
    return(lErrors);
}
Beispiel #3
0
//*****************************************************************************
//
//! xuart0301 test execute main body.
//
//! \return None.
//
//*****************************************************************************
static void xuart0301Execute(void)
{
    unsigned char UartData = 0;
    unsigned char i = 0;
    xtBoolean bTmpBoolean = xfalse;

    UART_Print("\r\nPlease wait 1 s then type the follow string\r\n");
    UART_Print("123456789ABCDE\r\n");

    bTmpBoolean = UARTCharsAvail(UART_BASE);
    TestAssert((xfalse == bTmpBoolean),
            "UART 0301: Function UARTCharsAvail failed!\r\n");
    
    while((UartData = UARTCharGet(UART_BASE)) != '\n')
    {
        UARTCharPut(UART_BASE, UartData);
        if(++i >= 15)
        {
            break;
        }
    }
    UARTCharPut(UART_BASE, '\r');
    UARTCharPut(UART_BASE, '\n');

}
Beispiel #4
0
//UART Int Handler. Will handle the data recieved and put in an array. WILL NOT UNDERSTAND JUST STORE
void Uart2IntHandler(void){
	unsigned long ulStatus;

	ulStatus=UARTIntStatus(UART2_BASE, true);	//This reports if the interrupt was a transmit recieve etc, only reports one's setup to be detected in initalization could possibly remove transmit detection

	UARTIntClear(UART2_BASE, ulStatus);	//Clears the interrupt so it does not detect itself.

	if(ulStatus & UART_INT_TX){
		//Transmit was requested I don't think anything needs to be done here I could probably get rid of this and the interrupt for it but for now im leaving it. UARTSend does this job in a cleaner way
	}else if(ulStatus & UART_INT_RX || ulStatus & UART_INT_RT){	//If recieved data
		GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x08);
		while(UARTCharsAvail(UART2_BASE)){	//While there is still data available to read
			char buffer = UARTCharGetNonBlocking(UART2_BASE);	//Read the data into a buffer for scanning
			if((buffer == 0xFA)&&(commandAddress == -2)){	//Is it the first dummy byte
				commandAddress=-1;	//Set the command Address to -1 this way the dummy byte is the only starting byte for a packet to be accepeted
			}else if((buffer == 0xEB)&&(commandAddress == -1)){	//Is the second dummy byte read
				commandAddress=0;	//Prepare to read data the dummy byte's have been validated
			}else if(commandAddress>=0){						//Read in because it's not a dummy byte, prep for reading
				recievedCommands[commandAddress]=buffer;
				commandAddress++;	//Some efficiency could be done here. Remove this line than change the bottom to have ++commandAddress. But that's nitpicky stuff
				commandAddress = (commandAddress>4) ? -2 : commandAddress;			//If greater than 6 set to -1 else set to self
			}
		}
		//UARTCount = ((UARTCount+1)%65534); //Again not sure of datatype sizes so go with what works right.
	}

}
Beispiel #5
0
void UART0_Handler()
{
  c_pos_intEnter();

  uint32_t status;

  status = UARTIntStatus(PORTCFG_CON_USART, true);
  UARTIntClear(PORTCFG_CON_USART, status);

  if (status & UART_INT_TX)
    c_nos_putcharReady();

#if NOSCFG_FEATURE_CONIN == 1
  if (status & (UART_INT_RX | UART_INT_RT)) {

    unsigned char ch;

    while (UARTCharsAvail(PORTCFG_CON_USART)) {

      ch = UARTCharGetNonBlocking(PORTCFG_CON_USART);
      c_nos_keyinput(ch);
    }
  }
#endif


  c_pos_intExitQuick();
}
Beispiel #6
0
void UARTinterrupcion(void)
{
	char cThisChar;
			int n=0;
			int m_nTxBuffIn1 = 16;
		    unsigned long ulStatus;

		    //
		    // Obtengo el estado de la interrupcion
		    //
		    ulStatus = UARTIntStatus(UART1_BASE, true);
		    //
		    // Limpio los flags de interrupcion
		    //
		    UARTIntClear(UART1_BASE, ulStatus);

		    if(RIGHT_BUTTON){;}

		    if(ulStatus && UART_INT_RX){

		    }
		     while(m_nTxBuffIn1>0 && UARTCharsAvail(UART1_BASE))
		     {
		               //
		               // Lee el proximo caracter de la FIFO de recepcion.
		               //
		     cThisChar = UARTCharGetNonBlocking(UART1_BASE);

		     UARTCharPut(UART0_BASE, cThisChar);

		     m_nTxBuffIn1--;

		     n=n+1;
    }
}
Beispiel #7
0
STATIC void UARTGenericIntHandler(uint32_t uart_id) {
    pyb_uart_obj_t *self;
    uint32_t status;

    if ((self = pyb_uart_find(uart_id))) {
        status = MAP_UARTIntStatus(self->reg, true);
        // receive interrupt
        if (status & (UART_INT_RX | UART_INT_RT)) {
            MAP_UARTIntClear(self->reg, UART_INT_RX | UART_INT_RT);
            while (UARTCharsAvail(self->reg)) {
                int data = MAP_UARTCharGetNonBlocking(self->reg);
                if (MICROPY_STDIO_UART == self->uart_id && data == user_interrupt_char) {
                    // raise exception when interrupts are finished
                    mpexception_keyboard_nlr_jump();
                }
                else if (self->read_buf_len != 0) {
                    uint16_t next_head = (self->read_buf_head + 1) % self->read_buf_len;
                    if (next_head != self->read_buf_tail) {
                        // only store data if room in buf
                        self->read_buf[self->read_buf_head] = data;
                        self->read_buf_head = next_head;
                    }
                }
            }
        }
    }
}
void UARTIntHandler(void)
{
	//	UARTCharPut(UART0_BASE, 'a');
	uint32_t ui32Status;
	ui32Status = UARTIntStatus(UART3_BASE, true); //get interrupt status
	//	UARTCharPut(UART0_BASE, 'a');
	UARTIntClear(UART3_BASE, ui32Status); //clear the asserted interrupts

	//	UARTCharPut(UART0_BASE, 'a');
	while(UARTCharsAvail(UART3_BASE)) //loop while there are chars
	{
		//		UARTCharPut(UART0_BASE, 'a');
		char x = UARTCharGetNonBlocking(UART3_BASE);
		UARTCharPut(UART0_BASE, x);
		buf[it++] = x;
	}
	buf[it]='\0';
	char *ptr = strstr(buf,"OK\r\n");
	if(ptr != NULL) {
		SIM908_status = true;
	}
	//	UARTCharPutNonBlocking(UART0_BASE, 'a');
	//  buf[it]='\0';
	//
	//  if(strncmp(buf, "OK", 2) == 0) SIM908_status = true;
	//  else if(strncmp(buf,  "ERROR", 5) == 0) {
	//
	//  }
	//  else {
	//
	//  }
}
void uartb_intHandler(){
    int tmp=0;

    // detect the event that triggered the interrupt
    unsigned long intStatus=UARTIntStatus(UART_BUFFERIZED_BASE,1);
    // Clear the interrupt (done early because rtfm)
    UARTIntClear(UART_BUFFERIZED_BASE,intStatus);

    // if it is on RX fifo limit or RX timeout, put these bits in circular buffer
    if (intStatus==UART_INT_RT || intStatus==UART_INT_RX){
        UARTIntDisable(UART_BUFFERIZED_BASE,(UART_INT_RT | UART_INT_RX));
        while (UARTCharsAvail(UART_BUFFERIZED_BASE)){
            // RDA interrupt
            tmp = (rxbuf.head+1)%UART_BUFFERIZED_CBUFF_SIZE;

            if(tmp != rxbuf.tail){
                rxbuf.cbuf[rxbuf.head] = UARTCharGetNonBlocking(UART_BUFFERIZED_BASE);
                rxbuf.head = tmp;
            }
        }
        UARTIntEnable(UART_BUFFERIZED_BASE,(UART_INT_RT | UART_INT_RX));
    }
    // xxx if it is on TX fifo limit, what should we do ? loop until fifo is free again ? useless if blocking writes are used.

    // otherwise, discard whitout doing anything (done at the beginning of the function, see doc for "why ?".
}
Beispiel #10
0
//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void UART0IntHandler(void)
{
    unsigned long ulStatus;

    //
    // Get the interrrupt status.
    //
    ulStatus = UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    UARTIntClear(UART0_BASE, ulStatus);

    //
    // Loop while there are characters in the receive FIFO.
    //
    while(UARTCharsAvail(UART0_BASE))
    {
        //
        // Read the next character from the UART and write it back to the UART.
        //
        UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE));
    }
}
Beispiel #11
0
int main(void)
{
	/*Set the clocking to directly run from the crystal at 8MHz*/
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);


    /* Make the UART pins be peripheral controlled. */
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	
	/* Sets the configuration of a UART. */
	UARTConfigSetExpClk(UART0_BASE, 8000000, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    while(1)
    {

    if(UARTCharsAvail(UART0_BASE))
    {
    	/* Unsigned Char */
    	UARTCharPut(UART0_BASE,(unsigned char)(UARTCharGet(UART0_BASE)+1));
    }

    }

}
Beispiel #12
0
/**
 * Turn off interrupt sources that may interrupt us (SysTick and Ethernet) and then switch control
 * to the Boot Loader. This will never return!
 */
void halSwitchToBootloader()
{
    while(UARTCharsAvail(UART0_BASE))
    {
        UARTCharGet(UART0_BASE);
    }

    EthernetIntDisable(ETH_BASE, 0xFFFF);
    SysTickIntDisable();
    IntDisable(INT_UART0);
    UARTIntDisable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    UARTIntClear(UART0_BASE, UART_INT_RX | UART_INT_RT);


    delayMs(100);
    // Call the boot loader so that it will listen for an update on the UART.
    (*((void (*)(void))(*(unsigned long *)0x2c)))();

    //
    // The boot loader should take control, so this should never be reached.
    // Just in case, loop forever.
    //
    while(1)
    {
    }

}
Beispiel #13
0
void UARTIntHandler(void)
{
	uint32_t ui32Status;
	ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
	UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
	while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
	{
		char x = UARTCharGetNonBlocking(UART0_BASE);
		if(mode == 0 && x == 's') {
			mode = 1;
			UARTStrPut("Enter the temperature : ");
			newSet = 0;
		} else if (mode == 1) {
			if (x == 127 && newSet > 0) { // backspace
				UARTCharPut(UART0_BASE, 127);
				newSet /= 10;
			} else if (x >= 48 && x <= 57) { // digit
				UARTCharPut(UART0_BASE, x);
				newSet = newSet*10 + (x - 48);
			} else if (x == 13) { // new line (enter)
				setTemp = newSet;
				UARTStrPut("\r\nSet Temperature updated to ");
				UARTIntPut(setTemp);
				UARTCharPut(UART0_BASE, 176);
				UARTStrPut("C\r\n");
				mode = 0;
			}
		}
	}
}
Beispiel #14
0
void getValue(char* atCommand, char* response, unsigned maxLen){
    // Take control of the stdio UART
    // The wifi chip is connected to UART1
    UARTStdioConfig(1, 115200, 16000000);
    char rxBuf[200] = {0};
    unsigned index = 0;

    // Send command
    if( !(atCommand[0] == '\0') )
    {
        UARTprintf("%s\r\n", atCommand);
    }

    // read rxBuf

    // Check if data exists on uart1 (non usb uart)
    do
    {
        if( UARTCharsAvail(UART1_BASE) )
        {
            rxBuf[index] = (char)UARTCharGetNonBlocking(UART1_BASE);
            index++;
        }
    }while(index < maxLen);

    memcpy(response, rxBuf, maxLen);
    UARTStdioConfig(0, 115200, 16000000);
    return;
}
Beispiel #15
0
Datei: debug.c Projekt: DSKIM3/lk
void stellaris_uart0_irq(void)
{
	arm_cm_irq_entry();

	//
	// Get the interrrupt status.
	//
	unsigned long ulStatus = UARTIntStatus(DEBUG_UART, true);

	//
	// Clear the asserted interrupts.
	//
	UARTIntClear(DEBUG_UART, ulStatus);

	//
	// Loop while there are characters in the receive FIFO.
	//
	bool resched = false;
	while (UARTCharsAvail(DEBUG_UART)) {
		//
		// Read the next character from the UART and write it back to the UART.
		//
		unsigned char c = UARTCharGetNonBlocking(DEBUG_UART);
		cbuf_write_char(&debug_rx_buf, c, false);

		resched = true;
	}

	arm_cm_irq_exit(resched);
}
Beispiel #16
0
void UARTIntHandler(void) {
	uint32_t ui32Status;
	ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
	UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
	if(UARTCharGetNonBlocking(UART0_BASE) == 'S'){
		char m[] = "Enter The Temperature : ";
		char h[100] = "Set temperature Updated to ";
		int i;
		int l;
		l=0;
		for(i=0;m[i];i++){
					UARTCharPut(UART0_BASE, m[i]);
				}
		int x=0;
		while(1){
			char c;
			if(UARTCharsAvail(UART0_BASE)){
				c= UARTCharGetNonBlocking(UART0_BASE);
				UARTCharPut(UART0_BASE, c);
				if(c=='\r') break;
				h[27+l]=c;
				x=10*x+c-'0';
				l++;
			}
		}
		settemp = x;
		for(i=0;i<27+l;i++){
							UARTCharPut(UART0_BASE, h[i]);
						}
		UARTCharPut(UART0_BASE, '*');
		UARTCharPut(UART0_BASE, 'C');
		UARTCharPut(UART0_BASE, '\r');
		UARTCharPut(UART0_BASE,'\n');
	}
}
Beispiel #17
0
//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void UART0IntHandler(void)
{
    unsigned long ulStatus;
	tBoolean bRc;

    //
    // Get the interrrupt status.
    //
    ulStatus = UARTIntStatus(UART0_BASE, true);
    //
    // Clear the asserted interrupts.
    //
    UARTIntClear(UART0_BASE, ulStatus);

	//
	// Check what is the source of the interrupt
	//

	//if(ulStatus & UART_INT_OE)
	//{
	//}
	//else if(ulStatus & UART_INT_BE)
	//{
	//}
	//else if(ulStatus & UART_INT_PE)
	//{
	//}
	if(ulStatus & UART_INT_TX)
	{
		// TX int
		// Push next char to transmitter
		bRc = true;
		while(m_nTxBuffIn > 0 && bRc == true)
		{
			bRc = UARTCharPutNonBlocking(UART0_BASE,m_tTxBuff[m_nTxNextNdx]);
 			if(bRc == true)
			{
				m_nTxNextNdx++;
				m_nTxBuffIn--;
			}
		}
	}
	else 
	if(ulStatus & UART_INT_RX || ulStatus & UART_INT_RT)
	{
		// RX int
		// Read all RX fifo data
		while(UARTCharsAvail(UART0_BASE))
		{
			// Read the next character from the UART
			// (and write it back to the UART) ?
			#if defined(stabilizition)
			ContropMessageLoop(UART0_BASE,0);
			#else
			MessageLoop(UART0_BASE,0);
			#endif
			
		}
	}
}
Beispiel #18
0
/**
 * UART 1 - for gps module
 */
void uart4InturruptHandle(void) {
	unsigned long ulStatus1, val;
	ulStatus1 = ROM_UARTIntStatus(UART1_BASE, true);
	ROM_UARTIntClear(UART1_BASE, ulStatus1);

	while (UARTCharsAvail(UART1_BASE)) {
		val = UARTCharGetNonBlocking(UART1_BASE);
//    inputBuffer[j]=val;

		if ((val == '$')) {
			//gpsSentence[1][82] = '\0';
			gpsSentence[!toggle][j] = '\0';
			gpsBufferSize[!toggle] = j;
//			gpsSentence[!toggle][0] = j;
			j = 0;	//0 index to hold end point
			toggle = !toggle;
			message = true;

		}
		gpsSentence[!toggle][j] = val;

		if (val == '\n' || val == '\r' || val == ' ' || val == '\t') {
			j--; //if some newline is in the message, simply ignore that charater by
			//shifting the increment backwardsso
		}

		j++;
	}

}
Beispiel #19
0
/*
 *  SIOの割込みサービスルーチン
 */
void
sio_isr(intptr_t exinf)
{
	SIOPCB          *p_siopcb;

	p_siopcb = get_siopcb(exinf);

	/*
	 *  割込みのクリア
	 */
	UARTIntClear(p_siopcb->p_siopinib->base,
				 UARTIntStatus(p_siopcb->p_siopinib->base, true));

	if (UARTCharsAvail(p_siopcb->p_siopinib->base)) {
		/*
		 *  受信通知コールバックルーチンを呼び出す.
		 */
		sio_irdy_rcv(p_siopcb->exinf);
	}
	if (UARTSpaceAvail(p_siopcb->p_siopinib->base)) {
		/*
		 *  送信可能コールバックルーチンを呼び出す.
		 */
		sio_irdy_snd(p_siopcb->exinf);
	}
}
static size_t uartGet(uint8_t* data, size_t nData, void* usr)
{
    uint32_t uart_base = (uint32_t) usr;
    size_t ret = 0;
    while (ret < nData && UARTCharsAvail(uart_base))
        data[ret++] = UARTCharGet(uart_base);
    return ret;
}
Beispiel #21
0
/*
 *  シリアルI/Oポートからの文字受信
 */
int_t
sio_rcv_chr(SIOPCB *p_siopcb)
{
	if(UARTCharsAvail(p_siopcb->p_siopinib->base)){
		return(UARTCharGetNonBlocking(p_siopcb->p_siopinib->base));
	}
	return(-1);
}
Beispiel #22
0
    virtual long SerialDataAvailable(int serialDevice) {
        if (serialDevice == 0) {
            return UARTCharsAvail(UART0_BASE);
        } else {
            return 0;
        }

    }
Beispiel #23
0
void rien(void) {
    unsigned long ulStatus;
    ulStatus = UARTIntStatus(UART5_BASE, true);
    UARTIntClear(UART5_BASE, ulStatus);

    while(UARTCharsAvail(UART5_BASE)) {
        char c = UARTCharGet(UART5_BASE);
        switch(UART5_buffer_state) {
        case 1:
            //On reçoit alpha, beta et gamma
            *UART5_buffer_pointer = c;
            UART5_buffer_pointer++;
            if (UART5_buffer_pointer - UART5_buffer >= 3) {
                UART5_buffer_state = 0;
                UART5_buffer_pointer = UART5_buffer;
                unsigned char should_move = UART5_buffer[2];
                if (should_move) {
                    go_angle = UART5_buffer[0] | (UART5_buffer[1] << 8);
                    if (go_angle > 360)
                    	go_angle = 0;
                	new_order = 1;
                }
                else {
                	new_order = 0;
                }
            }
            break;
        default:
            //On reçoit un int de start ou une commande aimant
            if ((c == 0xFE) && (UART5_buffer_pointer - UART5_buffer == 3)) {
                //Aimant activé
                UART5_buffer_pointer = UART5_buffer;
                actuators_servo_raise(0);
                actuators_servo_raise(1);
            }
            else if ((c == 0xFD) && (UART5_buffer_pointer - UART5_buffer == 3)) {
                //Aimant désactivé
            	actuators_servo_lower(0);
            	actuators_servo_lower(1);
                UART5_buffer_pointer = UART5_buffer;
            }
            else if (c != 0xFF) {
                //Truc pas normal, on reset la stack
                UART5_buffer_pointer = UART5_buffer;
            }
            else {
                //Octet de start
                *UART5_buffer_pointer = c;
                UART5_buffer_pointer++;
                if (UART5_buffer_pointer - UART5_buffer >= 4) {
                    //Passage en réception des angles
                    UART5_buffer_state = 1;
                    UART5_buffer_pointer = UART5_buffer;
                }
            }
        }
    }
}
Beispiel #24
0
// -----------------------------------------------------------------------------
//! \brief      This callback is invoked on Read completion of readSize/receive
//!             timeout
//!
//! \param[in]  handle - handle to the UART port
//! \param[in]  ptr    - pointer to buffer to read data into
//! \param[in]  size   - size of the data
//!
//! \return     void
// -----------------------------------------------------------------------------
static void SDITLUART_readCallBack(UART_Handle handle, void *ptr, size_t size)
{
    ICall_CSState key;
    key = ICall_enterCriticalSection();
    uint8 errStatus = 0;

    if (errStatus = ((UARTCC26XX_Handle)handle->object)->status)
    {
      //report UART error status to application 
      if(incomingRXErrorStatusAppCBFunc != NULL)
        incomingRXErrorStatusAppCBFunc(UART_ERROR_EVT, &errStatus, sizeof(errStatus));
    }

    if (size)
    {
        if (size != SDITLUART_readIsrBuf(size))
        {
            // Buffer overflow imminent. Cancel read and pass to higher layers
            // for handling
#ifdef POWER_SAVING
            RxActive = FALSE;
#endif //POWER_SAVING
            if ( sdiTransmitCB )
            {
                sdiTransmitCB(SDI_TL_BUF_SIZE,TransportTxLen);
            }
        }
    }

#ifdef POWER_SAVING
    // Read has been cancelled by transport layer, or bus timeout and no bytes in FIFO
    //    - do not invoke another read
    if ( !UARTCharsAvail(((UARTCC26XX_HWAttrs const *)(uartHandle->hwAttrs))->baseAddr) &&
            mrdy_flag )
    {
        RxActive = FALSE;
        
        // If TX has also completed then we are safe to issue call back
        if ( !TxActive && sdiTransmitCB )
        {
            sdiTransmitCB(TransportRxLen,TransportTxLen);
        }
    }
    else
    {
        UART_read(uartHandle, &isrRxBuf[0], UART_ISR_BUF_SIZE);
    }
#else
    if ( sdiTransmitCB )
    {
        sdiTransmitCB(size,0);
    }
    TransportRxLen = 0;
    UART_read(uartHandle, &isrRxBuf[0], UART_ISR_BUF_SIZE);
#endif //POWER_SAVING

    ICall_leaveCriticalSection(key);
}
Beispiel #25
0
/*
 * @brief Check and get a byte from UART/USB with interrupt disabled.
 *
 * @return the byte value on success; -1 if there's nothing in the buffer.
 */
int getSerialByteNonblocking(void) {
	int c = -1;

	if (UARTCharsAvail(UART0_BASE)) {
		c = UARTCharGetNonBlocking(UART0_BASE);
	}

	return c;
}
//##### INTERNAL BEGIN #####
//*****************************************************************************
//
// Send a wakup packet to the remote network processors UART interface.
//
// This function will send a NULL character to the UART interface repeatedly
// in order to awaken the RNP and cause it to start listening for UART packets.
//
// \return None.
//
//*****************************************************************************
void
RemoTIUARTWake(void)
{
#if 0
    bool bIntState;
    uint32_t ui32Ticks;

    //
    // Disable Master interrupts.  Record previous interrupt state to properly
    // restore it later.
    //
    bIntState = IntMasterDisable();

    //
    // Tick counter for tracking how many times we send the NULL character set.
    //
    ui32Ticks = 0;

    //
    // If the TX interrupt is enabled.  If it is assume UART is already
    // awake.  If it is not then wake up the UART on the RNP with a null char.
    //
    if((HWREG(g_ui32UARTBase + UART_O_IM) & 0x20) != UART_IM_TXIM);
    {
        do
        {
            //
            // Send consecutive NULL characters.
            //
            UARTCharPut(g_ui32UARTBase, 0);
            UARTCharPut(g_ui32UARTBase, 0);
            UARTCharPut(g_ui32UARTBase, 0);
            UARTCharPut(g_ui32UARTBase, 0);

            //
            // Delay 10 milliseconds to allow time for RNP to process and wake.
            //
            SysCtlDelay(SysCtlClockGet() / (100 * 3));
            ui32Ticks++;

        //
        // Send the NULL character set until we get a character back or we have
        // tried 10 times to get a response.
        //
        } while((ui32Ticks < 10) & (UARTCharsAvail(g_ui32UARTBase) == 0));
    }

    //
    // Restore the master interrupt enable to it previous state.
    //
    if(!bIntState)
    {
        IntMasterEnable();
    }
#endif // 0
}
Beispiel #27
0
/*************************************************************************************************
 * @fn      sbUartGetChar
 *
 * @brief   Attempt to get an Rx byte.
 *
 * @param   pCh - Pointer to the character buffer into which to read an Rx byte.
 *
 * @return  Zero or One.
 */
uint32 sbUartGetChar(uint8 *pCh)
{
  if (UARTCharsAvail(HAL_UART_PORT))
  {
    *pCh = UARTCharGetNonBlocking(HAL_UART_PORT);
    return 1;
  }

  return 0;
}
Beispiel #28
0
void readPackage(){

	//debug_red = false;
	
	while(UARTCharsAvail(UART_PC_COMM)){
		
		package[packageCounter] = (char)UARTCharGet(UART_PC_COMM);
		
		getCommand();
	}
	
	while(UARTCharsAvail(UART4_BASE)) {
		
		if (read_mpu) {
			
			sensorData[sensorDataCounter++] = (char)UARTCharGet(UART4_BASE);
		
			if (sensorDataCounter == 6) {
				read_mpu = false;
				sensorDataCounter = 0;
				
				atualizaLeiturasMPU6050();
			}
		} else if (read_sonar) {
			sonarData[sonarDataCounter++] = (char)UARTCharGet(UART4_BASE);
			
			if (sonarDataCounter == 3) {
				read_sonar = false;
				sonarDataCounter = 0;
				atualizaLeituraSonar(sonarData[0]);
			}
		} else {
			
			char aux = (char)UARTCharGet(UART4_BASE);
			
			if (aux == MESSAGE_TYPE_DADOS_MPU6050) {
				read_mpu = true;
			}
			else if (aux == MESSAGE_TYPE_DADOS_SONAR) read_sonar = true;
		}
	}
}
Beispiel #29
0
/*
 * @brief Wait and get a byte from UART/USB with interrupt disabled.
 * Program is blocked until there's an available byte or timeout.
 *
 * @param timeout Polling time before exiting (us)
 * @return the byte value on success; -1 if there's nothing in the buffer or timeout.
 */
int getSerialByteWithTimeout(uint32 timeout) {
	uint32 i;

	for (i = 0; i < timeout; i++) {
		if (UARTCharsAvail(UART0_BASE)) {
			return UARTCharGetNonBlocking(UART0_BASE);
		}
		systemDelayTenMicroSecond(1);
	}

	return -1;
}
Beispiel #30
0
void UARTIntHandler0() {
	unsigned long ulStatus;
	static char tempPacket = 0;

	ulStatus = UARTIntStatus(UART0_BASE, true);

	UARTIntClear(UART0_BASE, ulStatus);

	while (UARTCharsAvail(UART0_BASE)) {
		tempPacket = UARTCharGetNonBlocking(UART0_BASE);
	}
}