v1.5.0
Go to the documentation of this file.
7 #ifndef _HARDWARE_INTERP_H
8 #define _HARDWARE_INTERP_H
11 #include "hardware/structs/interp.h"
12 #include "hardware/regs/sio.h"
15 #ifndef PARAM_ASSERTIONS_ENABLED_INTERP
16 #define PARAM_ASSERTIONS_ENABLED_INTERP 0
41 #define interp0 interp0_hw
42 #define interp1 interp1_hw
57 static inline uint interp_index(
interp_hw_t *interp) {
58 valid_params_if(INTERP, interp == interp0 || interp == interp1);
59 return interp == interp1 ? 1 : 0;
74 #define interp_lane_claim interp_claim_lane
92 #define interp_lane_unclaim interp_unclaim_lane
122 valid_params_if(INTERP, shift < 32);
123 c->ctrl = (c->ctrl & ~SIO_INTERP0_CTRL_LANE0_SHIFT_BITS) |
124 ((shift << SIO_INTERP0_CTRL_LANE0_SHIFT_LSB) & SIO_INTERP0_CTRL_LANE0_SHIFT_BITS);
137 valid_params_if(INTERP, mask_msb < 32);
138 valid_params_if(INTERP, mask_lsb <= mask_msb);
139 c->ctrl = (c->ctrl & ~(SIO_INTERP0_CTRL_LANE0_MASK_LSB_BITS | SIO_INTERP0_CTRL_LANE0_MASK_MSB_BITS)) |
140 ((mask_lsb << SIO_INTERP0_CTRL_LANE0_MASK_LSB_LSB) & SIO_INTERP0_CTRL_LANE0_MASK_LSB_BITS) |
141 ((mask_msb << SIO_INTERP0_CTRL_LANE0_MASK_MSB_LSB) & SIO_INTERP0_CTRL_LANE0_MASK_MSB_BITS);
155 c->ctrl = (c->ctrl & ~SIO_INTERP0_CTRL_LANE0_CROSS_INPUT_BITS) |
156 (cross_input ? SIO_INTERP0_CTRL_LANE0_CROSS_INPUT_BITS : 0);
168 c->ctrl = (c->ctrl & ~SIO_INTERP0_CTRL_LANE0_CROSS_RESULT_BITS) |
169 (cross_result ? SIO_INTERP0_CTRL_LANE0_CROSS_RESULT_BITS : 0);
182 c->ctrl = (c->ctrl & ~SIO_INTERP0_CTRL_LANE0_SIGNED_BITS) |
183 (_signed ? SIO_INTERP0_CTRL_LANE0_SIGNED_BITS : 0);
195 c->ctrl = (c->ctrl & ~SIO_INTERP0_CTRL_LANE0_ADD_RAW_BITS) |
196 (add_raw ? SIO_INTERP0_CTRL_LANE0_ADD_RAW_BITS : 0);
215 c->ctrl = (c->ctrl & ~SIO_INTERP0_CTRL_LANE0_BLEND_BITS) |
216 (blend ? SIO_INTERP0_CTRL_LANE0_BLEND_BITS : 0);
230 c->ctrl = (c->ctrl & ~SIO_INTERP1_CTRL_LANE0_CLAMP_BITS) |
231 (clamp ? SIO_INTERP1_CTRL_LANE0_CLAMP_BITS : 0);
246 invalid_params_if(INTERP, bits > 3);
248 c->ctrl = (c->ctrl & ~SIO_INTERP0_CTRL_LANE0_FORCE_MSB_BITS) |
249 (bits << SIO_INTERP0_CTRL_LANE0_FORCE_MSB_LSB);
276 invalid_params_if(INTERP, lane > 1);
277 invalid_params_if(INTERP, config->ctrl & SIO_INTERP1_CTRL_LANE0_CLAMP_BITS &&
278 (!interp_index(interp) || lane));
279 invalid_params_if(INTERP, config->ctrl & SIO_INTERP0_CTRL_LANE0_BLEND_BITS &&
280 (interp_index(interp) || lane));
281 interp->ctrl[lane] = config->ctrl;
299 interp->ctrl[lane] = interp->ctrl[lane] | (bits << SIO_INTERP0_CTRL_LANE0_FORCE_MSB_LSB);
335 interp->base[lane] = val;
346 return interp->base[lane];
359 interp->base01 = val;
371 interp->accum[lane] = val;
382 return interp->accum[lane];
393 return interp->pop[lane];
404 return interp->peek[lane];
414 return interp->pop[2];
424 return interp->peek[2];
438 interp->add_raw[lane] = val;
451 return interp->add_raw[lane];
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.
Definition: interp.h:413
static interp_config interp_default_config(void)
Get a default configuration.
Definition: interp.h:257
void interp_unclaim_lane_mask(interp_hw_t *interp, uint lane_mask)
Release previously claimed interpolator lanes.
Definition: interp.c:44
static void interp_set_base_both(interp_hw_t *interp, uint32_t val)
Sets the interpolator base registers simultaneously.
Definition: interp.h:358
static void interp_config_set_blend(interp_config *c, bool blend)
Set blend mode.
Definition: interp.h:214
static void interp_config_set_shift(interp_config *c, uint shift)
Set the interpolator shift value.
Definition: interp.h:121
void interp_claim_lane(interp_hw_t *interp, uint lane)
Claim the interpolator lane specified.
Definition: interp.c:23
static uint32_t interp_get_raw(interp_hw_t *interp, uint lane)
Get raw lane value.
Definition: interp.h:450
bool interp_lane_is_claimed(interp_hw_t *interp, uint lane)
Determine if an interpolator lane is claimed.
Definition: interp.c:39
static void interp_add_accumulater(interp_hw_t *interp, uint lane, uint32_t val)
Add to accumulator.
Definition: interp.h:437
static void interp_set_config(interp_hw_t *interp, uint lane, interp_config *config)
Send configuration to a lane.
Definition: interp.h:275
static void interp_set_force_bits(interp_hw_t *interp, uint lane, uint bits)
Directly set the force bits on a specified lane.
Definition: interp.h:297
static uint32_t interp_peek_lane_result(interp_hw_t *interp, uint lane)
Read lane result.
Definition: interp.h:403
static void interp_set_accumulator(interp_hw_t *interp, uint lane, uint32_t val)
Sets the interpolator accumulator register by lane.
Definition: interp.h:370
static void interp_config_set_add_raw(interp_config *c, bool add_raw)
Set raw add option.
Definition: interp.h:194
void interp_restore(interp_hw_t *interp, interp_hw_save_t *saver)
Restore an interpolator state.
Definition: interp.c:60
void interp_save(interp_hw_t *interp, interp_hw_save_t *saver)
Save the specified interpolator state.
Definition: interp.c:50
static uint32_t interp_peek_full_result(interp_hw_t *interp)
Read lane result.
Definition: interp.h:423
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.
Definition: interp.h:392
static void interp_config_set_cross_result(interp_config *c, bool cross_result)
Enable cross results.
Definition: interp.h:167
static void interp_config_set_mask(interp_config *c, uint mask_lsb, uint mask_msb)
Set the interpolator mask range.
Definition: interp.h:136
static void interp_set_base(interp_hw_t *interp, uint lane, uint32_t val)
Sets the interpolator base register by lane.
Definition: interp.h:334
static uint32_t interp_get_base(interp_hw_t *interp, uint lane)
Gets the content of interpolator base register by lane.
Definition: interp.h:345
void interp_unclaim_lane(interp_hw_t *interp, uint lane)
Release a previously claimed interpolator lane.
Definition: interp.c:34
void interp_claim_lane_mask(interp_hw_t *interp, uint lane_mask)
Claim the interpolator lanes specified in the mask.
Definition: interp.c:28
static void interp_config_set_force_bits(interp_config *c, uint bits)
Set interpolator Force bits.
Definition: interp.h:245
static void interp_config_set_clamp(interp_config *c, bool clamp)
Set interpolator clamp mode (Interpolator 1 only)
Definition: interp.h:229
static uint32_t interp_get_accumulator(interp_hw_t *interp, uint lane)
Gets the content of the interpolator accumulator register by lane.
Definition: interp.h:381
static void interp_config_set_cross_input(interp_config *c, bool cross_input)
Enable cross input.
Definition: interp.h:154
static void interp_config_set_signed(interp_config *c, bool _signed)
Set sign extension.
Definition: interp.h:181