//***************************************************************************** //***************************************************************************** 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); }
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); }
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); }
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); }
//***************************************************************************** // 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)); }