1 /*!
2 \file gd32f4xx_ipa.c
3 \brief IPA driver
4
5 \version 2016-08-15, V1.0.0, firmware for GD32F4xx
6 \version 2018-12-12, V2.0.0, firmware for GD32F4xx
7 \version 2020-09-30, V2.1.0, firmware for GD32F4xx
8 \version 2022-03-09, V3.0.0, firmware for GD32F4xx
9 */
10
11 /*
12 Copyright (c) 2022, GigaDevice Semiconductor Inc.
13
14 Redistribution and use in source and binary forms, with or without modification,
15 are permitted provided that the following conditions are met:
16
17 1. Redistributions of source code must retain the above copyright notice, this
18 list of conditions and the following disclaimer.
19 2. Redistributions in binary form must reproduce the above copyright notice,
20 this list of conditions and the following disclaimer in the documentation
21 and/or other materials provided with the distribution.
22 3. Neither the name of the copyright holder nor the names of its contributors
23 may be used to endorse or promote products derived from this software without
24 specific prior written permission.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 OF SUCH DAMAGE.
36 */
37
38 #include "gd32f4xx_ipa.h"
39
40 #define IPA_DEFAULT_VALUE 0x00000000U
41
42 /*!
43 \brief deinitialize IPA registers
44 \param[in] none
45 \param[out] none
46 \retval none
47 */
ipa_deinit(void)48 void ipa_deinit(void)
49 {
50 rcu_periph_reset_enable(RCU_IPARST);
51 rcu_periph_reset_disable(RCU_IPARST);
52 }
53
54 /*!
55 \brief enable IPA transfer
56 \param[in] none
57 \param[out] none
58 \retval none
59 */
ipa_transfer_enable(void)60 void ipa_transfer_enable(void)
61 {
62 IPA_CTL |= IPA_CTL_TEN;
63 }
64
65 /*!
66 \brief enable IPA transfer hang up
67 \param[in] none
68 \param[out] none
69 \retval none
70 */
ipa_transfer_hangup_enable(void)71 void ipa_transfer_hangup_enable(void)
72 {
73 IPA_CTL |= IPA_CTL_THU;
74 }
75
76 /*!
77 \brief disable IPA transfer hang up
78 \param[in] none
79 \param[out] none
80 \retval none
81 */
ipa_transfer_hangup_disable(void)82 void ipa_transfer_hangup_disable(void)
83 {
84 IPA_CTL &= ~(IPA_CTL_THU);
85 }
86
87 /*!
88 \brief enable IPA transfer stop
89 \param[in] none
90 \param[out] none
91 \retval none
92 */
ipa_transfer_stop_enable(void)93 void ipa_transfer_stop_enable(void)
94 {
95 IPA_CTL |= IPA_CTL_TST;
96 }
97
98 /*!
99 \brief disable IPA transfer stop
100 \param[in] none
101 \param[out] none
102 \retval none
103 */
ipa_transfer_stop_disable(void)104 void ipa_transfer_stop_disable(void)
105 {
106 IPA_CTL &= ~(IPA_CTL_TST);
107 }
108 /*!
109 \brief enable IPA foreground LUT loading
110 \param[in] none
111 \param[out] none
112 \retval none
113 */
ipa_foreground_lut_loading_enable(void)114 void ipa_foreground_lut_loading_enable(void)
115 {
116 IPA_FPCTL |= IPA_FPCTL_FLLEN;
117 }
118
119 /*!
120 \brief enable IPA background LUT loading
121 \param[in] none
122 \param[out] none
123 \retval none
124 */
ipa_background_lut_loading_enable(void)125 void ipa_background_lut_loading_enable(void)
126 {
127 IPA_BPCTL |= IPA_BPCTL_BLLEN;
128 }
129
130 /*!
131 \brief set pixel format convert mode, the function is invalid when the IPA transfer is enabled
132 \param[in] pfcm: pixel format convert mode
133 only one parameter can be selected which is shown as below:
134 \arg IPA_FGTODE: foreground memory to destination memory without pixel format convert
135 \arg IPA_FGTODE_PF_CONVERT: foreground memory to destination memory with pixel format convert
136 \arg IPA_FGBGTODE: blending foreground and background memory to destination memory
137 \arg IPA_FILL_UP_DE: fill up destination memory with specific color
138 \param[out] none
139 \retval none
140 */
ipa_pixel_format_convert_mode_set(uint32_t pfcm)141 void ipa_pixel_format_convert_mode_set(uint32_t pfcm)
142 {
143 IPA_CTL &= ~(IPA_CTL_PFCM);
144 IPA_CTL |= pfcm;
145 }
146
147 /*!
148 \brief initialize the structure of IPA foreground parameter struct with the default values, it is
149 suggested that call this function after an ipa_foreground_parameter_struct structure is defined
150 \param[in] none
151 \param[out] foreground_struct: the data needed to initialize foreground
152 foreground_memaddr: foreground memory base address
153 foreground_lineoff: foreground line offset
154 foreground_prealpha: foreground pre-defined alpha value
155 foreground_alpha_algorithm: IPA_FG_ALPHA_MODE_0,IPA_FG_ALPHA_MODE_1,IPA_FG_ALPHA_MODE_2
156 foreground_pf: foreground pixel format(FOREGROUND_PPF_ARGB8888,FOREGROUND_PPF_RGB888,FOREGROUND_PPF_RGB565,
157 FOREGROUND_PPF_ARG1555,FOREGROUND_PPF_ARGB4444,FOREGROUND_PPF_L8,FOREGROUND_PPF_AL44,
158 FOREGROUND_PPF_AL88,FOREGROUND_PPF_L4,FOREGROUND_PPF_A8,FOREGROUND_PPF_A4)
159 foreground_prered: foreground pre-defined red value
160 foreground_pregreen: foreground pre-defined green value
161 foreground_preblue: foreground pre-defined blue value
162 \retval none
163 */
ipa_foreground_struct_para_init(ipa_foreground_parameter_struct * foreground_struct)164 void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct *foreground_struct)
165 {
166 /* initialize the struct parameters with default values */
167 foreground_struct->foreground_memaddr = IPA_DEFAULT_VALUE;
168 foreground_struct->foreground_lineoff = IPA_DEFAULT_VALUE;
169 foreground_struct->foreground_prealpha = IPA_DEFAULT_VALUE;
170 foreground_struct->foreground_alpha_algorithm = IPA_FG_ALPHA_MODE_0;
171 foreground_struct->foreground_pf = FOREGROUND_PPF_ARGB8888;
172 foreground_struct->foreground_prered = IPA_DEFAULT_VALUE;
173 foreground_struct->foreground_pregreen = IPA_DEFAULT_VALUE;
174 foreground_struct->foreground_preblue = IPA_DEFAULT_VALUE;
175 }
176
177 /*!
178 \brief initialize foreground parameters
179 \param[in] foreground_struct: the data needed to initialize foreground
180 foreground_memaddr: foreground memory base address
181 foreground_lineoff: foreground line offset
182 foreground_prealpha: foreground pre-defined alpha value
183 foreground_alpha_algorithm: IPA_FG_ALPHA_MODE_0,IPA_FG_ALPHA_MODE_1,IPA_FG_ALPHA_MODE_2
184 foreground_pf: foreground pixel format(FOREGROUND_PPF_ARGB8888,FOREGROUND_PPF_RGB888,FOREGROUND_PPF_RGB565,
185 FOREGROUND_PPF_ARG1555,FOREGROUND_PPF_ARGB4444,FOREGROUND_PPF_L8,FOREGROUND_PPF_AL44,
186 FOREGROUND_PPF_AL88,FOREGROUND_PPF_L4,FOREGROUND_PPF_A8,FOREGROUND_PPF_A4)
187 foreground_prered: foreground pre-defined red value
188 foreground_pregreen: foreground pre-defined green value
189 foreground_preblue: foreground pre-defined blue value
190 \param[out] none
191 \retval none
192 */
ipa_foreground_init(ipa_foreground_parameter_struct * foreground_struct)193 void ipa_foreground_init(ipa_foreground_parameter_struct *foreground_struct)
194 {
195 FlagStatus tempflag = RESET;
196 if(RESET != (IPA_CTL & IPA_CTL_TEN)) {
197 tempflag = SET;
198 /* reset the TEN in order to configure the following bits */
199 IPA_CTL &= ~IPA_CTL_TEN;
200 }
201
202 /* foreground memory base address configuration */
203 IPA_FMADDR &= ~(IPA_FMADDR_FMADDR);
204 IPA_FMADDR = foreground_struct->foreground_memaddr;
205 /* foreground line offset configuration */
206 IPA_FLOFF &= ~(IPA_FLOFF_FLOFF);
207 IPA_FLOFF = foreground_struct->foreground_lineoff;
208 /* foreground pixel format pre-defined alpha, alpha calculation algorithm configuration */
209 IPA_FPCTL &= ~(IPA_FPCTL_FPDAV | IPA_FPCTL_FAVCA | IPA_FPCTL_FPF);
210 IPA_FPCTL |= (foreground_struct->foreground_prealpha << 24U);
211 IPA_FPCTL |= foreground_struct->foreground_alpha_algorithm;
212 IPA_FPCTL |= foreground_struct->foreground_pf;
213 /* foreground pre-defined red green blue configuration */
214 IPA_FPV &= ~(IPA_FPV_FPDRV | IPA_FPV_FPDGV | IPA_FPV_FPDBV);
215 IPA_FPV |= ((foreground_struct->foreground_prered << 16U) | (foreground_struct->foreground_pregreen << 8U)
216 | (foreground_struct->foreground_preblue));
217
218 if(SET == tempflag) {
219 /* restore the state of TEN */
220 IPA_CTL |= IPA_CTL_TEN;
221 }
222 }
223
224 /*!
225 \brief initialize the structure of IPA background parameter struct with the default values, it is
226 suggested that call this function after an ipa_background_parameter_struct structure is defined
227 \param[in] none
228 \param[out] background_struct: the data needed to initialize background
229 background_memaddr: background memory base address
230 background_lineoff: background line offset
231 background_prealpha: background pre-defined alpha value
232 background_alpha_algorithm: IPA_BG_ALPHA_MODE_0,IPA_BG_ALPHA_MODE_1,IPA_BG_ALPHA_MODE_2
233 background_pf: background pixel format(BACKGROUND_PPF_ARGB8888,BACKGROUND_PPF_RGB888,BACKGROUND_PPF_RGB565,
234 BACKGROUND_PPF_ARG1555,BACKGROUND_PPF_ARGB4444,BACKGROUND_PPF_L8,BACKGROUND_PPF_AL44,
235 BACKGROUND_PPF_AL88,BACKGROUND_PPF_L4,BACKGROUND_PPF_A8,BACKGROUND_PPF_A4)
236 background_prered: background pre-defined red value
237 background_pregreen: background pre-defined green value
238 background_preblue: background pre-defined blue value
239 \retval none
240 */
ipa_background_struct_para_init(ipa_background_parameter_struct * background_struct)241 void ipa_background_struct_para_init(ipa_background_parameter_struct *background_struct)
242 {
243 /* initialize the struct parameters with default values */
244 background_struct->background_memaddr = IPA_DEFAULT_VALUE;
245 background_struct->background_lineoff = IPA_DEFAULT_VALUE;
246 background_struct->background_prealpha = IPA_DEFAULT_VALUE;
247 background_struct->background_alpha_algorithm = IPA_BG_ALPHA_MODE_0;
248 background_struct->background_pf = BACKGROUND_PPF_ARGB8888;
249 background_struct->background_prered = IPA_DEFAULT_VALUE;
250 background_struct->background_pregreen = IPA_DEFAULT_VALUE;
251 background_struct->background_preblue = IPA_DEFAULT_VALUE;
252 }
253
254 /*!
255 \brief initialize background parameters
256 \param[in] background_struct: the data needed to initialize background
257 background_memaddr: background memory base address
258 background_lineoff: background line offset
259 background_prealpha: background pre-defined alpha value
260 background_alpha_algorithm: IPA_BG_ALPHA_MODE_0,IPA_FG_ALPHA_MODE_1,IPA_FG_ALPHA_MODE_2
261 background_pf: background pixel format(BACKGROUND_PPF_ARGB8888,BACKGROUND_PPF_RGB888,BACKGROUND_PPF_RGB565,
262 BACKGROUND_PPF_ARG1555,BACKGROUND_PPF_ARGB4444,BACKGROUND_PPF_L8,BACKGROUND_PPF_AL44,
263 BACKGROUND_PPF_AL88,BACKGROUND_PPF_L4,BACKGROUND_PPF_A8,BACKGROUND_PPF_A4)
264 background_prered: background pre-defined red value
265 background_pregreen: background pre-defined green value
266 background_preblue: background pre-defined blue value
267 \param[out] none
268 \retval none
269 */
ipa_background_init(ipa_background_parameter_struct * background_struct)270 void ipa_background_init(ipa_background_parameter_struct *background_struct)
271 {
272 FlagStatus tempflag = RESET;
273 if(RESET != (IPA_CTL & IPA_CTL_TEN)) {
274 tempflag = SET;
275 /* reset the TEN in order to configure the following bits */
276 IPA_CTL &= ~IPA_CTL_TEN;
277 }
278
279 /* background memory base address configuration */
280 IPA_BMADDR &= ~(IPA_BMADDR_BMADDR);
281 IPA_BMADDR = background_struct->background_memaddr;
282 /* background line offset configuration */
283 IPA_BLOFF &= ~(IPA_BLOFF_BLOFF);
284 IPA_BLOFF = background_struct->background_lineoff;
285 /* background pixel format pre-defined alpha, alpha calculation algorithm configuration */
286 IPA_BPCTL &= ~(IPA_BPCTL_BPDAV | IPA_BPCTL_BAVCA | IPA_BPCTL_BPF);
287 IPA_BPCTL |= (background_struct->background_prealpha << 24U);
288 IPA_BPCTL |= background_struct->background_alpha_algorithm;
289 IPA_BPCTL |= background_struct->background_pf;
290 /* background pre-defined red green blue configuration */
291 IPA_BPV &= ~(IPA_BPV_BPDRV | IPA_BPV_BPDGV | IPA_BPV_BPDBV);
292 IPA_BPV |= ((background_struct->background_prered << 16U) | (background_struct->background_pregreen << 8U)
293 | (background_struct->background_preblue));
294
295 if(SET == tempflag) {
296 /* restore the state of TEN */
297 IPA_CTL |= IPA_CTL_TEN;
298 }
299 }
300
301 /*!
302 \brief initialize the structure of IPA destination parameter struct with the default values, it is
303 suggested that call this function after an ipa_destination_parameter_struct structure is defined
304 \param[in] none
305 \param[out] destination_struct: the data needed to initialize destination parameter
306 destination_pf: IPA_DPF_ARGB8888,IPA_DPF_RGB888,IPA_DPF_RGB565,IPA_DPF_ARGB1555,
307 IPA_DPF_ARGB4444,refer to ipa_dpf_enum
308 destination_lineoff: destination line offset
309 destination_prealpha: destination pre-defined alpha value
310 destination_prered: destination pre-defined red value
311 destination_pregreen: destination pre-defined green value
312 destination_preblue: destination pre-defined blue value
313 destination_memaddr: destination memory base address
314 image_width: width of the image to be processed
315 image_height: height of the image to be processed
316 \retval none
317 */
ipa_destination_struct_para_init(ipa_destination_parameter_struct * destination_struct)318 void ipa_destination_struct_para_init(ipa_destination_parameter_struct *destination_struct)
319 {
320 /* initialize the struct parameters with default values */
321 destination_struct->destination_pf = IPA_DPF_ARGB8888;
322 destination_struct->destination_lineoff = IPA_DEFAULT_VALUE;
323 destination_struct->destination_prealpha = IPA_DEFAULT_VALUE;
324 destination_struct->destination_prered = IPA_DEFAULT_VALUE;
325 destination_struct->destination_pregreen = IPA_DEFAULT_VALUE;
326 destination_struct->destination_preblue = IPA_DEFAULT_VALUE;
327 destination_struct->destination_memaddr = IPA_DEFAULT_VALUE;
328 destination_struct->image_width = IPA_DEFAULT_VALUE;
329 destination_struct->image_height = IPA_DEFAULT_VALUE;
330 }
331
332 /*!
333 \brief initialize destination parameters
334 \param[in] destination_struct: the data needed to initialize destination parameters
335 destination_pf: IPA_DPF_ARGB8888,IPA_DPF_RGB888,IPA_DPF_RGB565,IPA_DPF_ARGB1555,
336 IPA_DPF_ARGB4444,refer to ipa_dpf_enum
337 destination_lineoff: destination line offset
338 destination_prealpha: destination pre-defined alpha value
339 destination_prered: destination pre-defined red value
340 destination_pregreen: destination pre-defined green value
341 destination_preblue: destination pre-defined blue value
342 destination_memaddr: destination memory base address
343 image_width: width of the image to be processed
344 image_height: height of the image to be processed
345 \param[out] none
346 \retval none
347 */
ipa_destination_init(ipa_destination_parameter_struct * destination_struct)348 void ipa_destination_init(ipa_destination_parameter_struct *destination_struct)
349 {
350 uint32_t destination_pixelformat;
351 FlagStatus tempflag = RESET;
352 if(RESET != (IPA_CTL & IPA_CTL_TEN)) {
353 tempflag = SET;
354 /* reset the TEN in order to configure the following bits */
355 IPA_CTL &= ~IPA_CTL_TEN;
356 }
357
358 /* destination pixel format configuration */
359 IPA_DPCTL &= ~(IPA_DPCTL_DPF);
360 IPA_DPCTL = destination_struct->destination_pf;
361 destination_pixelformat = destination_struct->destination_pf;
362 /* destination pixel format ARGB8888 */
363 switch(destination_pixelformat) {
364 case IPA_DPF_ARGB8888:
365 IPA_DPV &= ~(IPA_DPV_DPDBV_0 | (IPA_DPV_DPDGV_0) | (IPA_DPV_DPDRV_0) | (IPA_DPV_DPDAV_0));
366 IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 8U)
367 | (destination_struct->destination_prered << 16U)
368 | (destination_struct->destination_prealpha << 24U));
369 break;
370 /* destination pixel format RGB888 */
371 case IPA_DPF_RGB888:
372 IPA_DPV &= ~(IPA_DPV_DPDBV_1 | (IPA_DPV_DPDGV_1) | (IPA_DPV_DPDRV_1));
373 IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 8U)
374 | (destination_struct->destination_prered << 16U));
375 break;
376 /* destination pixel format RGB565 */
377 case IPA_DPF_RGB565:
378 IPA_DPV &= ~(IPA_DPV_DPDBV_2 | (IPA_DPV_DPDGV_2) | (IPA_DPV_DPDRV_2));
379 IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 5U)
380 | (destination_struct->destination_prered << 11U));
381 break;
382 /* destination pixel format ARGB1555 */
383 case IPA_DPF_ARGB1555:
384 IPA_DPV &= ~(IPA_DPV_DPDBV_3 | (IPA_DPV_DPDGV_3) | (IPA_DPV_DPDRV_3) | (IPA_DPV_DPDAV_3));
385 IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 5U)
386 | (destination_struct->destination_prered << 10U)
387 | (destination_struct->destination_prealpha << 15U));
388 break;
389 /* destination pixel format ARGB4444 */
390 case IPA_DPF_ARGB4444:
391 IPA_DPV &= ~(IPA_DPV_DPDBV_4 | (IPA_DPV_DPDGV_4) | (IPA_DPV_DPDRV_4) | (IPA_DPV_DPDAV_4));
392 IPA_DPV = (destination_struct->destination_preblue | (destination_struct->destination_pregreen << 4U)
393 | (destination_struct->destination_prered << 8U)
394 | (destination_struct->destination_prealpha << 12U));
395 break;
396 default:
397 break;
398 }
399 /* destination memory base address configuration */
400 IPA_DMADDR &= ~(IPA_DMADDR_DMADDR);
401 IPA_DMADDR = destination_struct->destination_memaddr;
402 /* destination line offset configuration */
403 IPA_DLOFF &= ~(IPA_DLOFF_DLOFF);
404 IPA_DLOFF = destination_struct->destination_lineoff;
405 /* image size configuration */
406 IPA_IMS &= ~(IPA_IMS_HEIGHT | IPA_IMS_WIDTH);
407 IPA_IMS |= ((destination_struct->image_width << 16U) | (destination_struct->image_height));
408
409 if(SET == tempflag) {
410 /* restore the state of TEN */
411 IPA_CTL |= IPA_CTL_TEN;
412 }
413 }
414
415 /*!
416 \brief initialize IPA foreground LUT parameters
417 \param[in] fg_lut_num: foreground LUT number of pixel
418 \param[in] fg_lut_pf: foreground LUT pixel format(IPA_LUT_PF_ARGB8888, IPA_LUT_PF_RGB888)
419 \param[in] fg_lut_addr: foreground LUT memory base address
420 \param[out] none
421 \retval none
422 */
ipa_foreground_lut_init(uint8_t fg_lut_num,uint8_t fg_lut_pf,uint32_t fg_lut_addr)423 void ipa_foreground_lut_init(uint8_t fg_lut_num, uint8_t fg_lut_pf, uint32_t fg_lut_addr)
424 {
425 FlagStatus tempflag = RESET;
426 if(RESET != (IPA_FPCTL & IPA_FPCTL_FLLEN)) {
427 tempflag = SET;
428 /* reset the FLLEN in order to configure the following bits */
429 IPA_FPCTL &= ~IPA_FPCTL_FLLEN;
430 }
431
432 /* foreground LUT number of pixel configuration */
433 IPA_FPCTL |= ((uint32_t)fg_lut_num << 8U);
434 /* foreground LUT pixel format configuration */
435 if(IPA_LUT_PF_RGB888 == fg_lut_pf) {
436 IPA_FPCTL |= IPA_FPCTL_FLPF;
437 } else {
438 IPA_FPCTL &= ~(IPA_FPCTL_FLPF);
439 }
440 /* foreground LUT memory base address configuration */
441 IPA_FLMADDR &= ~(IPA_FLMADDR_FLMADDR);
442 IPA_FLMADDR = fg_lut_addr;
443
444 if(SET == tempflag) {
445 /* restore the state of FLLEN */
446 IPA_FPCTL |= IPA_FPCTL_FLLEN;
447 }
448 }
449
450 /*!
451 \brief initialize IPA background LUT parameters
452 \param[in] bg_lut_num: background LUT number of pixel
453 \param[in] bg_lut_pf: background LUT pixel format(IPA_LUT_PF_ARGB8888, IPA_LUT_PF_RGB888)
454 \param[in] bg_lut_addr: background LUT memory base address
455 \param[out] none
456 \retval none
457 */
ipa_background_lut_init(uint8_t bg_lut_num,uint8_t bg_lut_pf,uint32_t bg_lut_addr)458 void ipa_background_lut_init(uint8_t bg_lut_num, uint8_t bg_lut_pf, uint32_t bg_lut_addr)
459 {
460 FlagStatus tempflag = RESET;
461 if(RESET != (IPA_BPCTL & IPA_BPCTL_BLLEN)) {
462 tempflag = SET;
463 /* reset the BLLEN in order to configure the following bits */
464 IPA_BPCTL &= ~IPA_BPCTL_BLLEN;
465 }
466
467 /* background LUT number of pixel configuration */
468 IPA_BPCTL |= ((uint32_t)bg_lut_num << 8U);
469 /* background LUT pixel format configuration */
470 if(IPA_LUT_PF_RGB888 == bg_lut_pf) {
471 IPA_BPCTL |= IPA_BPCTL_BLPF;
472 } else {
473 IPA_BPCTL &= ~(IPA_BPCTL_BLPF);
474 }
475 /* background LUT memory base address configuration */
476 IPA_BLMADDR &= ~(IPA_BLMADDR_BLMADDR);
477 IPA_BLMADDR = bg_lut_addr;
478
479 if(SET == tempflag) {
480 /* restore the state of BLLEN */
481 IPA_BPCTL |= IPA_BPCTL_BLLEN;
482 }
483 }
484
485 /*!
486 \brief configure IPA line mark
487 \param[in] line_num: line number
488 \param[out] none
489 \retval none
490 */
ipa_line_mark_config(uint16_t line_num)491 void ipa_line_mark_config(uint16_t line_num)
492 {
493 IPA_LM &= ~(IPA_LM_LM);
494 IPA_LM = line_num;
495 }
496
497 /*!
498 \brief inter-timer enable or disable
499 \param[in] timer_cfg: IPA_INTER_TIMER_ENABLE,IPA_INTER_TIMER_DISABLE
500 \param[out] none
501 \retval none
502 */
ipa_inter_timer_config(uint8_t timer_cfg)503 void ipa_inter_timer_config(uint8_t timer_cfg)
504 {
505 if(IPA_INTER_TIMER_ENABLE == timer_cfg) {
506 IPA_ITCTL |= IPA_ITCTL_ITEN;
507 } else {
508 IPA_ITCTL &= ~(IPA_ITCTL_ITEN);
509 }
510 }
511
512 /*!
513 \brief configure the number of clock cycles interval
514 \param[in] clk_num: the number of clock cycles
515 \param[out] none
516 \retval none
517 */
ipa_interval_clock_num_config(uint8_t clk_num)518 void ipa_interval_clock_num_config(uint8_t clk_num)
519 {
520 /* NCCI[7:0] bits have no meaning if ITEN is '0' */
521 IPA_ITCTL &= ~(IPA_ITCTL_NCCI);
522 IPA_ITCTL |= ((uint32_t)clk_num << 8U);
523 }
524
525 /*!
526 \brief get IPA flag status in IPA_INTF register
527 \param[in] flag: IPA flags
528 one or more parameters can be selected which are shown as below:
529 \arg IPA_FLAG_TAE: transfer access error interrupt flag
530 \arg IPA_FLAG_FTF: full transfer finish interrupt flag
531 \arg IPA_FLAG_TLM: transfer line mark interrupt flag
532 \arg IPA_FLAG_LAC: LUT access conflict interrupt flag
533 \arg IPA_FLAG_LLF: LUT loading finish interrupt flag
534 \arg IPA_FLAG_WCF: wrong configuration interrupt flag
535 \param[out] none
536 \retval none
537 */
ipa_flag_get(uint32_t flag)538 FlagStatus ipa_flag_get(uint32_t flag)
539 {
540 if(RESET != (IPA_INTF & flag)) {
541 return SET;
542 } else {
543 return RESET;
544 }
545 }
546
547 /*!
548 \brief clear IPA flag in IPA_INTF register
549 \param[in] flag: IPA flags
550 one or more parameters can be selected which are shown as below:
551 \arg IPA_FLAG_TAE: transfer access error interrupt flag
552 \arg IPA_FLAG_FTF: full transfer finish interrupt flag
553 \arg IPA_FLAG_TLM: transfer line mark interrupt flag
554 \arg IPA_FLAG_LAC: LUT access conflict interrupt flag
555 \arg IPA_FLAG_LLF: LUT loading finish interrupt flag
556 \arg IPA_FLAG_WCF: wrong configuration interrupt flag
557 \param[out] none
558 \retval none
559 */
ipa_flag_clear(uint32_t flag)560 void ipa_flag_clear(uint32_t flag)
561 {
562 IPA_INTC |= (flag);
563 }
564
565 /*!
566 \brief enable IPA interrupt
567 \param[in] int_flag: IPA interrupt flags
568 one or more parameters can be selected which are shown as below:
569 \arg IPA_INT_TAE: transfer access error interrupt
570 \arg IPA_INT_FTF: full transfer finish interrupt
571 \arg IPA_INT_TLM: transfer line mark interrupt
572 \arg IPA_INT_LAC: LUT access conflict interrupt
573 \arg IPA_INT_LLF: LUT loading finish interrupt
574 \arg IPA_INT_WCF: wrong configuration interrupt
575 \param[out] none
576 \retval none
577 */
ipa_interrupt_enable(uint32_t int_flag)578 void ipa_interrupt_enable(uint32_t int_flag)
579 {
580 IPA_CTL |= (int_flag);
581 }
582
583 /*!
584 \brief disable IPA interrupt
585 \param[in] int_flag: IPA interrupt flags
586 one or more parameters can be selected which are shown as below:
587 \arg IPA_INT_TAE: transfer access error interrupt
588 \arg IPA_INT_FTF: full transfer finish interrupt
589 \arg IPA_INT_TLM: transfer line mark interrupt
590 \arg IPA_INT_LAC: LUT access conflict interrupt
591 \arg IPA_INT_LLF: LUT loading finish interrupt
592 \arg IPA_INT_WCF: wrong configuration interrupt
593 \param[out] none
594 \retval none
595 */
ipa_interrupt_disable(uint32_t int_flag)596 void ipa_interrupt_disable(uint32_t int_flag)
597 {
598 IPA_CTL &= ~(int_flag);
599 }
600
601 /*!
602 \brief get IPA interrupt flag
603 \param[in] int_flag: IPA interrupt flag flags
604 one or more parameters can be selected which are shown as below:
605 \arg IPA_INT_FLAG_TAE: transfer access error interrupt flag
606 \arg IPA_INT_FLAG_FTF: full transfer finish interrupt flag
607 \arg IPA_INT_FLAG_TLM: transfer line mark interrupt flag
608 \arg IPA_INT_FLAG_LAC: LUT access conflict interrupt flag
609 \arg IPA_INT_FLAG_LLF: LUT loading finish interrupt flag
610 \arg IPA_INT_FLAG_WCF: wrong configuration interrupt flag
611 \param[out] none
612 \retval none
613 */
ipa_interrupt_flag_get(uint32_t int_flag)614 FlagStatus ipa_interrupt_flag_get(uint32_t int_flag)
615 {
616 if(0U != (IPA_INTF & int_flag)) {
617 return SET;
618 } else {
619 return RESET;
620 }
621 }
622
623 /*!
624 \brief clear IPA interrupt flag
625 \param[in] int_flag: IPA interrupt flag flags
626 one or more parameters can be selected which are shown as below:
627 \arg IPA_INT_FLAG_TAE: transfer access error interrupt flag
628 \arg IPA_INT_FLAG_FTF: full transfer finish interrupt flag
629 \arg IPA_INT_FLAG_TLM: transfer line mark interrupt flag
630 \arg IPA_INT_FLAG_LAC: LUT access conflict interrupt flag
631 \arg IPA_INT_FLAG_LLF: LUT loading finish interrupt flag
632 \arg IPA_INT_FLAG_WCF: wrong configuration interrupt flag
633 \param[out] none
634 \retval none
635 */
ipa_interrupt_flag_clear(uint32_t int_flag)636 void ipa_interrupt_flag_clear(uint32_t int_flag)
637 {
638 IPA_INTC |= (int_flag);
639 }
640