v2.0.0
Modules | Functions
hardware_interp
Hardware APIs

Hardware Interpolator API. More...

## Modules
| interp_config
| Interpolator configuration.

## Functions
void | interp_claim_lane (interp_hw_t *interp, uint lane)
| Claim the interpolator lane specified. More...
void | interp_claim_lane_mask (interp_hw_t *interp, uint lane_mask)
| Claim the interpolator lanes specified in the mask. More...
void | interp_unclaim_lane (interp_hw_t *interp, uint lane)
| Release a previously claimed interpolator lane. More...
bool | interp_lane_is_claimed (interp_hw_t *interp, uint lane)
| Determine if an interpolator lane is claimed. More...
void | interp_unclaim_lane_mask (interp_hw_t *interp, uint lane_mask)
| Release previously claimed interpolator lanes. More...
static void | interp_set_force_bits (interp_hw_t *interp, uint lane, uint bits)
| Directly set the force bits on a specified lane. More...
void | interp_save (interp_hw_t *interp, interp_hw_save_t *saver)
| Save the specified interpolator state. More...
void | interp_restore (interp_hw_t *interp, interp_hw_save_t *saver)
| Restore an interpolator state. More...
static void | interp_set_base (interp_hw_t *interp, uint lane, uint32_t val)
| Sets the interpolator base register by lane. More...
static uint32_t | interp_get_base (interp_hw_t *interp, uint lane)
| Gets the content of interpolator base register by lane. More...
static void | interp_set_base_both (interp_hw_t *interp, uint32_t val)
| Sets the interpolator base registers simultaneously. More...
static void | interp_set_accumulator (interp_hw_t *interp, uint lane, uint32_t val)
| Sets the interpolator accumulator register by lane. More...
static uint32_t | interp_get_accumulator (interp_hw_t *interp, uint lane)
| Gets the content of the interpolator accumulator register by lane. More...
static uint32_t | interp_pop_lane_result (interp_hw_t *interp, uint lane)
| Read lane result, and write lane results to both accumulators to update the interpolator. More...
static uint32_t | interp_peek_lane_result (interp_hw_t *interp, uint lane)
| Read lane result. More...
static uint32_t | interp_pop_full_result (interp_hw_t *interp)
| Read lane result, and write lane results to both accumulators to update the interpolator. More...
static uint32_t | interp_peek_full_result (interp_hw_t *interp)
| Read lane result. More...
static void | interp_add_accumulater (interp_hw_t *interp, uint lane, uint32_t val)
| Add to accumulator. More...
static uint32_t | interp_get_raw (interp_hw_t *interp, uint lane)
| Get raw lane value. More...

## Detailed Description

Hardware Interpolator API.

Each core is equipped with two interpolators (INTERP0 and INTERP1) which can be used to accelerate tasks by combining certain pre-configured simple operations into a single processor cycle. Intended for cases where the pre-configured operation is repeated a large number of times, this results in code which uses both fewer CPU cycles and fewer CPU registers in the time critical sections of the code.

The interpolators are used heavily to accelerate audio operations within the SDK, but their flexible configuration make it possible to optimise many other tasks such as quantization and dithering, table lookup address generation, affine texture mapping, decompression and linear feedback.

Please refer to the appropriate RP-series microcontroller datasheet for more information on the HW interpolators and how they work.

## Function Documentation

## ◆ interp_add_accumulater()

static void interp_add_accumulater | ( | interp_hw_t * | interp,
|  | uint | lane,
|  | uint32_t | val
| ) |  |
| inlinestatic

Add to accumulator.

Atomically add the specified value to the accumulator on the specified lane

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1
  val | Value to add

## ◆ interp_claim_lane()

void interp_claim_lane | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |

Claim the interpolator lane specified.

Use this function to claim exclusive access to the specified interpolator lane.

This function will panic if the lane is already claimed.

Parameters

  interp | Interpolator on which to claim a lane. interp0 or interp1
  lane | The lane number, 0 or 1.

## ◆ interp_claim_lane_mask()

void interp_claim_lane_mask | ( | interp_hw_t * | interp,
|  | uint | lane_mask
| ) |  |

Claim the interpolator lanes specified in the mask.

Parameters

  interp | Interpolator on which to claim lanes. interp0 or interp1
  lane_mask | Bit pattern of lanes to claim (only bits 0 and 1 are valid)

## ◆ interp_get_accumulator()

static uint32_t interp_get_accumulator | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |
| inlinestatic

Gets the content of the interpolator accumulator register by lane.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1

Returns
  The current content of the register

## ◆ interp_get_base()

static uint32_t interp_get_base | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |
| inlinestatic

