Пример #1
0
void USBMouse::move(uint8_t x, uint8_t y, uint8_t z) {
    HIDReportInData[0] = HID_REPORTID_MouseReport;
    report[1] = x;
    report[2] = y;
    report[3] = z;
    memcpy(HIDReportInData + 1, report, 8);
    HID_Task();
}
Пример #2
0
void USBMouse::scroll(uint8_t z) {
    HIDReportInData[0] = HID_REPORTID_MouseReport;
    report[1] = 0;
    report[2] = 0;
    report[3] = z;
    memcpy(HIDReportInData + 1, report, 8);
    HID_Task();
}
Пример #3
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  enters a loop to run the application tasks in sequence.
 */
int main(void)
{
  SetupHardware();

  for (;;)
  {
    HID_Task();
    USB_USBTask();
  }
}
/** Main program entry point. This routine configures the hardware required by the application, then
 *  enters a loop to run the application tasks in sequence.
 */
int main(void)
{
	SetupHardware();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		HID_Task();
		USB_USBTask();
	}
}
Пример #5
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  enters a loop to run the application tasks in sequence.
 */
int main(void)
{
	SetupHardware();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	GlobalInterruptEnable();

	for (;;)
	{
		HID_Task();
		USB_USBTask();
	}
}
Пример #6
0
int main(void)
{

	SetupHardware();

	data_init(&data, &calib_params); //put some values into structure for testing
	ahrs_init(&data, &u8g, &calib_params);

	GlobalInterruptEnable();

	for (;;)
	{
		//time between updates
		timer_old = timer;
		timer = get_timer_ms();
		if (timer > timer_old) {
			t_period = (timer - timer_old) / 1000.0; //in seconds
		}
		else
			t_period = 0;
		data.time_period = t_period;

		//read data - sensors
		adxl345_read(&data); //accelerometer read
		l3g4200d_read_seq(&data); //gyroscope read
		hmc5883l_read(&data); //magnetometer read

		//buttons
		buttons_read(&data);

		//compute
		//ahrs_orientation_from_gyro(&data);
		ahrs_orientation(&data);
		//ahrs_orientation_from_accel_mag(&data);

		HID_Task();
		USB_USBTask();
	}
}
Пример #7
0
void USBKeyboard::send_now() {
    HIDReportInData[0] = HID_REPORTID_KeyboardReport;
    memcpy(HIDReportInData + 1, report, 8);
    HID_Task();
}
Пример #8
0
void USBMouse::set_buttons(uint8_t b1, uint8_t b2, uint8_t b3) {
    HIDReportInData[0] = HID_REPORTID_MouseReport;
    report[0] = (b1 << 2) + (b2 << 1) + b3;
    memcpy(HIDReportInData + 1, report, 8);
    HID_Task();
}
Пример #9
0
void vs_send_pad_state(void) {
	HID_Task();
	USB_USBTask();
}
Пример #10
0
int8_t main(void)
{
    SetupHardware();
    sei();	
		  	
	while(1) {		
		//Joystick 1
		//=========================================================================================
		HIDReportOutData[0] = HID_REPORTID_JoystickReport;
		
		//digital direction
		up    = !(PINE&0x01); //D00 - digital up
		down  = !(PINE&0x02); //D01 - digital down
		left  = !(PINC&0x01); //D02 - digital left
		right = !(PINC&0x02); //D03 - digital right			
		
		HIDReportOutData[5] = 0X08;  //NULL		
		if (left)  { HIDReportOutData[5]=0x06; }
		if (right) { HIDReportOutData[5]=0x02; }
		if (up) {
			if (left)		{ HIDReportOutData[5]=0x07; }
			else if (right)	{ HIDReportOutData[5]=0x01; } 
			else			{ HIDReportOutData[5]=0x00; }		
		}
		if (down) {
			if (left)		{ HIDReportOutData[5]=0x05; }
			else if (right)	{ HIDReportOutData[5]=0x03; } 
			else			{ HIDReportOutData[5]=0x04; }
		}		
		
		//buttons
		buttons = 0x00;
		if(!(PINC&0x04)) { buttons=buttons|(1<<0); }	//D04 - button 1
		if(!(PINC&0x08)) { buttons=buttons|(1<<1); }	//D05 - button 2
		if(!(PINC&0x10)) { buttons=buttons|(1<<2); }	//D06 - button 3
		if(!(PINC&0x20)) { buttons=buttons|(1<<3); }	//D07 - button 4
		if(!(PINC&0x40)) { buttons=buttons|(1<<4); }	//D08 - button 5
		if(!(PINC&0x80)) { buttons=buttons|(1<<5); }	//D09 - button 6
		if(!(PINA&0x80)) { buttons=buttons|(1<<6); }	//D10 - button 7
		if(!(PINA&0x20)) { buttons=buttons|(1<<7); }	//D11 - button 8
		HIDReportOutData[6] = buttons;						
		
		//padding
		HIDReportOutData[7] = 0; // ] - unused
		HIDReportOutData[8] = 0; // ]
		
		HID_Task();
		USB_USBTask();
		_delay_ms(2);

		//Joystick 2
		//=========================================================================================
		HIDReportOutData[0] = HID_REPORTID_JoystickReport2;
		
		//digital direction
		up    = !(PINA&0x02); //D13 - digital up
		down  = !(PINA&0x01); //D14 - digital down
		left  = !(PINA&0x04); //D15 - digital left
		right = !(PINA&0x10); //D16 - digital right			
		
		HIDReportOutData[5] = 0X08;  //NULL		
		if (left)  { HIDReportOutData[5]=0x06; }
		if (right) { HIDReportOutData[5]=0x02; }
		if (up) {
			if (left)		{ HIDReportOutData[5]=0x07; }
			else if (right)	{ HIDReportOutData[5]=0x01; } 
			else			{ HIDReportOutData[5]=0x00; }		
		}
		if (down) {
			if (left)		{ HIDReportOutData[5]=0x05; }
			else if (right)	{ HIDReportOutData[5]=0x03; } 
			else			{ HIDReportOutData[5]=0x04; }
		}		
		
		//buttons
		buttons = 0x00;
		if(!(PINA&0x40)) { buttons=buttons|(1<<0); }	//D17 - button 1
		if(!(PINE&0x40)) { buttons=buttons|(1<<1); }	//D18 - button 2
		if(!(PINB&0x01)) { buttons=buttons|(1<<2); }	//D19 - button 3
		if(!(PINB&0x02)) { buttons=buttons|(1<<3); }	//D20 - button 4
		if(!(PINB&0x04)) { buttons=buttons|(1<<4); }	//D21 - button 5
		if(!(PINB&0x08)) { buttons=buttons|(1<<5); }	//D22 - button 6
		if(!(PINB&0x10)) { buttons=buttons|(1<<6); }	//D23 - button 7
		if(!(PINB&0x20)) { buttons=buttons|(1<<7); }	//D24 - button 8
		HIDReportOutData[6] = buttons;						
		
		//padding
		HIDReportOutData[7] = 0; // ] - unused
		HIDReportOutData[8] = 0; // ]
		
		HID_Task();
		USB_USBTask();
		_delay_ms(2);

		//Joystick 3
		//=========================================================================================
		HIDReportOutData[0] = HID_REPORTID_JoystickReport3;
		
		//digital direction
		up    = !(PINB&0x40); //D25 - digital up
		down  = !(PINB&0x80); //D26 - digital down
		left  = !(PINE&0x80); //D27 - digital left
		right = !(PINE&0x08); //D28 - digital right			
		
		HIDReportOutData[5] = 0X08;  //NULL		
		if (left)  { HIDReportOutData[5]=0x06; }
		if (right) { HIDReportOutData[5]=0x02; }
		if (up) {
			if (left)		{ HIDReportOutData[5]=0x07; }
			else if (right)	{ HIDReportOutData[5]=0x01; } 
			else			{ HIDReportOutData[5]=0x00; }		
		}
		if (down) {
			if (left)		{ HIDReportOutData[5]=0x05; }
			else if (right)	{ HIDReportOutData[5]=0x03; } 
			else			{ HIDReportOutData[5]=0x04; }
		}		
		
		//buttons
		buttons = 0x00;
		if(!(PIND&0x01)) { buttons=buttons|(1<<0); }	//D29 - button 1
		if(!(PIND&0x02)) { buttons=buttons|(1<<1); }	//D30 - button 2
		if(!(PIND&0x04)) { buttons=buttons|(1<<2); }	//D31 - button 3
		if(!(PIND&0x08)) { buttons=buttons|(1<<3); }	//D32 - button 4
		if(!(PIND&0x10)) { buttons=buttons|(1<<4); }	//D33 - button 5
		if(!(PIND&0x20)) { buttons=buttons|(1<<5); }	//D34 - button 6
		HIDReportOutData[6] = buttons;						
		
		//padding
		HIDReportOutData[7] = 0; // ] - unused
		HIDReportOutData[8] = 0; // ]
		
		HID_Task();
		USB_USBTask();
		_delay_ms(2);

		//Joystick 4
		//=========================================================================================
		HIDReportOutData[0] = HID_REPORTID_JoystickReport4;
		
		//digital direction
		up    = !(PIND&0x40); //D35 - digital up
		down  = !(PIND&0x80); //D36 - digital down
		left  = !(PINF&0x01); //A00 - digital left
		right = !(PINF&0x02); //A01 - digital right			
		
		HIDReportOutData[5] = 0X08;  //NULL		
		if (left)  { HIDReportOutData[5]=0x06; }
		if (right) { HIDReportOutData[5]=0x02; }
		if (up) {
			if (left)		{ HIDReportOutData[5]=0x07; }
			else if (right)	{ HIDReportOutData[5]=0x01; } 
			else			{ HIDReportOutData[5]=0x00; }		
		}
		if (down) {
			if (left)		{ HIDReportOutData[5]=0x05; }
			else if (right)	{ HIDReportOutData[5]=0x03; } 
			else			{ HIDReportOutData[5]=0x04; }
		}		
		
		//buttons
		buttons = 0x00;
		if(!(PINF&0x04)) { buttons=buttons|(1<<0); }	//A02 - button 1
		if(!(PINF&0x08)) { buttons=buttons|(1<<1); }	//A03 - button 2
		if(!(PINF&0x10)) { buttons=buttons|(1<<2); }	//A04 - button 3
		if(!(PINF&0x20)) { buttons=buttons|(1<<3); }	//A05 - button 4
		if(!(PINF&0x40)) { buttons=buttons|(1<<4); }	//A06 - button 5
		if(!(PINF&0x80)) { buttons=buttons|(1<<5); }	//A07 - button 6
		HIDReportOutData[6] = buttons;						
		
		//padding
		HIDReportOutData[7] = 0; // ] - unused
		HIDReportOutData[8] = 0; // ]
		
		HID_Task();
		USB_USBTask();
		_delay_ms(2);
		
	}
}