Ejemplo n.º 1
0
int main(void)
{
	/* Initialize the SAM system */
	sysclk_init();
	/* Disable the watchdog */
	WDT->WDT_MR = WDT_MR_WDDIS;

	/** Configura o timer */
	configure_tc();
	
	/* Configura os botões */
	configure_buttons();
	
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);

	pio_clear(PIOA, (1 << PIN_LED_BLUE));

	while (1) {
		
		
		/* Entra em modo sleep */
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);

		
	}
}
Ejemplo n.º 2
0
int main(void)
{
	
	int speed = 8192;
	//Def leds
	pio_set_output(PORT_LED_GREEN,MASK_LED_GREEN,1,0,0);
	pmc_enable_periph_clk(ID_LED_GREEN);
	pio_clear(PORT_LED_GREEN, MASK_LED_GREEN);
	/* Initialize the SAM system */
	sysclk_init();
	
	/* Disable the watchdog */
	WDT->WDT_MR = WDT_MR_WDDIS;

	/** Configura o timer */
	configure_tc();
	
	/* Configura os botões */
	configure_buttons();

	while (1) {
		
		/* Entra em modo sleep */
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);
		
	}
}
Ejemplo n.º 3
0
/* Main Code	                                                        */
/************************************************************************/
int main(void)
{
	/* Initialize the SAM system */
	sysclk_init();

	/* Disable the watchdog */
	WDT->WDT_MR = WDT_MR_WDDIS;

    /* Configura Leds */
    configure_leds();

	/** Configura o timer */
	configure_tc();
	
	/* Configura os botões */
	configure_buttons();

    
	while (1) {
		/* Entra em modo sleep */
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);
		
	}
Ejemplo n.º 4
0
int main(void)
{
	uint8_t vetor[TAMANHO+1];
	uint8_t uc_key;
	uint8_t rtn;

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


	/* Initialize debug console */
	config_uart();

	/* Initialize_tc */
	configure_tc();

	/* Initialize Led */
	config_led();
	
	/* frase de boas vindas */
	puts(" ---------------------------- \n\r"
	 	 " Bem vindo terraquio !		\n\r"
		 " ---------------------------- \n\r");
		 
	/* display main menu */
	display_menu();
	
	/* init var */
	vetor[TAMANHO] = STRING_NULL;
	
	while (1) {

		while(!g_UartStrgOk){ 
			pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);
		};

		//rtn = readvec(&vetor[0]);
	
			if (strcmp(g_UartStrg, "LGON") == 0)
			{
				pio_clear(PORT_LED_GREEN, MASK_LED_GREEN);
				puts("Led ON \n\r");
			}
			else if (strcmp(g_UartStrg, "LBPISCA") == 0)
			{
			flagB = 1;	
			puts("Pisca LED azul \n\r");	
			}
			else if (strcmp(g_UartStrg, "LGPISCA") == 0)
			{
				flagG = 2;
			}
			else if (strcmp(g_UartStrg, "LBON") == 0)
			{
				pio_clear(PORT_LED_BLUE, MASK_LED_BLUE);
				puts("Led ON \n\r");
			}
			else if (strcmp(g_UartStrg, "LRON") == 0)
			{
				pio_set(PORT_LED_RED, MASK_LED_RED);
				puts("Led ON \n\r");
			}
			else if (strcmp(g_UartStrg, "LGOFF") == 0)
			{
			pio_set(PORT_LED_GREEN, MASK_LED_GREEN);
			puts("Led OFF \n\r");	
			flagG = 0 ;
			}
			else if (strcmp(g_UartStrg, "LBOFF") == 0)
			{
				pio_set(PORT_LED_BLUE, MASK_LED_BLUE);
				puts("Led OFF \n\r");
				flagB = 0;
			}
			else if (strcmp(g_UartStrg, "LROFF") == 0)
			{
				pio_clear(PORT_LED_RED, MASK_LED_RED);
				puts("Led OFF \n\r");
			}
			else if (strcmp(g_UartStrg, "FREQ1") == 0)
			{
				tc_write_rc(TC0,0,8000);
				puts("Frequencia 8000 \n\r");
			}
			else if (strcmp(g_UartStrg, "FREQ2") == 0)
			{
				tc_write_rc(TC0,0,4000);
				puts("Frequencia 4000 \n\r");
			}
			else if (strcmp(g_UartStrg, "FREQ3") == 0)
			{
				tc_write_rc(TC0,0,2000);
				puts("Frequencia 2000 \n\r");
			}
			
			/* more else if clauses */
			else 
			{
				printf("[INFO] Opcao nao definida: %s \n\r", g_UartStrg);
			}

			//g_UartStrgAck = 1;
			limparvetor();

	}
}
Ejemplo n.º 5
0
 */
