예제 #1
0
파일: lcd.c 프로젝트: jbauer7/TIVA_Tetris
//*****************************************************************************
//*****************************************************************************
void init_lcd_gpio(void)
{ 
  gpio_enable_port(LCD_GPIO_BASE);
	gpio_enable_port(LCD_RST_BASE);
  
  // Configure SPI CLK
  gpio_config_digital_enable(LCD_GPIO_BASE, LCD_CLK_PIN);
  gpio_config_alternate_function(LCD_GPIO_BASE, LCD_CLK_PIN);
  gpio_config_port_control(LCD_GPIO_BASE, LCD_CLK_PIN_PCTL);
  
  // Configure SPI MOSI
  gpio_config_digital_enable(LCD_GPIO_BASE, LCD_MOSI_PIN);
  gpio_config_alternate_function(LCD_GPIO_BASE, LCD_MOSI_PIN);
  gpio_config_port_control(LCD_GPIO_BASE, LCD_MOSI_PIN_PCTL);
  
  // Configure CS to be a normal GPIO pin that is controlled 
  // explicitly by software
  gpio_config_digital_enable(LCD_GPIO_BASE, LCD_CS_PIN);
  gpio_config_alternate_function(LCD_GPIO_BASE, LCD_CS_PIN);
  gpio_config_port_control(LCD_GPIO_BASE, LCD_CS_PIN_PCTL);
	
	// Configure CD to be a normal GPIO pin that is controlled 
  // explicitly by software
  gpio_config_digital_enable(LCD_GPIO_BASE, LCD_CD_PIN);
  gpio_config_enable_output(LCD_GPIO_BASE, LCD_CD_PIN);
	
	// Configure RST_N to be a normal GPIO pin that is controlled 
  // explicitly by software
  gpio_config_digital_enable(LCD_RST_BASE, LCD_RST_PIN);
  gpio_config_enable_output(LCD_RST_BASE, LCD_RST_PIN);
	
  initialize_spi(LCD_SPI_BASE, 3);
}
예제 #2
0
void peripheral_init()
{
	
	/* Define the DCs for the DAC */
	uint8_t DCs = DAC_GPIO_0 | DAC_GPIO_1 | DAC_GPIO_2 | DAC_GPIO_3 | DAC_GPIO_4 | DAC_GPIO_5;
	
	/* Turn Clock ON for GPIOF (Push Up Button), GPIOE (Pot and PS2), and GPIOB (DC0-DC5) */	
	gpio_enable_port(PUSH_BUTTON_GPIO_BASE);
	gpio_enable_port(ADC_GPIO_BASE);
	gpio_enable_port(DAC_GPIO_BASE);
	
	/* Set pin for Push Up and DC0-DC5 to Digital */
	gpio_config_digital_enable(PUSH_BUTTON_GPIO_BASE, PUSH_BUTTON_UP_PIN);
	gpio_config_digital_enable(DAC_GPIO_BASE, DCs);
	
	/* Set pins for Pot and PS2 to analogic */
	gpio_config_analog_enable(ADC_GPIO_BASE, ADC_GPIO_X_PIN | ADC_GPIO_Y_PIN | ADC_GPIO_POT_PIN);
	
	/* Set PS2 and Push buttons as input and DC0-DC5 as output */
	gpio_config_enable_input(PUSH_BUTTON_GPIO_BASE, PUSH_BUTTON_UP_PIN);
	gpio_config_enable_input(ADC_GPIO_BASE, ADC_GPIO_X_PIN | ADC_GPIO_Y_PIN | ADC_GPIO_POT_PIN);
	
	gpio_config_enable_output(DAC_GPIO_BASE, DCs);
	
	/* Set pin for Push Up to PullUp */
	gpio_config_enable_pullup(PUSH_BUTTON_GPIO_BASE, PUSH_BUTTON_UP_PIN);
	
	/* Enable pins for Pot and PS2 as alaternate function (ADC) */
	gpio_config_alternate_function(ADC_GPIO_BASE, ADC_GPIO_X_PIN | ADC_GPIO_Y_PIN | ADC_GPIO_POT_PIN);
}
예제 #3
0
void initialize_rotary(void) {
	// Push button pins on PC4, PC5, PC6, and PC7
	gpio_enable_port(GPIOC_BASE);
	gpio_config_digital_enable(GPIOC_BASE, PIN4 | PIN5 | PIN6 | PIN7);
	gpio_config_enable_input(GPIOC_BASE, PIN4 | PIN6 | PIN7);
	gpio_config_enable_output(GPIOC_BASE, PIN5);
	gpio_config_enable_pullup(GPIOC_BASE, PIN6 | PIN7);
	gpio_config_enable_pulldown(GPIOC_BASE, PIN4);
}
예제 #4
0
void initialize_steppers(void) {
	// Stepper0 is pins PA6, PA7, PF0, PF1, PF2, PF3
	// Stepper1 is pins PE0, PE1, PE2, PE3, PE4, PE5
	
	// Stepper0 pins on Port A - PIN6 and PIN7
	gpio_enable_port(GPIOA_BASE);
	gpio_config_digital_enable(GPIOA_BASE, PIN6 | PIN7);
	gpio_config_enable_output(GPIOA_BASE, PIN6 | PIN7);
	
	// Stepper0 pins on Port F - PIN0, PIN1, PIN2, and PIN3
	gpio_enable_port(GPIOF_BASE);
	gpio_config_digital_enable(GPIOF_BASE, PIN0 | PIN1 | PIN2 | PIN3);
	gpio_config_enable_output(GPIOF_BASE, PIN0 | PIN1 | PIN2 | PIN3);

	// Stepper 1 pins on Port E - PIN0 - PIN5
	gpio_enable_port(GPIOE_BASE);
	gpio_config_digital_enable(GPIOE_BASE, PIN0 | PIN1 | PIN2 | PIN3 | PIN4 | PIN5);
	gpio_config_enable_output(GPIOE_BASE, PIN0 | PIN1 | PIN2 | PIN3 | PIN4 | PIN5);
}
예제 #5
0
void initialize_LCD(void) {
	// LCD initialization
	gpio_enable_port(GPIOB_BASE);
	// Configure SPI CLK
  gpio_config_digital_enable(LCD_GPIO_BASE, LCD_CLK_PIN);
  gpio_config_alternate_function(LCD_GPIO_BASE, LCD_CLK_PIN);
  gpio_config_port_control(LCD_GPIO_BASE, LCD_CLK_PIN_PCTL);
  
  // Configure SPI MISO
  gpio_config_digital_enable(LCD_GPIO_BASE, LCD_MISO_PIN);
  gpio_config_alternate_function(LCD_GPIO_BASE, LCD_MISO_PIN);
  gpio_config_port_control(LCD_GPIO_BASE, LCD_MISO_PIN_PCTL);
  
  // Configure SPI MOSI
  gpio_config_digital_enable(LCD_GPIO_BASE, LCD_MOSI_PIN);
  gpio_config_alternate_function(LCD_GPIO_BASE, LCD_MOSI_PIN);
  gpio_config_port_control(LCD_GPIO_BASE, LCD_MOSI_PIN_PCTL);
  
  // Configure CS to be a normal GPIO pin that is controlled 
  // explicitly by software
  gpio_config_digital_enable(LCD_GPIO_BASE,LCD_CS_PIN);
  gpio_config_enable_output(LCD_GPIO_BASE,LCD_CS_PIN);

	// Configure RST, BL_EN, and CMD_SEL to be normal GPIO pins
	gpio_config_digital_enable(LCD_GPIO_BASE, LCD_RST_PIN | LCD_BL_EN_PIN | LCD_CMD_SEL_PIN);
	gpio_config_enable_output(LCD_GPIO_BASE, LCD_RST_PIN | LCD_BL_EN_PIN | LCD_CMD_SEL_PIN);
	
	initialize_spi2();
	
	//ILI9341_Initial();
	init_lcd2();
	setRotation(0);	
	
	fillScreen(ILI9341_RED);
	drawStringCenter("  P L E X U S", 0, ILI9341_WHITE, ILI9341_WHITE);
  drawStringCenter(" ADJUST YAW", 3, ILI9341_WHITE, ILI9341_WHITE);
  drawStringCenter("THEN", 5, ILI9341_WHITE, ILI9341_WHITE);
  drawStringCenter(" ADJUST PITCH", 7, ILI9341_WHITE, ILI9341_WHITE);
  drawStringCenter("AND", 9, ILI9341_WHITE, ILI9341_WHITE);
  drawStringCenter("FIRE", 11, ILI9341_WHITE,ILI9341_WHITE);	
}
예제 #6
0
void initialize_magnet(void) {
	// Magnet is on PF4
	gpio_enable_port(GPIOF_BASE);
	gpio_config_digital_enable(GPIOF_BASE, PIN4);
	gpio_config_enable_output(GPIOF_BASE, PIN4);
}
예제 #7
0
void initialize_actuator(void) {
	// Actuator pins on PD4 and PD5
	gpio_enable_port(GPIOD_BASE);
	gpio_config_digital_enable(GPIOD_BASE, PIN4 | PIN5);
	gpio_config_enable_output(GPIOD_BASE, PIN4 | PIN5);
}