Arm-2D  
2D Image Processing Library for Cortex-M Processors
 
Loading...
Searching...
No Matches
arm_2d_helper.h
1/*
2 * Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19/* ----------------------------------------------------------------------
20 * Project: Arm-2D Library
21 * Title: #include "arm_2d_helper.h"
22 * Description: Public header file for the all helper services
23 *
24 * $Date: 10. Dec 2022
25 * $Revision: V.1.6.1
26 *
27 * Target Processor: Cortex-M cores
28 * -------------------------------------------------------------------- */
29
30#ifndef __ARM_2D_HELPER_H__
31#define __ARM_2D_HELPER_H__
32
33/*============================ INCLUDES ======================================*/
34#include "arm_2d.h"
35#include "./__arm_2d_helper_common.h"
36#include "./arm_2d_helper_pfb.h"
37#include "./arm_2d_helper_scene.h"
38#include "./arm_2d_disp_adapters.h"
39#include "./arm_2d_helper_list.h"
40
41#include <stdlib.h>
42#include <assert.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#if defined(__clang__)
49# pragma clang diagnostic push
50# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
51# pragma clang diagnostic ignored "-Wunused-function"
52#endif
53
54
55/*!
56 * \addtogroup gHelper 7 Helper Services
57 * @{
58 */
59/*============================ MACROS ========================================*/
60/*============================ MACROFIED FUNCTIONS ===========================*/
61
62/*!
63 * \brief set an alarm with given period and check the status
64 *
65 * \param[in] __ms a time period in millisecond
66 * \param[in] ... an optional timestamp holder
67 *
68 * \return bool whether it is timeout
69 */
70#define arm_2d_helper_is_time_out(__ms, ...) \
71 ({ static int64_t arm_2d_safe_name(s_lTimestamp); \
72 __arm_2d_helper_is_time_out(arm_2d_helper_convert_ms_to_ticks(__ms), \
73 (&arm_2d_safe_name(s_lTimestamp),##__VA_ARGS__));})
74
75
76/*!
77 * \brief calculate the stroke of a liner slider based on time
78 *
79 * \param[in] __from the start of the slider
80 * \param[in] __to the end of the slider
81 * \param[in] __ms a given period (ms) in which the slider should finish the
82 * whole stroke
83 * \param[out] __stroke_ptr the address of an int32_t stroke variable
84 * \param[in] ... an optional address of a timestamp variable, if you omit it,
85 * NULL will be passed, and the code that call this funtion will not
86 * be reentrant.
87 * \retval true the slider has finished the whole stroke
88 * \retval false the slider hasn't reach the target end
89 */
90#define arm_2d_helper_time_liner_slider( __from, \
91 __to, \
92 __ms, \
93 __stroke_ptr, \
94 ...) \
95 ({static int64_t arm_2d_safe_name(s_lTimestamp); \
96 __arm_2d_helper_time_line_slider((__from), \
97 (__to), \
98 arm_2d_helper_convert_ms_to_ticks(__ms), \
99 (__stroke_ptr), \
100 (&arm_2d_safe_name(s_lTimestamp),##__VA_ARGS__));})
101
102/*!
103 * \brief calculate the stroke of a cosine slider based on time
104 *
105 * \param[in] __from the start of the slider
106 * \param[in] __to the end of the slider
107 * \param[in] __ms a given period (ms) in which the slider should finish the
108 * whole stroke
109 * \param[in] __phase the phase offset
110 * \param[out] __stroke_ptr the address of an int32_t stroke variable
111 * \param[in] ... an optional address of a timestamp variable, if you omit it,
112 * NULL will be passed, and the code that call this funtion will not
113 * be reentrant.
114 * \retval true the slider has finished the whole stroke
115 * \retval false the slider hasn't reach the target end
116 */
117#define arm_2d_helper_time_cos_slider( __from, \
118 __to, \
119 __ms, \
120 __phase, \
121 __stroke_ptr, \
122 ...) \
123 ({static int64_t arm_2d_safe_name(s_lTimestamp); \
124 __arm_2d_helper_time_cos_slider((__from), \
125 (__to), \
126 arm_2d_helper_convert_ms_to_ticks(__ms), \
127 (__phase), \
128 (__stroke_ptr), \
129 (&arm_2d_safe_name(s_lTimestamp),##__VA_ARGS__));})
130
131/*!
132 * \brief calculate the stroke of a cosine slider(0~pi) based on time
133 *
134 * \param[in] __from the start of the slider
135 * \param[in] __to the end of the slider
136 * \param[in] __ms a given period (ms) in which the slider should finish the
137 * whole stroke
138 * \param[out] __stroke_ptr the address of an int32_t stroke variable
139 * \param[in] ... an optional address of a timestamp variable, if you omit it,
140 * NULL will be passed, and the code that call this funtion will not
141 * be reentrant.
142 * \retval true the slider has finished the whole stroke
143 * \retval false the slider hasn't reach the target end
144 */
145#define arm_2d_helper_time_half_cos_slider( __from, \
146 __to, \
147 __ms, \
148 __stroke_ptr, \
149 ...) \
150 ({static int64_t arm_2d_safe_name(s_lTimestamp); \
151 __arm_2d_helper_time_half_cos_slider((__from), \
152 (__to), \
153 arm_2d_helper_convert_ms_to_ticks(__ms), \
154 (__stroke_ptr), \
155 (&arm_2d_safe_name(s_lTimestamp),##__VA_ARGS__));})
156
157/*============================ TYPES =========================================*/
158/*============================ GLOBAL VARIABLES ==============================*/
159/*============================ LOCAL VARIABLES ===============================*/
160/*============================ PROTOTYPES ====================================*/
161
162/*!
163 * \brief initialize helper services
164 */
165extern
167
168/*!
169 * \brief convert ticks of a reference timer to millisecond
170 *
171 * \param[in] lTick the tick count
172 * \return int64_t the millisecond
173 */
174extern
176
177/*!
178 * \brief convert millisecond into ticks of the reference timer
179 *
180 * \param[in] wMS the target time in millisecond
181 * \return int64_t the ticks
182 */
183extern
185
186/*!
187 * \brief get the reference clock frequency
188 * \return uint32_t the frequency
189 */
190extern
192
193/*!
194 * \brief get the current system stamp from the reference clock
195 *
196 * \return int64_t the timestamp in ticks (no overflow issue)
197 * \note you have to call arm_2d_helper_convert_ticks_to_ms() to convert the
198 * the timestamp into milliseconds when required.
199 */
200extern
202
203
204/*!
205 * \brief set an alarm with given period and check the status
206 *
207 * \param[in] lPeriod a time period in ticks
208 * \param[in] plTimestamp a pointer points to an int64_t integer, if NULL is
209 * passed, an static local variable inside the function will be used
210 * \return bool whether it is timeout or not
211 */
212ARM_NONNULL(2)
213extern
214bool __arm_2d_helper_is_time_out(int64_t lPeriod, int64_t *plTimestamp);
215
216/*!
217 * \brief calculate the stroke of a liner slider based on time
218 *
219 * \param[in] nFrom the start of the slider
220 * \param[in] nTo the end of the slider
221 * \param[in] lPeriod a given period in which the slider should finish the whole
222 * stroke
223 * \param[out] pnStroke the address of an int32_t stroke variable
224 * \param[in] plTimestamp the address of a timestamp variable, if you pass NULL
225 * the code that call this funtion will not be reentrant.
226 * \retval true the slider has finished the whole stroke
227 * \retval false the slider hasn't reach the target end
228 */
229ARM_NONNULL(4,5)
230extern
232 int32_t nTo,
233 int64_t lPeriod,
234 int32_t *pnStroke,
235 int64_t *plTimestamp);
236
237/*!
238 * \brief calculate the stroke of a cosine slider (0~pi) based on time
239 *
240 * \param[in] nFrom the start of the slider
241 * \param[in] nTo the end of the slider
242 * \param[in] lPeriod a given period in which the slider should finish the whole
243 * stroke
244 * \param[out] pnStroke the address of an int32_t stroke variable
245 * \param[in] plTimestamp the address of a timestamp variable, if you pass NULL
246 * the code that call this funtion will not be reentrant.
247 * \retval true the slider has finished the whole stroke
248 * \retval false the slider hasn't reach the target end
249 */
250ARM_NONNULL(4,5)
251extern
253 int32_t nTo,
254 int64_t lPeriod,
255 int32_t *pnStroke,
256 int64_t *plTimestamp);
257
258/*!
259 * \brief calculate the stroke of a consine slider (0~2pi) based on time
260 *
261 * \param[in] nFrom the start of the slider
262 * \param[in] nTo the end of the slider
263 * \param[in] lPeriod a given period in which the slider should finish the whole
264 * stroke
265 * \param[in] lPhase the phase offset
266 * \param[out] pnStroke the address of an int32_t stroke variable
267 * \param[in] plTimestamp the address of a timestamp variable, if you pass NULL
268 * the code that call this funtion will not be reentrant.
269 * \retval true the slider has finished the whole stroke
270 * \retval false the slider hasn't reach the target end
271 */
272ARM_NONNULL(5,6)
273extern
275 int32_t nTo,
276 int64_t lPeriod,
277 float fPhase,
278 int32_t *pnStroke,
279 int64_t *plTimestamp);
280
281/*!
282 * \brier colour intrapolation
283 * \param[in] wFrom a 32bit colour (4 8bit colour channels) on the start
284 * \param[in] wTo a 32bit colour (4 8bit colour channels) on the end
285 * \param[in] nDistance the reference full distance between two end points
286 * \param[in] nOffset the offset from the start
287 * \return uint32_t 32bit colour
288 */
289extern
290uint32_t __arm_2d_helper_colour_slider( uint32_t wFrom,
291 uint32_t wTo,
292 int32_t nDistance,
293 int32_t nOffset);
294
295/*! @} */
296
297#if defined(__clang__)
298# pragma clang diagnostic pop
299#endif
300
301#ifdef __cplusplus
302}
303#endif
304
305#endif