1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/************************************************************************************************
PROJECT : simple_draw
FILE : $Id: jcua.c 15225 2017-11-21 12:01:29Z matthias.nippert $
============================================================================
DESCRIPTION
============================================================================
C O P Y R I G H T
============================================================================
Copyright (c) 2013 - 2014
by
Renesas Electronics (Europe) GmbH.
Arcadiastrasse 10
D-40472 Duesseldorf
Germany
All rights reserved.
============================================================================
Purpose: only for testing, not for mass production
DISCLAIMER
LICENSEE has read, understood and accepted the terms and conditions defined in
the license agreement, especially the usage rights. In any case, it is
LICENSEE's responsibility to make sure that any user of the software complies
with the terms and conditions of the signed license agreement.
SAMPLE CODE is not part of the licensed software, as such it must not be used in
mass-production applications. It can only be used for evaluation and
demonstration purposes at customer's premises listed in the signed license
agreement.
****************************************************************************
*/
/*******************************************************************************
Section: Includes
*/
#include "r_typedefs.h" /* Renesas basic types, e.g. uint32_t */
#include "r_jcua_api.h"
#include "r_ddb_api.h"
#include "r_wm_api.h"
#include "r_tick_api.h"
#include "jcua.h"
#include "loc_graphics.h"
#define JCUA_WM_UNIT (0U)
/***********************************************************
Section: Local Variables
*/
static uint32_t loc_CallbackReached;
static uint32_t loc_InterruptFactor;
static r_jcua_Error_t JcuaError;
static uint16_t loc_JEPG_H = 0u;
static uint16_t loc_JEPG_Pitch = 0u;
extern r_wm_Window_t loc_WmWindowJcua;
static uint8_t R_WM_Frame_Flag = 0xFFu;
/***********************************************************
Section: Local Defines
*/
#define LOC_BYTE_PER_PIXEL (4)
/***********************************************************
Section: Local Functions
*/
/*******************************************************************************
Function: SetSFMAConfig
Fills the flash device config and command structure according to the target
device.
*/
void loc_JpegCallbackFunction(uint32_t Unit, r_jcua_CallbackReason_t Factor, uint32_t Param)
{
loc_CallbackReached = 1;
loc_InterruptFactor |= Factor;
return;
}
void Init_JcuaRun(uint16_t u16JEPGH, uint16_t u16JEPGPitch)
{
/* Initialize JCUA driver. */
JcuaError = R_JCUA_Init(LOC_JCUA_UNIT);
/* Open the decoder. */
if (R_JCUA_ERR_OK == JcuaError)
{
JcuaError = R_JCUA_DecoderOpen(LOC_JCUA_UNIT, loc_JpegCallbackFunction, 0);
}
loc_JEPG_H = u16JEPGH;
loc_JEPG_Pitch = u16JEPGPitch;
}
void JCUA_Enable_window(void)
{
R_WM_WindowEnable(0, &loc_WmWindowJcua);
R_WM_FrameEndMark(0, 0);
R_WM_FrameWait(0, 0);
R_WM_Frame_Flag = 1u;
}
void JCUA_Disable_window(void)
{
R_WM_WindowDisable(0, &loc_WmWindowJcua);
R_WM_FrameEndMark(0, 0);
R_WM_FrameWait(0, 0);
R_WM_Frame_Flag = 0u;
}
uint8_t Common_Get_window_Sta(void)
{
return R_WM_Frame_Flag;
}
void loc_JcuaRun(uint32_t image)
{
r_jcua_Error_t error;
r_jcua_FrameBuffer_t frame_buffer;
r_jcua_DecodeSetting_t option;
r_wm_Error_t wmErr;
/* Initialize JCUA driver. */
error = R_JCUA_Init(LOC_JCUA_UNIT);
/* Open the decoder. */
if (R_JCUA_ERR_OK == error)
{
error = R_JCUA_DecoderOpen(LOC_JCUA_UNIT, loc_JpegCallbackFunction, 0);
/* Setup frame buffer information. */
frame_buffer.Address = R_WM_WindowNewDrawBufGet(0U, &loc_WmWindowJcua);
frame_buffer.Size = loc_JEPG_Pitch * loc_JEPG_H * LOC_BYTE_PER_PIXEL;
frame_buffer.Stride = loc_JEPG_Pitch * LOC_BYTE_PER_PIXEL;
frame_buffer.Format = R_JCUA_OUTPUT_FORMAT_ARGB8888;
frame_buffer.Swap = R_JCUA_SWAP_LONG;
option.OptionFlag = R_JCUA_DECODE_OPTION_NONE;
option.ImgInfo = R_NULL;
/* Start JPEG decode.*/
loc_CallbackReached = 0;
if (R_JCUA_ERR_OK == JcuaError)
{
JcuaError = R_JCUA_DecoderStart(LOC_JCUA_UNIT, image, &frame_buffer, &option);
if (R_JCUA_ERR_OK == JcuaError)
{
/* Wait decode complete. */
while (loc_CallbackReached == 0)
{
};
wmErr = R_WM_WindowSwap(JCUA_WM_UNIT, &loc_WmWindowJcua);
if (R_WM_ERR_OK != wmErr)
{
while (1U)
{
}
}
wmErr = R_WM_FrameEndMark(JCUA_WM_UNIT, 0);
if (R_WM_ERR_OK != wmErr)
{
while (1U)
{
}
}
wmErr = R_WM_FrameWait(JCUA_WM_UNIT, 0);
if (R_WM_ERR_OK != wmErr)
{
while (0U) /*while(1u)��ʱ����while(1u)*/
{
}
}
// R_TICK_WaitMS(0, 500);
}
else
{
/* Close the decoder. */
JcuaError = R_JCUA_DecoderClose(LOC_JCUA_UNIT);
}
}
}
/* Close */
R_JCUA_DecoderClose(LOC_JCUA_UNIT);
/* De-initialize Unit 0 of JCUA driver. */
R_JCUA_DeInit(LOC_JCUA_UNIT);
}