Ejemplo n.º 1
0
int main(void)
{
	sysclk_init();
	board_init();

	configure_lcd();
	configure_botao();
	configure_adc();
	configure_tc();
		ili93xx_set_foreground_color(COLOR_BLACK);
	ili93xx_draw_string(10, 20, (uint8_t *)"14 - ADC");
	

	/** Draw text, image and basic shapes on the LCD */
	//ili93xx_set_foreground_color(COLOR_BLACK);
	//ili93xx_draw_string(10, 20, (uint8_t *)"14 - ADC");

	while (1) {
		if(adc_value_new == 1)
		{
		refresh_lcd(adc_value_old);
		adc_value_new = 0;
		}
	}
}
Ejemplo n.º 2
0
/************************************** Main Function ********************************************************************/
int main(void)
{
  initialize_lcd();  // initialize
  configure_lcd();   // Configure
    
  write_command8_lcd(0x81);             // the first line 
  
  write_char_lcd(0x53);  				// S
  write_char_lcd(0x54); 				// T
  write_char_lcd(0x41); 				// A
  write_char_lcd(0x47); 				// G
  write_char_lcd(0x45); 				// E
  write_char_lcd(0x00);
  write_char_lcd(0x4c);                	// L
  write_char_lcd(0x49);				   	// I
  write_char_lcd(0x52);				   	// R
  write_char_lcd(0x4d); 			   	// M
  write_char_lcd(0x4d); 			   	// M

  write_command8_lcd(0xc3);            // the second line
  
  write_char_lcd(0x41); 				// A
  write_char_lcd(0x4c);                	// L
  write_char_lcd(0x49);				   	// I
  write_char_lcd(0x00);
  write_char_lcd(0x44);                 // D
  write_char_lcd(0x49);				   	// I
  write_char_lcd(0x4f);         		// O
  write_char_lcd(0x55);                 // U
  write_char_lcd(0x52);				   	// R
  write_char_lcd(0x49);				   	// I
  return 0;
}
Ejemplo n.º 3
0
static int clcd_init(void)
{
	int res;

	if (is_omap3evm())
	{
		res = clcd_init_evm();
		if ( res )
			return res;
	}

	if (is_overo())
	{
		res = clcd_init_overo();
		if ( res )
			return res;
	}

	return configure_lcd(fb_paddr);
}
Ejemplo n.º 4
0
int main(void)
{
	sysclk_init();
	board_init();

	configure_lcd();
	configure_botao();
	configure_adc();
	configure_tc();


	/** Draw text, image and basic shapes on the LCD */
	ili93xx_set_foreground_color(COLOR_BLACK);
	ili93xx_draw_string(10, 20, (uint8_t *)"14 - ADC");
	ili93xx_draw_filled_circle(120,160,60);
	ili93xx_set_foreground_color(COLOR_WHITE);
	ili93xx_draw_filled_circle(120,160,55);

	while (1) {
	}
Ejemplo n.º 5
0
int main(void)
{
		/*Status flags to indicate the re-burst for library */
	uint16_t status_flag = 0u;
	uint16_t burst_flag = 0u;

	uint8_t lft_pressed = 0;
	uint8_t rgt_pressed = 0;

	static uint8_t old_position = 0;

	uint8_t uc_char;
	uint8_t uc_flag;
	sysclk_init();
	board_init();
	configure_buttons();
	configure_hall();

	wdt_disable(WDT);
	pmc_enable_periph_clk(ID_PIOC);
	qt_reset_sensing();
	config_sensors();
	qt_init_sensing();
	/* Set the parameters like recalibration threshold, Max_On_Duration etc in this function by the user */
	qt_set_parameters();
	init_timer_isr();
	qt_filter_callback = 0;

	configure_console();
	printf(STRING_HEADER);
	
	configure_lcd();
	g_pwm_channel = configure_pwm();

	/* Cabeçalho do lcd */
	pos_lcd_x = 20;
	pos_lcd_y = 40;
	start_lcd(pos_lcd_x, pos_lcd_y, ul_duty, hall_1, hall_2, hall_3, phase);

	/* Infinite loop */
	while (1) {
		static uint8_t phase_aux;
		static uint32_t hall_1_aux, hall_2_aux, hall_3_aux, ul_duty_aux;

		/* Atualiza o display somente quando houver alteração nas variáveis que serão apresentadas */
		
		if(ul_duty_aux != ul_duty)
		{
			escreve_int_lcd("dc = ", ul_duty*100/PERIOD_VALUE, pos_lcd_x, 40);
			ul_duty_aux = ul_duty;
		}
		
		if(phase_aux != phase || hall_1_aux != hall_1 || hall_2_aux != hall_2 || hall_3_aux != hall_3)
		{
			escreve_int_lcd("hall1 = ", hall_1, pos_lcd_x, 60);
			escreve_int_lcd("hall2 = ", hall_2, pos_lcd_x, 80);
			escreve_int_lcd("hall3 = ", hall_3, pos_lcd_x, 100);
			escreve_int_lcd("phase = ", phase, pos_lcd_x, 120);

			phase_aux = phase;
			hall_1_aux = hall_1;
			hall_2_aux = hall_2;
			hall_3_aux = hall_3;
		}
		
		if(motor_run == 0 && ul_duty != 0)
			Hall_Phase();
		
		uc_char = 0;
		uc_flag = uart_read(CONSOLE_UART, &uc_char);
		if (!uc_flag) {
			if (uc_char == 't') {
				printf("   duty cicle = %lu \r\n",ul_duty*100/PERIOD_VALUE);
				printf("   hall1 = %lu \r\n", hall_1);
				printf("   hall2 = %lu \r\n", hall_2);
				printf("   hall3 = %lu \r\n", hall_3);
				printf("   phase = %u \r\n\n", phase);
			}
			if (uc_char == 'a'){				
				if(ul_duty < PERIOD_VALUE) ul_duty++;
				printf("   duty cicle = %lu \r\n",ul_duty*100/PERIOD_VALUE);
			}
			if (uc_char == 's'){
				if(ul_duty > INIT_DUTY_VALUE) ul_duty--;
				printf("   duty cicle = %lu \r\n",ul_duty*100/PERIOD_VALUE);
			}
			if (uc_char == 'd')
			{
				ensaio = 1;
				printf("   Ensaio de rampa\r\n");
				printf("   para parar pressione a letra 'P'\r\n");	
			}
			if (uc_char == 'f')
			{
				ensaio = 2;
				printf("   Ensaio de degrau\r\n");
				printf("   para parar pressione a letra 'P'\r\n");
			}
			if (uc_char == 'p')
			{
				ensaio = 0;
				ul_duty = 0;
			}
			if (uc_char == 'i')
			{
				sel_rot = !sel_rot;
				printf("   Rotacao invertida\r\n");
				printf("   para parar pressione a letra 'P'\r\n");
			}
		}
		
		if (time_to_measure_touch) {

			/* Clear flag: it's time to measure touch */
			time_to_measure_touch = 0u;

			do {
				/*  One time measure touch sensors    */
				status_flag = qt_measure_sensors(current_time_ms_touch);

				burst_flag = status_flag & QTLIB_BURST_AGAIN;

				/*Time critical host application code goes here */

			} while (burst_flag);
		}

		/*  Time Non-critical host application code goes here */


		if ((GET_SENSOR_STATE(BOARD_LEFT_KEY_ID) != 0)
		&& (lft_pressed == 0)) {
			lft_pressed = 1;
			if(ul_duty > INIT_DUTY_VALUE) ul_duty--;
			printf("  duty cicle = %lu \r\n",ul_duty*100/PERIOD_VALUE);
			} else {
			if ((GET_SENSOR_STATE(BOARD_LEFT_KEY_ID) == 0)
			&& (lft_pressed == 1)) {
				lft_pressed = 0;
			}
		}
		if ((GET_SENSOR_STATE(BOARD_RIGHT_KEY_ID) != 0)
		&& (rgt_pressed == 0)) {
			rgt_pressed = 1;
			if(ul_duty < PERIOD_VALUE) ul_duty++;
			printf("  duty cicle = %lu \r\n",ul_duty*100/PERIOD_VALUE);
			} else {
			if ((GET_SENSOR_STATE(BOARD_RIGHT_KEY_ID) == 0)
			&& (rgt_pressed == 1)) {
				rgt_pressed = 0;
			}
		}


		if (GET_ROTOR_SLIDER_POSITION(0) != old_position) {
			old_position = GET_ROTOR_SLIDER_POSITION(0);
			if (motor_run==0) flag_hab_m = 1;
			ul_duty = old_position*PERIOD_VALUE/255;
		}
	}
}
Ejemplo n.º 6
0
int main(void)
{
	uint8_t uc_key;

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

	/* Configure LED 1 */
	pmc_enable_periph_clk(PIN_LED_BLUE_ID);
	pio_set_output(PIN_LED_BLUE_PIO , PIN_LED_BLUE_MASK, 1, 0, 0);

	/* Initialize debug console */
	config_uart();
	
	/* frase de boas vindas */
	puts(" ---------------------------- \n\r"
	 	 " Bem vindo terraquio !		\n\r"
		 " ---------------------------- \n\r");
	
	/* Enable peripheral clock */
	pmc_enable_periph_clk(ID_SMC);

	/** Configura o LEDs */
	configure_leds();

	/** Configura o timer */
	configure_tc();


	/* Configuração LCD */
	configure_lcd();
	
	desenhaCabecalho();
	
	/* display main menu */
	display_menu();

	while (1) {
		
		
		usart_serial_getchar((Usart *)CONSOLE_UART, &uc_key);	
		switch (uc_key) {
			case '1':
				display_menu();
				break;
			case '2':
				flagLED = 0;
				pio_clear(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Led ON \n\r");
				break;
			case '3' :
				flagLED = 1;
				pio_set(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Led OFF \n\r");
				break;
			case '4' :
				flagLED = 2;
				pio_set(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Led OFF \n\r");
				break;
			case '5' :
				flagLED = 3;
				pio_set(PIN_LED_BLUE_PIO, PIN_LED_BLUE_MASK);
				puts("Defina a o valor da Frequência (0-65356) \n\r");
				usart_serial_getchar((Usart *)CONSOLE_UART, &uc_key);
				//tc_write_rc(uc_key);
				break;
				
			default:
				printf("Opcao nao definida: %d \n\r", uc_key);
		}	
	}
}