Example #1
0
/*#if defined(SUPMCU_GPSRM1_REVA) \
    ||  defined(SUPMCU_GPSRM1_REVB) \
    ||  defined(SUPMCU_GPSRM1_REVC)
*/
void __attribute__ ((interrupt,no_auto_psv)) _U2RXInterrupt(void) {
  if(gps_enabled()) {
    // PIC24 requires explicit clear of UART Rx interrupt flag!
    U2RX_Clear_Intr_Status_Bit;
    gps_NMEA_rcv(ReadUART2());
  }
  else {
    csk_uart1_inchar(ReadUART2());
  }
}
Example #2
0
void _ISR_PSV _U2RXInterrupt(void) {	// UART2 RX [6zb]
    //InterruptTest6++;
    __builtin_disi(0x3FFF); //disable interrupts up to priority 6 for n cycles
    _U2RXIF = 0; 	// interrupt flag reset
    ClrWdt();		// [1]
    unsigned char DatoRx;
    DatoRx = ReadUART2();
    if(StatoSeriale[PORT_COM2] == WAIT_MESSAGE)
    {   //  time-out dei dati in ricezione non sia scaduto, altrimenti
        if (!TimerOutRxModbus[PORT_COM2])
        {   FreeRxBuffer(PORT_COM2);
        }
        TimerOutRxModbus[PORT_COM2] = TIME_OUT_MODBUS;
        *RxPointer[PORT_COM2] = DatoRx; //  Salva nel buffer il dato ricevuto
        RxPointer[PORT_COM2]++;
        RxNByte[PORT_COM2]++;
        if (RxNByte[PORT_COM2] >= MODBUS_N_BYTE_RX)     //  se ricevuti piĆ¹ caratteri della lunghezza del buffer
        {   RxPointer[PORT_COM2] = ModbusRxBuff[PORT_COM2]; //  azzera il puntatore di ricezione
            RxNByte[PORT_COM2] = 0;                 //  e il numero di byte ricevuti
        }
    }
    DISICNT = 0; //re-enable interrupts

    //InterruptTest6--;
}
Example #3
0
// UART2 RX ISR
void __attribute__ ((interrupt,no_auto_psv)) _U2RXInterrupt(void)
{
    char c;

    // Clear the interrupt status of UART2 RX
    U2RX_Clear_Intr_Status_Bit;

    // Wait for data to become available
    //while(!DataRdyUART2());

    // Read a character
    //c = ReadUART2();

    // Read a character
    c = read();

    // Valid Chracter returned
    if (c) {

        // Write character out to USB when ready
        while(BusyUART3());
        WriteUART3((unsigned int)c);

        // Clear out any garbage characters
        while(DataRdyUART2())
            ReadUART2();

    }

    // Print out GPS info
//    displayGPSInfo();
    
}
Example #4
0
//=================================================================================================
//	Function name: UART Receive Interrupt handler.
//	----------------------------------------------
//	Description:
//
//	UART Receive interrupt handler. This interrupt handler is responsible for receiving.
//=================================================================================================
//
avixDeclareISR(_U2RXInterrupt, no_auto_psv)
{
	tavixMsgId		msg;
	
	avixSFR(IFS1, U2RXIF, WRITE_BF, 0);	// Atomic clear of receive interrupt bit.
	msg = avixMsg_AllocateFromISR(MSG_TYPE_SERIAL_CONTROL);		// The type of the message is
	avixMsg_PutCharFromISR(msg, ReadUART2());					// used to distinguish from 
	avixMsgQThread_SendFromISR(msg, tUart);						// the data connection message.
}
Example #5
0
void __attribute__((interrupt, no_auto_psv)) _U2RXInterrupt(void)
{
	static uint8_t c = 0;
	U2RX_Clear_Intr_Status_Bit;
	while (!DataRdyUART2());
	c = ReadUART2();
	enqueue(&rx_queue, &c);
	if (rx_handler) {
		uckernel_submit_isr_task(rx_handler, NULL, NULL);
	}
}
Example #6
0
int command_received(void){
	while(DataRdyUART2()){
		*Serial.receiveddata = ReadUART2();
		Serial.receiveddata++;	
	}
	if(Serial.receiveddata != Serial.rbuf){
		if(*(Serial.receiveddata-1) == '\r'){
			*(Serial.receiveddata-1) = '\0';
			Serial.receiveddata = Serial.rbuf;
			return 1;		
		}
	}
	return 0;
}
Example #7
0
void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void){
	IFS1bits.U2RXIF = 0;
	while(DataRdyUART2())
	{
		*Serial.receiveddata = ReadUART2();
		Serial.receiveddata++;
	}	
	if((Serial.rbuf[0] == 's') && 
	   (Serial.rbuf[1] == 't') && 
	   (Serial.rbuf[2] == 'p') && 
	   (Serial.rbuf[3] == '\r')) 
	{
		stop = 1;
	}
	if((Serial.rbuf[0] == 'r') && 
	   (Serial.rbuf[1] == 's') && 
	   (Serial.rbuf[2] == 't') && 
	   (Serial.rbuf[3] == '\r'))
	{
		reset = 1;
	}
}
Example #8
0
File: uart.c Project: sbalula/mola
void __attribute__((__interrupt__,auto_psv)) _U2RXInterrupt(void){
	IFS1bits.U2RXIF = 0;

	//Save the character into Serial.rbuf
	*Serial.receiveddata = ReadUART2();

	//STP & RST
	if(Serial.rbuf[3] == '\r'){
		if((Serial.rbuf[0] == 's') && 
		   (Serial.rbuf[1] == 't') && 
		   (Serial.rbuf[2] == 'p')) 
		{
			stop = 1;
			Serial.rbuf[3] = '\0';	//para remover o '\r' de modo a nao voltar a entrar no if...
			Serial.receiveddata = Serial.rbuf;	//para garantir que quando voltar a escrever comeca do inicio
			cmd_received = 0;
			return;
		}
		if((Serial.rbuf[0] == 'r') && 
		   (Serial.rbuf[1] == 's') && 
		   (Serial.rbuf[2] == 't'))
		{
			printf("RST\r");
			delay_ms(500); //para o pic ter tempo de mandar o comando correctamente
			asm("RESET");
		}
	}

	//In order to avoid buffer overflow & reset buffer when '\r' is received
	if((Serial.receiveddata == &Serial.rbuf[79]) || (*Serial.receiveddata == '\r')){
		*Serial.receiveddata = '\0';
		Serial.receiveddata = Serial.rbuf;
		cmd_received = 1;
	}
	else Serial.receiveddata++;
}