int main(void)
{
	sysclk_init();
	board_init();

	/** Initialize debug console */
	configure_console();
	
	/** Configura o timer */
	configure_tc();
	
	/* Configura os botões */
	configure_buttons();

	/** Enable peripheral clock */
	pmc_enable_periph_clk(ID_SMC);

	/** Configure SMC interface for Lcd */
	smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2)
			| SMC_SETUP_NCS_WR_SETUP(2)
			| SMC_SETUP_NRD_SETUP(2)
			| SMC_SETUP_NCS_RD_SETUP(2));
	smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4)
			| SMC_PULSE_NCS_WR_PULSE(4)
			| SMC_PULSE_NRD_PULSE(10)
			| SMC_PULSE_NCS_RD_PULSE(10));
	smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10)
			| SMC_CYCLE_NRD_CYCLE(22));
#if ((!defined(SAM4S)) && (!defined(SAM4E)))
	smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
			| SMC_MODE_WRITE_MODE
			| SMC_MODE_DBW_8_BIT);
#else
	smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
			| SMC_MODE_WRITE_MODE);
#endif
	/** Initialize display parameter */
	g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH;
	g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT;
	g_ili93xx_display_opt.foreground_color = COLOR_BLACK;
	g_ili93xx_display_opt.background_color = COLOR_WHITE;

	/** Switch off backlight */
	aat31xx_disable_backlight();

	/** Initialize LCD */
	ili93xx_init(&g_ili93xx_display_opt);

	/** Set backlight level */
	aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL);

	ili93xx_set_foreground_color(COLOR_WHITE);
	ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH,
			ILI93XX_LCD_HEIGHT);
	/** Turn on LCD */
	ili93xx_display_on();
	ili93xx_set_cursor_position(0, 0);

	/** Draw text, image and basic shapes on the LCD */
	ili93xx_set_foreground_color(COLOR_BLACK);
	ili93xx_draw_string(80, 10, (uint8_t *)"13 - LCD");
	ili93xx_draw_string(10, 40, (uint8_t *)"Andre");
	ili93xx_draw_string(10, 60, (uint8_t *)"Thales");
	ili93xx_draw_string(10, 80, (uint8_t *)"Tete");
	ili93xx_set_foreground_color(COLOR_ORANGE);
	ili93xx_draw_filled_rectangle(0, 100, ILI93XX_LCD_WIDTH,105);
	ili93xx_set_foreground_color(COLOR_GREEN);
	ili93xx_draw_filled_rectangle(0, 106, ILI93XX_LCD_WIDTH,111);
	
	while (1) {
		/* Entra em modo sleep */
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);
	}
