Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- interp_ fixes #428

Merged
merged 2 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/rp2_common/hardware_interp/include/hardware/interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ void interp_claim_lane_mask(interp_hw_t *interp, uint lane_mask);
*/
void interp_unclaim_lane(interp_hw_t *interp, uint lane);

/*! \brief Release previously claimed interpolator lanes \see interp_claim_lane_mask
* \ingroup hardware_interp
*
* \param interp Interpolator on which to release lanes. interp0 or interp1
* \param lane_mask Bit pattern of lanes to unclaim (only bits 0 and 1 are valid)
*/
void interp_unclaim_lane_mask(interp_hw_t *interp, uint lane_mask);

/*! \brief Set the interpolator shift value
* \ingroup interp_config
*
Expand Down Expand Up @@ -277,9 +285,9 @@ static inline void interp_set_force_bits(interp_hw_t *interp, uint lane, uint bi
}

typedef struct {
io_rw_32 accum[2];
io_rw_32 base[3];
io_rw_32 ctrl[2];
uint32_t accum[2];
uint32_t base[3];
uint32_t ctrl[2];
} interp_hw_save_t;

/*! \brief Save the specified interpolator state
Expand Down
16 changes: 13 additions & 3 deletions src/rp2_common/hardware_interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ static_assert(NUM_DMA_CHANNELS <= 16, "");

static uint8_t _claimed;

static inline uint interp_get_bit(interp_hw_t *interp, uint lane) {
return 1u << ((interp_index(interp) << 1u) | lane);
}

void interp_claim_lane(interp_hw_t *interp, uint lane) {
valid_params_if(INTERP, lane < 2);
uint bit = (interp_index(interp) << 1u) | lane;
uint bit = interp_get_bit(interp, lane);
hw_claim_or_assert((uint8_t *) &_claimed, bit, "Lane is already claimed");
}

Expand All @@ -30,8 +34,14 @@ void interp_claim_lane_mask(interp_hw_t *interp, uint lane_mask) {

void interp_unclaim_lane(interp_hw_t *interp, uint lane) {
valid_params_if(INTERP, lane < 2);
uint bit = (interp_index(interp) << 1u) | lane;
hw_claim_clear((uint8_t *) &_claimed, bit);
uint bit = interp_get_bit(interp, lane);
hw_claim_clear(&_claimed, bit);
}

void interp_unclaim_lane_mask(interp_hw_t *interp, uint lane_mask) {
valid_params_if(INTERP, lane_mask && lane_mask <= 0x3);
if (lane_mask & 1u) interp_unclaim_lane(interp, 0);
if (lane_mask & 2u) interp_unclaim_lane(interp, 1);
}

void interp_save(interp_hw_t *interp, interp_hw_save_t *saver) {
Expand Down