70 lines
2.1 KiB
C
70 lines
2.1 KiB
C
//
|
|
// Created by cfif on 16.09.22.
|
|
//
|
|
#include "Flash_EN25QH128A_104HIP.h"
|
|
|
|
void qspi_config(void)
|
|
{
|
|
gpio_init_type gpio_init_struct;
|
|
|
|
/* enable the qspi clock */
|
|
crm_periph_clock_enable(CRM_QSPI1_PERIPH_CLOCK, TRUE);
|
|
|
|
/* enable the pin clock */
|
|
crm_periph_clock_enable(CRM_GPIOF_PERIPH_CLOCK, TRUE);
|
|
crm_periph_clock_enable(CRM_GPIOG_PERIPH_CLOCK, TRUE);
|
|
|
|
/* set default parameter */
|
|
gpio_default_para_init(&gpio_init_struct);
|
|
|
|
/* configure the io0 gpio */
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_8;
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
gpio_init(GPIOF, &gpio_init_struct);
|
|
gpio_pin_mux_config(GPIOF, GPIO_PINS_SOURCE8, GPIO_MUX_10);
|
|
|
|
/* configure the io1 gpio */
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_9;
|
|
gpio_init(GPIOF, &gpio_init_struct);
|
|
gpio_pin_mux_config(GPIOF, GPIO_PINS_SOURCE9, GPIO_MUX_10);
|
|
|
|
/* configure the io2 gpio */
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_7;
|
|
gpio_init(GPIOF, &gpio_init_struct);
|
|
gpio_pin_mux_config(GPIOF, GPIO_PINS_SOURCE7, GPIO_MUX_9);
|
|
|
|
/* configure the io3 gpio */
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_6;
|
|
gpio_init(GPIOF, &gpio_init_struct);
|
|
gpio_pin_mux_config(GPIOF, GPIO_PINS_SOURCE6, GPIO_MUX_9);
|
|
|
|
/* configure the sck gpio */
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_10;
|
|
gpio_init(GPIOF, &gpio_init_struct);
|
|
gpio_pin_mux_config(GPIOF, GPIO_PINS_SOURCE10, GPIO_MUX_9);
|
|
|
|
/* configure the cs gpio */
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_6;
|
|
gpio_init(GPIOG, &gpio_init_struct);
|
|
gpio_pin_mux_config(GPIOG, GPIO_PINS_SOURCE6, GPIO_MUX_10);
|
|
}
|
|
|
|
void qspi_init() {
|
|
/* qspi config */
|
|
qspi_config();
|
|
|
|
/* switch to cmd port */
|
|
qspi_xip_enable(QSPI1, FALSE);
|
|
|
|
/* set sclk */
|
|
qspi_clk_division_set(QSPI1, QSPI_CLK_DIV_4);
|
|
|
|
/* set sck idle mode 0 */
|
|
qspi_sck_mode_set(QSPI1, QSPI_SCK_MODE_0);
|
|
|
|
/* set wip in bit 0 */
|
|
qspi_busy_config(QSPI1, QSPI_BUSY_OFFSET_0);
|
|
} |