Пример #1
0
void main () {
	everypio_digital_input_set(BUTTON, PULL_UP);
	everypio_analog_input_set(X, true);
	everypio_analog_input_set(Y, true);
	
	USB_Init(&mouse_deviceDefinition, &mouse_device);

	USB_SoftConnect (&mouse_device);

	SYSCON_StartSystick_10ms();
}
Пример #2
0
void main(void) {
	anypio_write(LED, false);

	// prepare the RGB outputs for PWM (timer and digital mode)
	ANY_GPIO_SET_FUNCTION(0,8,TMR,IOCON_IO_ADMODE_DIGITAL);
	ANY_GPIO_SET_FUNCTION(0,9,TMR,IOCON_IO_ADMODE_DIGITAL);
	ANY_GPIO_SET_FUNCTION(0,10,TMR,IOCON_IO_ADMODE_DIGITAL);

	// enable the timer
	Timer_Enable(CT16B0, true);

	// And set the match value to "about half"
	Timer_SetMatchValue(CT16B0, 0, 32000);
	Timer_SetMatchBehaviour(CT16B0, 0, 0);
	// enable PWM on red pin ...
	Timer_EnablePWM(CT16B0, 0, true);

	// repeat for green ...
	Timer_SetMatchValue(CT16B0, 1, 32000);
	Timer_SetMatchBehaviour(CT16B0, 1, 0);
	Timer_EnablePWM(CT16B0, 1, true);

	// ... and blue
	Timer_SetMatchValue(CT16B0, 2, 32000);
	Timer_SetMatchBehaviour(CT16B0, 2, 0);
	Timer_EnablePWM(CT16B0, 2, true);

	// finally, provide an additional matchvalue to reset the timer to 0 when
	// it reach 65635. Not technically necessary, because the timer's
	// maximum value is 65635 anyway and it would wrap back to 0 by
	// itself.

	Timer_SetMatchValue(CT16B0, 3, 65535);
	Timer_SetMatchBehaviour(CT16B0, 3, TIMER_MATCH_RESET);
	
	// now start the timer!
	Timer_Start(CT16B0);
	
	// There's a `systick` routine below that updates the rainbow
	// animation every 10ms, activate this routine:
	SYSCON_StartSystick_10ms();

}