Gets the content of interpolator base register by lane.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1 or 2

Returns
  The current content of the lane base register

## ◆ interp_get_raw()

static uint32_t interp_get_raw | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |
| inlinestatic

Get raw lane value.

Returns the raw shift and mask value from the specified lane, BASE0 is NOT added

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1

Returns
  The raw shift/mask value

## ◆ interp_lane_is_claimed()

bool interp_lane_is_claimed | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |

Determine if an interpolator lane is claimed.

Parameters

  interp | Interpolator whose lane to check
  lane | The lane number, 0 or 1

Returns
  true if claimed, false otherwise

See also
  interp_claim_lane
  interp_claim_lane_mask

## ◆ interp_peek_full_result()

static uint32_t interp_peek_full_result | ( | interp_hw_t * | interp | ) |
| inlinestatic

Read lane result.

Parameters

  interp | Interpolator instance, interp0 or interp1.

Returns
  The content of the FULL register

## ◆ interp_peek_lane_result()

static uint32_t interp_peek_lane_result | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |
| inlinestatic

Read lane result.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1

Returns
  The content of the lane result register

## ◆ interp_pop_full_result()

static uint32_t interp_pop_full_result | ( | interp_hw_t * | interp | ) |
| inlinestatic

Read lane result, and write lane results to both accumulators to update the interpolator.

Parameters

  interp | Interpolator instance, interp0 or interp1.

Returns
  The content of the FULL register

## ◆ interp_pop_lane_result()

static uint32_t interp_pop_lane_result | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |
| inlinestatic

Read lane result, and write lane results to both accumulators to update the interpolator.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1

Returns
  The content of the lane result register

## ◆ interp_restore()

void interp_restore | ( | interp_hw_t * | interp,
|  | interp_hw_save_t * | saver
| ) |  |

Restore an interpolator state.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  saver | Pointer to save structure to reapply to the specified interpolator

## ◆ interp_save()

void interp_save | ( | interp_hw_t * | interp,
|  | interp_hw_save_t * | saver
| ) |  |

Save the specified interpolator state.

Can be used to save state if you need an interpolator for another purpose, state can then be recovered afterwards and continue from that point

Parameters

  interp | Interpolator instance, interp0 or interp1.
  saver | Pointer to the save structure to fill in

## ◆ interp_set_accumulator()

static void interp_set_accumulator | ( | interp_hw_t * | interp,
|  | uint | lane,
|  | uint32_t | val
| ) |  |
| inlinestatic

Sets the interpolator accumulator register by lane.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1
  val | The value to apply to the register

## ◆ interp_set_base()

static void interp_set_base | ( | interp_hw_t * | interp,
|  | uint | lane,
|  | uint32_t | val
| ) |  |
| inlinestatic

Sets the interpolator base register by lane.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane number, 0 or 1 or 2
  val | The value to apply to the register

## ◆ interp_set_base_both()

static void interp_set_base_both | ( | interp_hw_t * | interp,
|  | uint32_t | val
| ) |  |
| inlinestatic

Sets the interpolator base registers simultaneously.

The lower 16 bits go to BASE0, upper bits to BASE1 simultaneously. Each half is sign-extended to 32 bits if that lane’s SIGNED flag is set.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  val | The value to apply to the register

## ◆ interp_set_force_bits()

static void interp_set_force_bits | ( | interp_hw_t * | interp,
|  | uint | lane,
|  | uint | bits
| ) |  |
| inlinestatic

Directly set the force bits on a specified lane.

These bits are ORed into bits 29:28 of the lane result presented to the processor on the bus. There is no effect on the internal 32-bit datapath.

Useful for using a lane to generate sequence of pointers into flash or SRAM, saving a subsequent OR or add operation.

Parameters

  interp | Interpolator instance, interp0 or interp1.
  lane | The lane to set
  bits | The bits to set (bits 0 and 1, value range 0-3)

## ◆ interp_unclaim_lane()

void interp_unclaim_lane | ( | interp_hw_t * | interp,
|  | uint | lane
| ) |  |

Release a previously claimed interpolator lane.

Parameters

  interp | Interpolator on which to release a lane. interp0 or interp1
  lane | The lane number, 0 or 1

## ◆ interp_unclaim_lane_mask()

void interp_unclaim_lane_mask | ( | interp_hw_t * | interp,
|  | uint | lane_mask
| ) |  |

Release previously claimed interpolator lanes.

See also
  interp_claim_lane_mask

Parameters

  interp | Interpolator on which to release lanes. interp0 or interp1
  lane_mask | Bit pattern of lanes to unclaim (only bits 0 and 1 are valid)