@web-font-path: "roboto-debian.css";
RP2040 Low Low-level hardware-divider API. Non-RP2040 platforms provide software versions of all the functions. More...
Functions | |
static divmod_result_t | hw_divider_divmod_s32 (int32_t a, int32_t b) |
Do a signed HW divide and wait for result. | |
static divmod_result_t | hw_divider_divmod_u32 (uint32_t a, uint32_t b) |
Do an unsigned HW divide and wait for result. | |
static void | hw_divider_divmod_s32_start (int32_t a, int32_t b) |
Start a signed asynchronous divide. | |
static void | hw_divider_divmod_u32_start (uint32_t a, uint32_t b) |
Start an unsigned asynchronous divide. | |
static void | hw_divider_wait_ready (void) |
Wait for a divide to complete. | |
static divmod_result_t | hw_divider_result_nowait (void) |
Return result of HW divide, nowait. | |
static divmod_result_t | hw_divider_result_wait (void) |
Return result of last asynchronous HW divide. | |
static uint32_t | to_quotient_u32 (divmod_result_t r) |
Efficient extraction of unsigned quotient from 32p32 fixed point. | |
static int32_t | to_quotient_s32 (divmod_result_t r) |
Efficient extraction of signed quotient from 32p32 fixed point. | |
static uint32_t | to_remainder_u32 (divmod_result_t r) |
Efficient extraction of unsigned remainder from 32p32 fixed point. | |
static int32_t | to_remainder_s32 (divmod_result_t r) |
Efficient extraction of signed remainder from 32p32 fixed point. | |
static uint32_t | hw_divider_u32_quotient_wait (void) |
Return result of last asynchronous HW divide, unsigned quotient only. | |
static int32_t | hw_divider_s32_quotient_wait (void) |
Return result of last asynchronous HW divide, signed quotient only. | |
static uint32_t | hw_divider_u32_remainder_wait (void) |
Return result of last asynchronous HW divide, unsigned remainder only. | |
static int32_t | hw_divider_s32_remainder_wait (void) |
Return result of last asynchronous HW divide, signed remainder only. | |
static uint32_t | hw_divider_u32_quotient (uint32_t a, uint32_t b) |
Do an unsigned HW divide, wait for result, return quotient. | |
static uint32_t | hw_divider_u32_remainder (uint32_t a, uint32_t b) |
Do an unsigned HW divide, wait for result, return remainder. | |
static int32_t | hw_divider_quotient_s32 (int32_t a, int32_t b) |
Do a signed HW divide, wait for result, return quotient. | |
static int32_t | hw_divider_remainder_s32 (int32_t a, int32_t b) |
Do a signed HW divide, wait for result, return remainder. | |
static void | hw_divider_pause (void) |
Pause for exact amount of time needed for a asynchronous divide to complete. | |
static uint32_t | hw_divider_u32_quotient_inlined (uint32_t a, uint32_t b) |
Do a hardware unsigned HW divide, wait for result, return quotient. | |
static uint32_t | hw_divider_u32_remainder_inlined (uint32_t a, uint32_t b) |
Do a hardware unsigned HW divide, wait for result, return remainder. | |
static int32_t | hw_divider_s32_quotient_inlined (int32_t a, int32_t b) |
Do a hardware signed HW divide, wait for result, return quotient. | |
static int32_t | hw_divider_s32_remainder_inlined (int32_t a, int32_t b) |
Do a hardware signed HW divide, wait for result, return remainder. | |
static void | hw_divider_save_state (hw_divider_state_t *dest) |
Save the calling cores hardware divider state. | |
static void | hw_divider_restore_state (hw_divider_state_t *src) |
Load a saved hardware divider state into the current core's hardware divider. | |
RP2040 Low Low-level hardware-divider API. Non-RP2040 platforms provide software versions of all the functions.
The SIO contains an 8-cycle signed/unsigned divide/modulo circuit, per core. Calculation is started by writing a dividend and divisor to the two argument registers, DIVIDEND and DIVISOR. The divider calculates the quotient / and remainder % of this division over the next 8 cycles, and on the 9th cycle the results can be read from the two result registers DIV_QUOTIENT and DIV_REMAINDER. A 'ready' bit in register DIV_CSR can be polled to wait for the calculation to complete, or software can insert a fixed 8-cycle delay
This header provides low level macros and inline functions for accessing the hardware dividers directly, and perhaps most usefully performing asynchronous divides. These functions however do not follow the regular SDK conventions for saving/restoring the divider state, so are not generally safe to call from interrupt handlers
The pico_divider library provides a more user friendly set of APIs over the divider (and support for 64 bit divides), and of course by default regular C language integer divisions are redirected through that library, meaning you can just use C level /
and %
operators and gain the benefits of the fast hardware divider.
|
inlinestatic |
Do a signed HW divide and wait for result.
Divide a
by b
, wait for calculation to complete, return result as a pair of 32-bit quotient/remainder values.
a | The dividend |
b | The divisor |
|
inlinestatic |
Start a signed asynchronous divide.
Start a divide of the specified signed parameters. You should wait for 8 cycles (__div_pause()) or wait for the ready bit to be set (hw_divider_wait_ready()) prior to reading the results.
a | The dividend |
b | The divisor |
|
inlinestatic |
Do an unsigned HW divide and wait for result.
Divide a
by b
, wait for calculation to complete, return result as a pair of 32-bit quotient/remainder values.
a | The dividend |
b | The divisor |
|
inlinestatic |
Start an unsigned asynchronous divide.
Start a divide of the specified unsigned parameters. You should wait for 8 cycles (__div_pause()) or wait for the ready bit to be set (hw_divider_wait_ready()) prior to reading the results.
a | The dividend |
b | The divisor |
|
inlinestatic |
Do a signed HW divide, wait for result, return quotient.
Divide a
by b
, wait for calculation to complete, return quotient.
a | The dividend |
b | The divisor |
|
inlinestatic |
Do a signed HW divide, wait for result, return remainder.
Divide a
by b
, wait for calculation to complete, return remainder.
a | The dividend |
b | The divisor |
|
inlinestatic |
Load a saved hardware divider state into the current core's hardware divider.
Copy the passed hardware divider state into the hardware divider.
src | the location to load the divider state from |
|
inlinestatic |
Return result of HW divide, nowait.
|
inlinestatic |
Return result of last asynchronous HW divide.
This function waits for the result to be ready by calling hw_divider_wait_ready().
|
inlinestatic |
Do a hardware signed HW divide, wait for result, return quotient.
Divide a
by b
, wait for calculation to complete, return quotient.
a | The dividend |
b | The divisor |
|
inlinestatic |
Return result of last asynchronous HW divide, signed quotient only.
This function waits for the result to be ready by calling hw_divider_wait_ready().
|
inlinestatic |
Do a hardware signed HW divide, wait for result, return remainder.
Divide a
by b
, wait for calculation to complete, return remainder.
a | The dividend |
b | The divisor |
|
inlinestatic |
Return result of last asynchronous HW divide, signed remainder only.
This function waits for the result to be ready by calling hw_divider_wait_ready().
|
inlinestatic |
Save the calling cores hardware divider state.
Copy the current core's hardware divider state into the provided structure. This method waits for the divider results to be stable, then copies them to memory. They can be restored via hw_divider_restore_state()
dest | the location to store the divider state |
|
inlinestatic |
Do an unsigned HW divide, wait for result, return quotient.
Divide a
by b
, wait for calculation to complete, return quotient.
a | The dividend |
b | The divisor |
|
inlinestatic |
Do a hardware unsigned HW divide, wait for result, return quotient.
Divide a
by b
, wait for calculation to complete, return quotient.
a | The dividend |
b | The divisor |
|
inlinestatic |
Return result of last asynchronous HW divide, unsigned quotient only.
This function waits for the result to be ready by calling hw_divider_wait_ready().
|
inlinestatic |
Do an unsigned HW divide, wait for result, return remainder.
Divide a
by b
, wait for calculation to complete, return remainder.
a | The dividend |
b | The divisor |
|
inlinestatic |
Do a hardware unsigned HW divide, wait for result, return remainder.
Divide a
by b
, wait for calculation to complete, return remainder.
a | The dividend |
b | The divisor |
|
inlinestatic |
Return result of last asynchronous HW divide, unsigned remainder only.
This function waits for the result to be ready by calling hw_divider_wait_ready().
|
inlinestatic |
Wait for a divide to complete.
Wait for a divide to complete
|
inlinestatic |
Efficient extraction of signed quotient from 32p32 fixed point.
r | A pair of 32-bit quotient/remainder values. |
|
inlinestatic |
Efficient extraction of unsigned quotient from 32p32 fixed point.
r | A pair of 32-bit quotient/remainder values. |
|
inlinestatic |
Efficient extraction of signed remainder from 32p32 fixed point.
r | A pair of 32-bit quotient/remainder values. |
|
inlinestatic |
Efficient extraction of unsigned remainder from 32p32 fixed point.
r | A pair of 32-bit quotient/remainder values. |