Quad Serial Peripheral Interface (QSPI) driver for SAM.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
#include "compiler.h"
#include "string.h"
#include "status_codes.h"
#include <assert.h>
#include "sysclk.h"
Data Structures | |
union | qspi_inst_frame_t::_qspiinst_frame |
struct | qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap |
struct | qspi_buffer_t |
Qspi buffer structure. More... | |
struct | qspi_config_t |
Qspi config structure. More... | |
struct | qspi_inst_frame_t |
Qspi frame structure for QSPI mode. More... | |
struct | qspi_mem_cmd_t |
Qspi command structure. More... | |
struct | qspid_t |
Qspi driver structure. More... | |
Macros | |
#define | QSPI_WPMR_WPKEY_PASSWD QSPI_WPMR_WPKEY((uint32_t) 0x515350) |
Enumerations | |
enum | qspi_access { QSPI_CMD_ACCESS = 0, QSPI_READ_ACCESS, QSPI_WRITE_ACCESS } |
Qspi access modes. More... | |
enum | qspi_cs_mode { QSPI_NOT_RELOADED = 0, QSPI_LASTXFER, QSPI_SYSTEMATICALLY } |
QSPI chip select mode. More... | |
enum | qspi_run_mode { spi_mode = QSPI_MR_SMM_SPI, mem_mode = QSPI_MR_SMM_MEMORY } |
Qspi enum types for QSPI modes. More... | |
Functions | |
static void | qspi_disable (Qspi *qspi) |
Disables a QSPI peripheral. More... | |
static void | qspi_disable_interrupt (Qspi *qspi, uint32_t sources) |
Disable QSPI interrupts. More... | |
static void | qspi_disable_loopback (Qspi *qspi) |
Disable loop back mode. More... | |
static void | qspi_enable (Qspi *qspi) |
Enables a QSPI peripheral. More... | |
static void | qspi_enable_interrupt (Qspi *qspi, uint32_t sources) |
Enable QSPI interrupts. More... | |
static void | qspi_enable_loopback (Qspi *qspi) |
Enable loop back mode. More... | |
enum status_code | qspi_flash_access_memory (struct qspid_t *qspid, enum qspi_access read_write, uint8_t scramble_flag) |
Writes or reads the QSPI memory (0x80000000) to trasmit or receive data from Flash memory. More... | |
enum status_code | qspi_flash_execute_command (struct qspid_t *qspid, enum qspi_access read_write) |
Functionality API – Serial Memory Mode. More... | |
void | qspi_get_config_default (struct qspi_config_t *qspi_config) |
Get default config. More... | |
static uint32_t | qspi_get_inst_frame (Qspi *qspi) |
Reads the Instruction frame of QSPI. More... | |
static uint32_t | qspi_get_writeprotect_status (Qspi *qspi) |
Get write protection status. More... | |
enum status_code | qspi_initialize (Qspi *qspi, struct qspi_config_t *qspi_config) |
Config qspi according the config struct. More... | |
enum status_code | qspi_read (Qspi *qspi, uint16_t *us_data, uint32_t num_of_bytes) |
Qspi read data. More... | |
static void | qspi_reset (Qspi *qspi) |
Resets a QSPI peripheral. More... | |
static enum status_code | qspi_set_baudrate (Qspi *qspi, uint32_t baudrate) |
Set qspi clock baudrate. More... | |
static void | qspi_set_clock_phase (Qspi *qspi, uint32_t phase) |
Set qspi clock phase. More... | |
static void | qspi_set_clock_polarity (Qspi *qspi, uint32_t polarity) |
Set qspi clock polarity. More... | |
static void | qspi_set_instruction_addr (Qspi *qspi, uint32_t addr) |
Set qspi instruction addr. More... | |
static void | qspi_set_instruction_code (Qspi *qspi, struct qspi_mem_cmd_t instruction_code) |
Set qspi instruction code. More... | |
void | qspi_set_instruction_frame (Qspi *qspi, struct qspi_inst_frame_t instruction_frame) |
Set qspi instruction frame. More... | |
static uint32_t | qspi_set_scrambing_key (Qspi *qspi, uint32_t key) |
Set qspi scrambling key. More... | |
static void | qspi_set_scrambling_mode (Qspi *qspi, uint32_t scr_enable, uint32_t random_mode) |
Set qspi scrambling mode. More... | |
static void | qspi_set_writeprotect (Qspi *qspi, uint32_t enable) |
Enable write protection. More... | |
enum status_code | qspi_write (Qspi *qspi, uint16_t *us_data, uint32_t num_of_bytes) |
Qspi write data. More... | |
#define QSPI_WPMR_WPKEY_PASSWD QSPI_WPMR_WPKEY((uint32_t) 0x515350) |
Referenced by qspi_set_writeprotect().
enum qspi_access |
enum qspi_cs_mode |
enum qspi_run_mode |
|
inlinestatic |
Disables a QSPI peripheral.
qspi | Pointer to a Qspi instance. |
Referenced by qspi_initialize().
|
inlinestatic |
Disable QSPI interrupts.
qspi | Pointer to an QSPI instance. |
sources | Interrupts to be disabled. |
|
inlinestatic |
Disable loop back mode.
qspi | Pointer to an QSPI instance. |
Referenced by qspi_set_config().
|
inlinestatic |
Enables a QSPI peripheral.
qspi | Pointer to a Qspi instance. |
Referenced by qspi_initialize().
|
inlinestatic |
Enable QSPI interrupts.
qspi | Pointer to an QSPI instance. |
sources | Interrupts to be enabled. |
|
inlinestatic |
|
inlinestatic |
Reads the Instruction frame of QSPI.
pQspi | Pointer to an Qspi instance. |
Referenced by qspi_flash_access_memory(), and qspi_flash_execute_command().
|
inlinestatic |
Get write protection status.
qspi | Pointer to a Qspi instance. |
|
inlinestatic |
Resets a QSPI peripheral.
qspi | Pointer to a Qspi instance. |
Referenced by qspi_initialize().
|
inlinestatic |
Set qspi clock baudrate.
qspi | Pointer to a Qspi instance. |
baudrate | Baud rate to be set. |
References ERR_INVALID_ARG, STATUS_OK, and sysclk_get_peripheral_hz().
Referenced by qspi_set_config().
|
inlinestatic |
Set qspi clock phase.
qspi | Pointer to a Qspi instance. |
phase | Phase to be set. |
Referenced by qspi_set_config().
|
inlinestatic |
Set qspi clock polarity.
qspi | Pointer to a Qspi instance. |
polarity | Polarity to be set. |
Referenced by qspi_set_config().
|
inlinestatic |
Set qspi instruction addr.
qspi | Pointer to a Qspi instance. |
addr | Address to be set. |
Referenced by qspi_flash_execute_command().
|
inlinestatic |
Set qspi instruction code.
qspi | Pointer to a Qspi instance. |
instruction_code | Code to be set. |
References qspi_mem_cmd_t::instruction, and qspi_mem_cmd_t::option.
Referenced by qspi_flash_access_memory(), and qspi_flash_execute_command().
|
inlinestatic |
Set qspi scrambling key.
qspi | Pointer to a Qspi instance. |
mode | Mode to be set. |
Referenced by qspi_set_config().
|
inlinestatic |
Set qspi scrambling mode.
qspi | Pointer to a Qspi instance. |
mode | Mode to be set. |
Referenced by qspi_flash_access_memory(), and qspi_set_config().
|
inlinestatic |
Enable write protection.
qspi | Pointer to a Qspi instance. |
enable | Enable or disable write protect. Protection status to be set. |
References QSPI_WPMR_WPKEY_PASSWD.