コード例 #1
0
ファイル: mac.c プロジェクト: kapaA/OpenSensor
/*==============================================================================
** Function...: rxFrameHandler
** Return.....: void
** Description: handles the incomming frame
** Created....: 09.08.2012 by Achuthan
** Modified...: dd.mm.yyyy by nn
==============================================================================*/
void rxFrameHandler(frame *tempFrame)
{

    GLOB_RET ret = GLOB_FAILURE;
    ret=packetController(tempFrame);
    
    if(ret==GLOB_SUCCESS)
    {
        switch(tempFrame->type)
        {
            case NC_PAY:
                if(expType.expectPAY)
                {
                    network_interface(INCOMING, tempFrame);
                }
                else
                {
                    #if defined (DEBUG)
                        //putsUSBUSART("I Dont expect Payload\n");
                    #endif
                }
                break;

            case PAY:
                if(expType.expectPAY)
                {
                   network_interface(INCOMING, tempFrame);
                }
                else
                {
                    #if defined (DEBUG)
                        putsUSBUSART("I Dont expect Payload\n");
                    #endif
                }
                break;

            case ACK:
                if(expType.expectACK)
                {
                    gotACK = YES;
                }
                break;

            

            default:
                break;
        }
    }
    else
    {
        #if defined (DEBUG)
            putsUSBUSART("Invalid Rx-Frame parameters\n");
        #endif
    }
}
コード例 #2
0
ファイル: main.c プロジェクト: PedroDiogo/POV
/********************************************************************
 * Function:        void ProcessMenu(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This function parses the input string given
 *					by the user.
 *
 * Note:            None
 *******************************************************************/
void ProcessMenu(void)
{
	int i; // Debug
	
	// If the line is empty return.
	if(RS232cp == 0) return;
	
	// Strip the CR/NL character.
	RS232_Out_Data[RS232cp] = '\0';
	
	// Test different menu options
	if(strcmpram2pgm("help", RS232_Out_Data) == 0)
		putrsUSBUSART("\r\nAvailable commands:\r\n\r\n* help - Displays this message, recursive style!\r\n* setMessage <text> - Defines a new message to be displayed on the POV.\r\n* showMessage - Shows the current message\r\n* version - Displays firmware version.");
	else if(strncmpram2pgm("setMessage ", RS232_Out_Data, 10) == 0)
	{				
		// Copy message
        strncpy(message, &RS232_Out_Data[11], MESSAGE_LENGTH);
        message[MESSAGE_LENGTH] = '\0';
        writeEEPROM(0x00, crc(0x00, (char) strlen(message)));
        writeEEPROM(0x01, (char) strlen(message));
        writeStrEEPROM(0x03, strlen(message), message);
        writeEEPROM(0x02, strcrc(message));

        // Display confirmation
        strcpypgm2ram(RS232_Out_Data, "\r\nYour message is now defined as:\r\n\t");
        strcat(RS232_Out_Data, message);

        putsUSBUSART(RS232_Out_Data);
	}
	else if(strcmpram2pgm("showMessage", RS232_Out_Data) == 0)
	{
		sprintf(RS232_Out_Data, "\r\nYour message is defined as:\r\n\t%s", message);
		putsUSBUSART(RS232_Out_Data);
	}
	else if(strcmpram2pgm("version", RS232_Out_Data) == 0)
		putrsUSBUSART("\r\nPOV serial configuration. Version 0.9");
	else
		putrsUSBUSART("\r\nUnknown command. Type 'help' for the list of available commands.");
	
	clearRS232Buffer = 1;
}
コード例 #3
0
void ProcessIO(void)
{   
    unsigned short result;
	static char state=VALUES;
	static char count=-1;
	static char adc_nr=0;
	static short adcchannel=0;
	char overflow=0;

    // User Application USB tasks

    if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;


	if(state == PUTHEADER){
		if( mUSBUSARTIsTxTrfReady() ){
			 putsUSBUSART(USB_Head_Buffer);
			state = VALUES;
		}
	} else {


	if( mUSBUSARTIsTxTrfReady() ){             // Wait for completion

		USB_Out_Buffer[0]++;
		count++;
		if(count>=64){ //max channels
			count=0;
			USB_Out_Buffer[0] = 60; //start character
		}
		

	//	if (count<=11) result = read_register(1, (0x0b+count) ); else
	//	result = read_register(2, (0x0b+count-12) );
		adcchannel++;
		if(adcchannel==16){
 				adcchannel=0;
				overflow=1;
		}
		result = spi_transfer(adc_nr, ( WRITE_REG | (adcchannel<<10) ));

			if(overflow==1){
 				overflow=0;
				adc_nr++;
				if(adc_nr==4) adc_nr=0;
			}

		USB_Out_Buffer[3] = result &0xFF;
		USB_Out_Buffer[2] = (result &0xFF00)>>8;

		putUSBUSART(USB_Out_Buffer,5);
		LED = !LED;
		


	 }
	}




    CDCTxService();
}		//end ProcessIO
コード例 #4
0
void PutsStringCPtr(char *str)
{
  if (!WaitToReadySerial()) return;
  putsUSBUSART(str);
  if (!WaitToReadySerial()) return;
}
コード例 #5
0
ファイル: config_cdc.c プロジェクト: kristofvl/HedgeHog
void cdc_write_conf(char* cstr) {
    putsUSBUSART(cstr);
    config_cycle = 0;
}