1 // Copyright (C) 2022 Beken Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <common/bk_err.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 typedef uint8_t qspi_unit_t; /**< QSPI uint id */ 24 typedef uint8_t qspi_id_t; /**< QSPI id */ 25 26 typedef enum { 27 QSPI_READ = 0, /**< QSPI read operation */ 28 QSPI_WRITE, /**< QSPI write operation */ 29 } qspi_op_t; 30 31 typedef enum { 32 QSPI_SCLK_DCO = 0, /**< QSPI source clock dco */ 33 QSPI_SCLK_XTAL_26M, /**< QSPI source clock xtal 26M */ 34 QSPI_SCLK_80M, /**< QSPI source clock 80M */ 35 QSPI_SCLK_120M, /**< QSPI source clock 120M */ 36 QSPI_SCLK_320M, /**< QSPI source clock 320M */ 37 QSPI_SCLK_480M, /**< QSPI source clock 480M */ 38 } qspi_src_clk_t; 39 40 typedef enum { 41 MEMORY_MAPPED_MODE = 0, /* memory mapped mode, used for psram/flash memory device */ 42 INDIRECT_MODE, /* indirect mode. used for OLED */ 43 } qspi_work_mode; 44 45 typedef struct { 46 qspi_src_clk_t src_clk; /**< QSPI source clock */ 47 uint32_t src_clk_div; /**< QSPI source clock divide number*/ 48 uint32_t clk_div; /**< QSPI controller clock divide number */ 49 } qspi_config_t; 50 51 typedef enum { 52 QSPI_1WIRE = 0, /**< QSPI 1_wire mode, standard SPI */ 53 QSPI_2WIRE, /**< QSPI 2_wire mode, DUAL SPI */ 54 QSPI_4WIRE, /**< QSPI 4_wire mode, QUAD SPI */ 55 } qspi_wire_mode_t; 56 57 typedef enum { 58 QSPI_PSRAM = 0, /**< QSPI PSRAM */ 59 QSPI_FLASH, /**< QSPI FLASH */ 60 QSPI_OLED, /**< QSPI OLED */ 61 } qspi_device_t; 62 63 typedef struct { 64 qspi_wire_mode_t wire_mode; /**< wire mode */ 65 qspi_work_mode work_mode; /**< work mode */ 66 qspi_op_t op; /**< QSPI operation */ 67 uint32_t cmd; /**< QSPI command */ 68 uint32_t addr; /**< QSPI address */ 69 uint32_t dummy_cycle; /**< QSPI dummy cycle */ 70 uint32_t data_len; /**< QSPI data length*/ 71 qspi_device_t device; /**< QSPI slave device*/ 72 } qspi_cmd_t; 73 74 #ifdef __cplusplus 75 } 76 #endif 77