//Send command over UART to skinproc
unsigned char sendTactileCommand(unsigned char length, unsigned char *frame) {
    static int i;
    static unsigned char val;

    tx_idx = frame[0];
    for (i = 0; i < length; i++) {
        val = frame[i];
        if (TACTILEUART) {
            while(BusyUART2());
            WriteUART2(val);
        }
    }
    return 1;
}
Beispiel #2
0
//General blocking UART send function, appends basic checksum
unsigned char uartSend(unsigned char length, unsigned char *frame) {
    int i;
    unsigned char checksum = 0;

    while(BusyUART2());
    WriteUART2(length);
    while(BusyUART2());
    WriteUART2(~length);

    checksum = 0xFF;

    //send payload data
    for (i = 0; i < length; i++) {
        checksum += frame[i];
        while(BusyUART2());
        WriteUART2(frame[i]);
    }

    //Send Checksum Data
    while(BusyUART2());
    WriteUART2(checksum);
    return 1;
}
Beispiel #3
0
//General blocking UART send function, appends basic checksum
unsigned char uartSend(unsigned char length, unsigned char *frame) {
    int i,j;
    
    // Calculate CRC and store at end of packet
    frame[length-1] = calculate_crc8(frame,length-1);

    LED_3=!LED_3;
    
    //send payload data
    for (i = 0; i < length; i++) {
        while(BusyUART2());
        WriteUART2(frame[i]);
        for(j = 0; j < 200; j++); //Brief wait allows mbed to keep up
    }

    return 1;
}
Beispiel #4
0
//=================================================================================================
//	Function name: UART Transmit Interrupt handler.
//	-----------------------------------------------
//	Description:
//
//	UART Transmit interrupt handler. This interrupt handler is responsible for transmitting.
//=================================================================================================
//
avixDeclareISR(_U2TXInterrupt, no_auto_psv)
{
	unsigned char 	buffer[4];
	int 			i;
	int 			nrChars;
	
	nrChars = avixPipe_ReadFromISR(pipeTransmit, buffer, sizeof(buffer)/sizeof(buffer[0]));
	
	for (i = 0; i < nrChars; i++)
	{
		WriteUART2(buffer[i]);
	}
	
	//-----------------------------------------------------------------------------------------
	// Activate the pipe callback to test if the transmit interrupt must be disabled since no
	// characters to transmit are available anymore. For this purpose pass the number of
	// characters that was read from the pipe.
	//-----------------------------------------------------------------------------------------
	avixPipe_StopDeviceFromISR(pipeTransmit, nrChars);
}