Beispiel #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);
}
Beispiel #2
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));
}
Beispiel #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);
}