예제 #1
0
/** Function to process the lest received report from the host.
 *
 *  \param[in] DataArray  Pointer to a buffer where the last report data is stored
 */
void ProcessGenericHIDReport(uint8_t* DataArray)
{
	/*
		This is where you need to process the reports being sent from the host to the device.
		DataArray is an array holding the last report from the host. This function is called
		each time the host has sent a report to the device.
	*/
	switch (DataArray[0]){
		case 0xA1:
			// Control block received
			switch (DataArray[1]){
				case 0x01:
					// Reset commmand
							cli();
							WD_SET(WD_RST,WDTO_15MS);
							while(1);
					break;
				case 0x02:
					// Battery level
					break;
			}
			break;
		case 0xB1:
			// Serial data received
			Serial.store(DataArray[1]);
			break;
		default:
			// Unhandled block received
			break;
	}
}
예제 #2
0
void setupFanRPMCount()
{
  TCCR1A=0;                 // reset timer/counter1 control register A
  TCCR1B=0;              	// reset timer/counter1 control register A
  TCNT1=0;           		// counter value = 0
  //Clock source on T1, falling edge (fan pulls down)
  TCCR1B = (1 << CS10) | (1 << CS11) | (1 << CS12);

  //Setup watchdog timer for 1hz refresh
  //WDTCSR = (1 << WDCE);
  //WDTCSR = (1 << WDP0) | (1 << WDP3);
  //WDTCSR = (1 << WDIE);
  WD_SET(WD_IRQ, WDTO_1S);
}
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t * const DCInterfaceInfo){

	DTR_old = DTR;

	if (DCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR){
		DTR = 1;
	}else{
		DTR = 0;
	}

	if ((DTR == 0) && (DTR_old == 1)){
		// Falling Edge of DTR signal

		// We reset the board
		// The original idea was to perform a softreset with a jump, but there are some problems in the bootloader if so.
		// Now a hard reset via WDT is being used.

#ifdef _RESET_ON_FALLING_DTR
		cli();
		WD_SET(WD_RST,WDTO_15MS);

		while(1){
			;
		}
#endif

	} else if ((DTR==1) && (DTR_old == 0)){
		// Rising edge of DTR signal

		// This event occurs when opening the serial port in the pc.
		// This event will be used to reset the user application only

		GPIOR0 = 0xDC;
		GPIOR1 = 0xA7;

		AppPtr_t AppStartPtr = (AppPtr_t)0x0000;
		AppStartPtr();

	}

}