Select one of the symbols to view example projects that use it.
 
Outline
#define _PICO_DIVIDER_H
#include "pico.h"
#include "hardware/divider.h"
div_s32s32(int32_t, int32_t);
divmod_s32s32_rem(int32_t, int32_t, int32_t *)
divmod_s32s32(int32_t, int32_t);
div_u32u32(uint32_t, uint32_t);
divmod_u32u32_rem(uint32_t, uint32_t, uint32_t *)
divmod_u32u32(uint32_t, uint32_t);
div_s64s64(int64_t, int64_t);
divmod_s64s64_rem(int64_t, int64_t, int64_t *);
divmod_s64s64(int64_t, int64_t);
div_u64u64(uint64_t, uint64_t);
divmod_u64u64_rem(uint64_t, uint64_t, uint64_t *);
divmod_u64u64(uint64_t, uint64_t);
div_s32s32_unsafe(int32_t, int32_t);
divmod_s32s32_rem_unsafe(int32_t, int32_t, int32_t *);
divmod_s32s32_unsafe(int32_t, int32_t);
div_u32u32_unsafe(uint32_t, uint32_t);
divmod_u32u32_rem_unsafe(uint32_t, uint32_t, uint32_t *);
divmod_u32u32_unsafe(uint32_t, uint32_t);
div_s64s64_unsafe(int64_t, int64_t);
divmod_s64s64_rem_unsafe(int64_t, int64_t, int64_t *);
divmod_s64s64_unsafe(int64_t, int64_t);
div_u64u64_unsafe(uint64_t, uint64_t);
divmod_u64u64_rem_unsafe(uint64_t, uint64_t, uint64_t *);
divmod_u64u64_unsafe(uint64_t, uint64_t);
Files
loading...
SourceVuRaspberry Pi Pico SDK and ExamplesPicoSDKsrc/common/pico_divider_headers/include/pico/divider.h
 
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause *//* ... */ #ifndef _PICO_DIVIDER_H #define _PICO_DIVIDER_H #include "pico.h" #include "hardware/divider.h" #ifdef __cplusplus extern "C" { #endif /** * \defgroup pico_divider pico_divider * \brief Optimized 32 and 64 bit division functions accelerated by the RP2040 hardware divider * * Additionally provides integration with the C `/` and `%` operators *//* ... */ /** \file pico/divider.h * \brief High level APIs including combined quotient and remainder functions for 32 and 64 bit accelerated by the hardware divider * \ingroup pico_divider * * These functions all call __aeabi_idiv0 or __aebi_ldiv0 on division by zero * passing the largest applicably signed value * * Functions with unsafe in their name do not save/restore divider state, so are unsafe to call from interrupts. Unsafe functions are slightly faster. *//* ... */ /** * \brief Integer divide of two signed 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient *//* ... */ int32_t div_s32s32(int32_t a, int32_t b); /** * \brief Integer divide of two signed 32-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor *//* ... */ static inline int32_t divmod_s32s32_rem(int32_t a, int32_t b, int32_t *rem) { divmod_result_t r = hw_divider_divmod_s32(a, b); *rem = to_remainder_s32(r); return to_quotient_s32(r); }{ ... } /** * \brief Integer divide of two signed 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in low word/r0, remainder in high word/r1 *//* ... */ divmod_result_t divmod_s32s32(int32_t a, int32_t b); /** * \brief Integer divide of two unsigned 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return Quotient *//* ... */ uint32_t div_u32u32(uint32_t a, uint32_t b); /** * \brief Integer divide of two unsigned 32-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor *//* ... */ static inline uint32_t divmod_u32u32_rem(uint32_t a, uint32_t b, uint32_t *rem) { divmod_result_t r = hw_divider_divmod_u32(a, b); *rem = to_remainder_u32(r); return to_quotient_u32(r); }{ ... } /** * \brief Integer divide of two unsigned 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in low word/r0, remainder in high word/r1 *//* ... */ divmod_result_t divmod_u32u32(uint32_t a, uint32_t b); /** * \brief Integer divide of two signed 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return Quotient *//* ... */ int64_t div_s64s64(int64_t a, int64_t b); /** * \brief Integer divide of two signed 64-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor *//* ... */ int64_t divmod_s64s64_rem(int64_t a, int64_t b, int64_t *rem); /** * \brief Integer divide of two signed 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in result (r0,r1), remainder in regs (r2, r3) *//* ... */ int64_t divmod_s64s64(int64_t a, int64_t b); /** * \brief Integer divide of two unsigned 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return Quotient *//* ... */ uint64_t div_u64u64(uint64_t a, uint64_t b); /** * \brief Integer divide of two unsigned 64-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor *//* ... */ uint64_t divmod_u64u64_rem(uint64_t a, uint64_t b, uint64_t *rem); /** * \brief Integer divide of two signed 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in result (r0,r1), remainder in regs (r2, r3) *//* ... */ uint64_t divmod_u64u64(uint64_t a, uint64_t b); // ----------------------------------------------------------------------- // these "unsafe" functions are slightly faster, but do not save the divider state, // so are not generally safe to be called from interrupts // ----------------------------------------------------------------------- /** * \brief Unsafe integer divide of two signed 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient * * Do not use in interrupts *//* ... */ int32_t div_s32s32_unsafe(int32_t a, int32_t b); /** * \brief Unsafe integer divide of two signed 32-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor * * Do not use in interrupts *//* ... */ int32_t divmod_s32s32_rem_unsafe(int32_t a, int32_t b, int32_t *rem); /** * \brief Unsafe integer divide of two unsigned 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in low word/r0, remainder in high word/r1 * * Do not use in interrupts *//* ... */ divmod_result_t divmod_s32s32_unsafe(int32_t a, int32_t b); /** * \brief Unsafe integer divide of two unsigned 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return Quotient * * Do not use in interrupts *//* ... */ uint32_t div_u32u32_unsafe(uint32_t a, uint32_t b); /** * \brief Unsafe integer divide of two unsigned 32-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor * * Do not use in interrupts *//* ... */ uint32_t divmod_u32u32_rem_unsafe(uint32_t a, uint32_t b, uint32_t *rem); /** * \brief Unsafe integer divide of two unsigned 32-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in low word/r0, remainder in high word/r1 * * Do not use in interrupts *//* ... */ divmod_result_t divmod_u32u32_unsafe(uint32_t a, uint32_t b); /** * \brief Unsafe integer divide of two signed 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return Quotient * * Do not use in interrupts *//* ... */ int64_t div_s64s64_unsafe(int64_t a, int64_t b); /** * \brief Unsafe integer divide of two signed 64-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor * * Do not use in interrupts *//* ... */ int64_t divmod_s64s64_rem_unsafe(int64_t a, int64_t b, int64_t *rem); /** * \brief Unsafe integer divide of two signed 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in result (r0,r1), remainder in regs (r2, r3) * * Do not use in interrupts *//* ... */ int64_t divmod_s64s64_unsafe(int64_t a, int64_t b); /** * \brief Unsafe integer divide of two unsigned 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return Quotient * * Do not use in interrupts *//* ... */ uint64_t div_u64u64_unsafe(uint64_t a, uint64_t b); /** * \brief Unsafe integer divide of two unsigned 64-bit values, with remainder * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \param [out] rem The remainder of dividend/divisor * \return Quotient result of dividend/divisor * * Do not use in interrupts *//* ... */ uint64_t divmod_u64u64_rem_unsafe(uint64_t a, uint64_t b, uint64_t *rem); /** * \brief Unsafe integer divide of two signed 64-bit values * \ingroup pico_divider * * \param a Dividend * \param b Divisor * \return quotient in result (r0,r1), remainder in regs (r2, r3) * * Do not use in interrupts *//* ... */ uint64_t divmod_u64u64_unsafe(uint64_t a, uint64_t b); #ifdef __cplusplus }extern "C" { ... } #endif/* ... */ #endif
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.