Ejemplo n.º 6
0
int main (void)
{

	/**
	* Inicializando o clock do uP
	*/
	sysclk_init();
	
	/** 
	*  Desabilitando o WathDog do uP
	*/
	WDT->WDT_MR = WDT_MR_WDDIS;
		
	/**
	* Ativa clock nos periféricos
	*/
	_pmc_enable_clock_periferico(ID_LED_BLUE);
	_pmc_enable_clock_periferico(ID_LED_GREEN);		// Redundante mas não tem problema !
	_pmc_enable_clock_periferico(ID_LED_RED);
	_pmc_enable_clock_periferico(ID_BUT_2);
				
	/**
	*	Configura saída
	*/
	pio_set_output(PORT_LED_BLUE  , MASK_LED_BLUE	,1,0,0);
	pio_set_output(PORT_LED_GREEN , MASK_LED_GREEN  ,1,0,0);
	pio_set_output(PORT_LED_RED	  , MASK_LED_RED	,1,0,0);
	
	/**
	* Configura entrada
	*/ 
	pio_set_input(PORT_BUT_2, MASK_BUT_2, PIO_PULLUP | PIO_DEBOUNCE);
	
	/*
	 * Configura divisor do clock para debounce
	 */
	pio_set_debounce_filter(PIOB, MASK_BUT_2, 100);
	
	/* 
	*	Configura interrupção para acontecer em borda de descida.
	*/
	pio_handler_set(PIOB ,ID_BUT_2 , MASK_BUT_2, PIO_IT_FALL_EDGE, push_button_handle);
				
	/*
	*	Ativa interrupção no periférico B porta do botão
	*/	
	pio_enable_interrupt(PIOB, MASK_BUT_2);
	
	/*
	*	Configura a prioridade da interrupção no pORTB
	*/
	NVIC_SetPriority(ID_BUT_2, 1 );
	
	/*
	*	Ativa interrupção no port B
	*/
	NVIC_EnableIRQ( ID_BUT_2);
	
	/**
	*	Loop infinito
	*/
	while(1){
		
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);
		
		pio_set(PIOA, (1 << PIN_LED_BLUE));
		delay_ms(500);
		pio_clear(PIOA, (1 << PIN_LED_BLUE));
		delay_ms(500);
		pio_set(PIOA, (1 << PIN_LED_BLUE));
		delay_ms(500);
		pio_clear(PIOA, (1 << PIN_LED_BLUE));
		delay_ms(500);
		
		
		
	}
}
Ejemplo n.º 7
0
/**
 * \brief Application entry point for smc_lcd example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	sysclk_init();
	board_init();
	
	/** Configura os botões, o TC e desabilita o Watchdog Timer. */
	configure_buttons();
	WDT->WDT_MR = WDT_MR_WDDIS;
	configure_tc();

	/** Initialize debug console */
	configure_console();

	/** Enable peripheral clock */
	pmc_enable_periph_clk(ID_SMC);

	/** Configure SMC interface for Lcd */
	smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2)
			| SMC_SETUP_NCS_WR_SETUP(2)
			| SMC_SETUP_NRD_SETUP(2)
			| SMC_SETUP_NCS_RD_SETUP(2));
	smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4)
			| SMC_PULSE_NCS_WR_PULSE(4)
			| SMC_PULSE_NRD_PULSE(10)
			| SMC_PULSE_NCS_RD_PULSE(10));
	smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10)
			| SMC_CYCLE_NRD_CYCLE(22));
#if ((!defined(SAM4S)) && (!defined(SAM4E)))
	smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
			| SMC_MODE_WRITE_MODE
			| SMC_MODE_DBW_8_BIT);
#else
	smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
			| SMC_MODE_WRITE_MODE);
#endif
	/** Initialize display parameter */
	g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH;
	g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT;
	g_ili93xx_display_opt.foreground_color = COLOR_BLACK;
	g_ili93xx_display_opt.background_color = COLOR_WHITE;

	/** Switch off backlight */
	aat31xx_disable_backlight();

	/** Initialize LCD */
	ili93xx_init(&g_ili93xx_display_opt);

	/** Set backlight level */
	aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL);

	ili93xx_set_foreground_color(COLOR_WHITE);
	ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH,
			ILI93XX_LCD_HEIGHT);
			
	/** Turn on LCD */
	ili93xx_display_on();
	ili93xx_set_cursor_position(0, 0);

	/** Escreve os nomes no display. */
	ili93xx_set_foreground_color(COLOR_BLACK);
	ili93xx_draw_string(10, 20, (uint8_t *)"Bruna Tavares");
	ili93xx_draw_string(10, 40, (uint8_t *)"Bruno Campos");
	ili93xx_draw_string(10, 60, (uint8_t *)"Keneth Yamada");
	
	/** Desenha linha */
	ili93xx_set_foreground_color(COLOR_BLUEVIOLET);
	ili93xx_draw_line(0, 90, 240, 90);
	
	/** Escreve contador e tempo no display. */
	ili93xx_set_foreground_color(COLOR_BLACK);
	ili93xx_draw_string(10, 110, (uint8_t *)"Contador");
	ili93xx_draw_string(10, 300, (uint8_t *)"Tempo ");

	/** Escreve valores iniciais do contador. */
	ili93xx_draw_string(130, 110, (uint8_t *)"000");
	ili93xx_draw_string(140, 300, (uint8_t *)"00:00");	

	while (1) {
		// Coloca o microcontrolador em modo Sleep aguardando interrupções.
		pmc_sleep(SAM_PM_SMODE_SLEEP_WFI);
	}
}