Esempio n. 1
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);
}
Esempio n. 2
0
//*****************************************************************************
//*****************************************************************************
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);
}
Esempio n. 3
0
void uart0_init(void)
{
	// Initialize GPIO for UART0
	gpio_enable_port(GPIOA_BASE);
  gpio_config_digital_enable( GPIOA_BASE, PA0 | PA1);
  gpio_config_alternate_function( GPIOA_BASE, PA0 | PA1);
  gpio_config_port_control( GPIOA_BASE, GPIO_PCTL_PA0_U0RX | GPIO_PCTL_PA1_U0TX);
}
Esempio n. 4
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);
}
Esempio n. 5
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);
}
Esempio n. 6
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);	
}
Esempio n. 7
0
//*****************************************************************************
// Configures the GPIO pins connected to the UP/DOWN and X-Direction of the
// PS2 controller
//*****************************************************************************
void gpio_init(void) {
    //Configures  GPIO pins for the UP/DOWN buttons
    gpio_enable_port(DIR_BTN_BASE);
    gpio_config_digital_enable(DIR_BTN_BASE,(DIR_BTN_UP | DIR_BTN_DOWN | DIR_BTN_LEFT | DIR_BTN_RIGHT));
    gpio_config_enable_input(DIR_BTN_BASE,(DIR_BTN_UP | DIR_BTN_DOWN | DIR_BTN_LEFT | DIR_BTN_RIGHT));
    gpio_config_enable_pullup(DIR_BTN_BASE,(DIR_BTN_UP | DIR_BTN_DOWN | DIR_BTN_LEFT | DIR_BTN_RIGHT));

    //Configures GPIO pins PS2 stick for the X-Direction
    gpio_enable_port(PS2_GPIO_BASE);
    gpio_config_analog_enable(PS2_GPIO_BASE, (PS2_X_DIR_PIN | PS2_Y_DIR_PIN));
    gpio_config_enable_input(PS2_GPIO_BASE, (PS2_X_DIR_PIN | PS2_Y_DIR_PIN));
    gpio_config_alternate_function(PS2_GPIO_BASE,(PS2_X_DIR_PIN | PS2_Y_DIR_PIN));
}
Esempio n. 8
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);
}
Esempio n. 9
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);
}