app_graphics_qspi.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file app_graphics_qspi.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of QSPI app library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 #ifndef __APP_GRAPHICS_QSPI_H__
39 #define __APP_GRAPHICS_QSPI_H__
40 
41 
42 /** @addtogroup PERIPHERAL Peripheral Driver
43  * @{
44  */
45 
46 /** @addtogroup APP_DRIVER APP DRIVER
47  * @{
48  */
49 
50 /** @defgroup APP_QSPI QSPI
51  * @brief QSPI APP module driver.
52  * @{
53  */
54 
55 
56 #include <stdbool.h>
57 #include "grx_hal.h"
58 #include "app_io.h"
59 #include "app_qspi.h"
60 #include "app_drv_error.h"
61 #include "app_drv_config.h"
62 #if ((APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR5525X) || (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR5526X))
63 #include "app_qspi_user_config.h"
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 #ifdef HAL_QSPI_MODULE_ENABLED
69 
70 /**
71  * @brief One block of a screen Structure
72  */
73 typedef struct scroll_read_info_t{
74  uint32_t src_start_address; /**< source address for current block */
75  uint32_t dst_start_address; /**< dist address for current block */
76  uint32_t length; /**< read length beats(byte/half word/word) for current block; Must 0<length<4096*/
77  struct scroll_read_info_t* next;
78 } app_qspi_scroll_read_info_t;
79 
80 /* Exported functions --------------------------------------------------------*/
81 /** @addtogroup APP_GRAPHICS_QSPI_DRIVER_FUNCTIONS Functions
82  * @{
83  */
84 /**
85  ****************************************************************************************
86  * @brief Read data block in Memory mapped Mode(XIP Mode), The Data is ordered by the order in flash/psram device
87  *
88  * @param[in] id : QSPI module ID.
89  * @param[in] address : the address of device connected to QSPI, start from 0x000000
90  * @param[in] buffer : memory pointer to save the read data
91  * @param[in] length : the read length in byte
92  * @return true/false
93  ****************************************************************************************
94  */
95 bool app_qspi_dma_mmap_read_block(app_qspi_id_t id, uint32_t address, uint8_t * buffer, uint32_t length);
96 
97 /**
98  ****************************************************************************************
99  * @brief Read some blocks data in Memory mapped Mode(XIP Mode) by DMA LLP, The Data is ordered by the order in flash/psram device
100  *
101  * @param[in] id : QSPI module ID.
102  * @param[in] data_size : @ref QSPI_DATASIZE_08_BITS
103  * @ref QSPI_DATASIZE_16_BITS
104  * @ref QSPI_DATASIZE_32_BITS
105  * @param[in] llp_src_en : enable source-address llp function or not
106  * @param[in] llp_dst_en : enable destination-address llp function or not
107  * @param[in] p_link_scroll_read : the link node of llp-read
108  * @param[in] link_len : the total number of link nodes. Note:link_len must less than 95
109  * @return true/false
110  ****************************************************************************************
111  */
112 bool app_qspi_dma_llp_scroll_read(app_qspi_id_t id, uint8_t data_size, uint32_t llp_src_en, uint32_t llp_dst_en, app_qspi_scroll_read_info_t* p_link_scroll_read, uint32_t link_len);
113 
114 /**
115  ****************************************************************************************
116  * @brief Special Async API to write QuadSPI Screen from memory mapped device(flash or psram)
117  * Must enable the two micro-defines to enable this API:
118  * QSPI_ASYNC_SCROLL_DRAW_SCREEN_SUPPORT
119  *
120  * @param[in] screen_id: QSPI module ID for screen, MUST config screen qspi to register mode.
121  * @param[in] storage_id: QSPI module ID for storage, MUST config storage qspi to mmap(xip) mode.
122  * @param[in] p_screen_cmd: pointer to the screen control command
123  * @param[in] p_screen_info: pointer to the screen information
124  * @param[in] p_scroll_config: pointer to the scrolling-config
125  * @param[in] is_first_call: When called in foreground task, please set true
126  * @return true/false
127  ****************************************************************************************
128  */
129 bool app_qspi_async_draw_screen(app_qspi_id_t screen_id,
130  app_qspi_id_t storage_id,
131  const app_qspi_screen_command_t * const p_screen_cmd,
132  const app_qspi_screen_info_t * const p_screen_info,
133  app_qspi_screen_scroll_t * p_scroll_config,
134  bool is_first_call);
135 
136 /**
137  ****************************************************************************************
138  * @brief Special Async API to write Screen in vertical direction, and veritical lines are organized in linked list.
139  * Must enable the two micro-defines to enable this API:
140  * QSPI_ASYNC_VERI_LINK_DRAW_SCREEN_SUPPORT
141  *
142  * @param[in] screen_id: QSPI module ID for screen, MUST config screen qspi to register mode.
143  * @param[in] storage_id: QSPI module ID for storage, MUST config storage qspi to mmap(xip) mode.
144  * @param[in] p_screen_cmd: pointer to the screen control command
145  * @param[in] p_screen_info: pointer to the screen information
146  * @param[in] p_link_scroll: pointer to the linked list structure
147  * @param[in] is_first_call: When called in foreground task, please set true
148  * @return true/false
149  ****************************************************************************************
150  */
151 bool app_qspi_async_veri_draw_screen(app_qspi_id_t screen_id,
152  app_qspi_id_t storage_id,
153  const app_qspi_screen_command_t * const p_screen_cmd,
154  const app_qspi_screen_info_t * const p_screen_info,
155  app_qspi_screen_veri_link_scroll_t * p_link_scroll,
156  bool is_first_call);
157 
158 /**
159  ****************************************************************************************
160  * @brief Special Async API to write one block of the Screen by DMA-LLP, every line of the block is organized in linked list.
161  * Must enable the micro-defines to enable this API:
162  * QSPI_ASYNC_VERI_LINK_DRAW_SCREEN_SUPPORT
163  *
164  * @param[in] screen_id: QSPI module ID for screen, MUST config screen qspi to register mode.
165  * @param[in] storage_id: QSPI module ID for storage, MUST config storage qspi to mmap(xip) mode.
166  * @param[in] p_screen_cmd: pointer to the screen control command
167  * @param[in] p_screen_info: pointer to the screen information
168  * @param[in] p_block_info: pointer to the block information structure
169  * @param[in] is_first_call: When first call, please set true(used this flag to decide whether send cmd or not)
170  * @return true/false
171  * @NOTE You need to control the CS outsize if (is_one_take_cs) is set true
172  * @NOTE It will generate APP_QSPI_EVT_TX_CPLT event when finish transmission.
173  ****************************************************************************************
174  */
175 bool app_qspi_async_llp_draw_block(app_qspi_id_t screen_id,
176  app_qspi_id_t storage_id,
177  const app_qspi_screen_command_t *const p_screen_cmd,
178  const app_qspi_screen_info_t *const p_screen_info,
179  app_qspi_screen_block_t *p_block_info,
180  bool is_first_call);
181 
182 /**
183  ****************************************************************************************
184  * @brief transfer big block data from sram to screen device in dma llp mode. Must override _q_malloc and _q_free in application layer
185  *
186  * @param[in] screen_id: which QSPI module want to transmit.
187  * @param[in] p_screen_cmd: Pointer to screen command configuration
188  * @param[in] p_screen_info: Pointer to screen configure information
189  * @param[in] p_buff: Pointer to data buffer to transfer
190  *
191  * @return Result of operation.
192  ****************************************************************************************
193  */
194 uint16_t app_qspi_send_display_frame(app_qspi_id_t screen_id,
195  const app_qspi_screen_command_t *const p_screen_cmd,
196  const app_qspi_screen_info_t *const p_screen_info, const uint8_t * p_buff);
197 
198 /**
199  ****************************************************************************************
200  * @brief transfer big block data from sram to screen device in dma llp mode. using when scrn_pixel_width == scrn_pixel_stride,
201  * This API costs less time than app_qspi_send_display_frame
202  *
203  * @param[in] screen_id: which QSPI module want to transmit.
204  * @param[in] p_screen_cmd: Pointer to screen command configuration
205  * @param[in] p_screen_info: Pointer to screen configure information
206  * @param[in] p_buff: Pointer to data buffer to transfer
207  *
208  * @return Result of operation.
209  ****************************************************************************************
210  */
211 SECTION_RAM_CODE uint16_t app_qspi_send_display_frame_simp(app_qspi_id_t screen_id,
212  const app_qspi_screen_command_t *const p_screen_cmd,
213  const app_qspi_screen_info_t *const p_screen_info, const uint8_t * p_buff);
214 
215 /**
216  ****************************************************************************************
217  * @brief Special API to Blit Image from memory mapped device to RAM Buffer
218  * Must enable the two micro-defines to enable this API:
219  * QSPI_BLIT_RECT_IMAGE_SUPPORT
220  *
221  * @param[in] storage_id : QSPI module ID for storage, MUST config storage qspi to mmap(xip) mode.
222  * @param[in] p_blit_config : pointer to blit config
223  * @param[in] xfer_type : pointer to the scrolling-config
224  * @return true/false
225  ****************************************************************************************
226  */
227 bool app_qspi_mmap_blit_image(app_qspi_id_t storage_id, blit_image_config_t * p_blit_config, blit_xfer_type_e xfer_type);
228 /** @} */
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 #endif
234 #endif
235 #endif
236 /** @} */
237 /** @} */
238 /** @} */
app_qspi_id_t
app_qspi_id_t
QSPI module Enumerations definition.
Definition: app_qspi.h:116
app_io.h
Header file containing functions prototypes of GPIO app library.
app_qspi_user_config.h
grx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_qspi.h
Header file containing functions prototypes of QSPI app library.
app_drv_error.h
Header file of app driver error code.
app_drv_config.h
Header file of app driver config code.