Esempio n. 1
0
int main(void)
{
	uint8_t uc_key;

	/* Initialize the system */
	sysclk_init();
	board_init();

	/* Configure LED 1 */
	pmc_enable_periph_clk(ID_LED_BLUE);
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);

	/* Initialize debug console */
	config_uart();
	
	/* frase de boas vindas */
	puts(" ---------------------------- \n\r"
	 	 " Bem vindo Corsi  !		\n\r"
		 " ---------------------------- \n\r");
		 
	/* display main menu */
	display_menu();
	configure_tc();
	TC0_Handler();
	
	pio_clear(PORT_LED_RED, MASK_LED_RED);
	pio_set(PORT_LED_GREEN, MASK_LED_GREEN);
	
	PIOA->PIO_PER = (1 << PIN_LED_BLUE );
	PIOA->PIO_OER |=  (1 << PIN_LED_BLUE );
	
	
	PMC->PMC_PCER0 |= ID_PIOC;
	PIOC->PIO_PER |= (1 << PIN_LED_RED );
	PIOC->PIO_OER |=  (1 << PIN_LED_RED );
	
	
	tc_stop(TC0, 0);
	PIOA->PIO_SODR = (1 << PIN_LED_BLUE );
	PIOC->PIO_CODR = (1 << PIN_LED_RED );
	
	while (1) {
		usart_serial_getchar((Usart *)CONSOLE_UART, &uc_key);	
		switch (uc_key) {
			case '1':
				display_menu();
				break;
			case '2':
				tc_start(TC0,0);
				PIOA->PIO_CODR = (1 << PIN_LED_BLUE );
				
				puts("Led BLUE ON \n\r");
				break;
			case '3' :
				tc_stop(TC0, 0);
				PIOA->PIO_SODR = (1 << PIN_LED_BLUE );
				puts("Led BLUE OFF \n\r");
			
				break;
			case '4':
				tc_start(TC0,0);
				pio_clear(PORT_LED_GREEN, MASK_LED_GREEN);
				puts("Led GREEN ON \n\r");
				break;
			case '5' :
				tc_stop(TC0, 0);

				pio_set(PORT_LED_GREEN, MASK_LED_GREEN);
				puts("Led GREEN OFF \n\r");
				break;
			case '6':
					tc_start(TC0,0);
					PIOC->PIO_SODR = (1 << PIN_LED_RED );
				
				puts("Led RED ON \n\r");
			break;
			case '7' :
				tc_stop(TC0, 0);
				PIOC->PIO_CODR = (1 << PIN_LED_RED );
				puts("Led RED OFF \n\r");
			break;
			case '8' :
				
				tc_write_rc(TC0, 0, tc_read_rc(TC0,0) * 0.5);
				puts("aumentando \n\r");
				break;
			case '9' :
				
				tc_write_rc(TC0, 0, tc_read_rc(TC0,0) * 1.4);
				puts("diminuindo \n\r");
				break;				
			default:
				printf("Opcao nao definida: %d \n\r", uc_key);
		}	
	}
}
Esempio n. 2
0
/**
 *  Handle Interrupcao botao 2.
 */
static void Button2_Handler(uint32_t id, uint32_t mask)
{
	tc_write_rc(TC0, 0, tc_read_rc(TC0,0) * 0.5);
}
Esempio n. 3
0
/**
 *  Handle Interrupcao botao 2.
 */
static void Button2_Handler(uint32_t id, uint32_t mask)
{
	tc_stop(TC0,0);
	tc_write_rc(TC0, 0, tc_read_rc(TC0, 0)*0.9);
	tc_start(TC0,0);
}