Better filter, 16b samples
This commit is contained in:
parent
1e4846dac3
commit
da73da4e38
1 changed files with 48 additions and 26 deletions
74
src/main.c
74
src/main.c
|
|
@ -141,8 +141,6 @@ static void init_bias()
|
||||||
gpio_set_drive_strength(FB_PIN, GPIO_DRIVE_STRENGTH_2MA);
|
gpio_set_drive_strength(FB_PIN, GPIO_DRIVE_STRENGTH_2MA);
|
||||||
gpio_set_slew_rate(FB_PIN, GPIO_SLEW_RATE_SLOW);
|
gpio_set_slew_rate(FB_PIN, GPIO_SLEW_RATE_SLOW);
|
||||||
|
|
||||||
PIO->input_sync_bypass = 1u << RX_PIN;
|
|
||||||
|
|
||||||
const uint16_t insn[] = {
|
const uint16_t insn[] = {
|
||||||
pio_encode_mov(pio_isr, pio_null),
|
pio_encode_mov(pio_isr, pio_null),
|
||||||
pio_encode_in(pio_y, 4),
|
pio_encode_in(pio_y, 4),
|
||||||
|
|
@ -209,8 +207,8 @@ static void init_adder()
|
||||||
* Should wrap here.
|
* Should wrap here.
|
||||||
* Jump to this portion must be inserted from the outside.
|
* Jump to this portion must be inserted from the outside.
|
||||||
*/
|
*/
|
||||||
pio_encode_in(pio_y, 32),
|
pio_encode_in(pio_x, 16),
|
||||||
pio_encode_in(pio_x, 32),
|
pio_encode_in(pio_y, 16),
|
||||||
pio_encode_out(pio_pc, 4),
|
pio_encode_out(pio_pc, 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -438,42 +436,66 @@ inline static uint32_t pio_sm_get_blocking_unsafe(pio_hw_t *pio, int sm)
|
||||||
|
|
||||||
inline static int nextI()
|
inline static int nextI()
|
||||||
{
|
{
|
||||||
static int prevI2, prevI1, prevI;
|
static uint16_t py, px;
|
||||||
|
|
||||||
int sI2 = pio_sm_get_blocking_unsafe(PIO, SM_COS);
|
uint32_t yx = pio_sm_get_blocking_unsafe(PIO, SM_COS);
|
||||||
|
uint16_t y = yx >> 16;
|
||||||
|
uint16_t x = yx;
|
||||||
|
|
||||||
int I2 = sI2 - prevI2;
|
uint16_t ny = py - y;
|
||||||
prevI2 = sI2;
|
uint16_t nx = px - x;
|
||||||
|
|
||||||
int sI1 = pio_sm_get_blocking_unsafe(PIO, SM_COS);
|
py = y;
|
||||||
int I1 = sI1 - prevI1;
|
px = x;
|
||||||
prevI1 = sI1;
|
|
||||||
|
|
||||||
int sI = I2 + I2 + I1;
|
int s = ((int)ny << 1) + (int)nx;
|
||||||
int I = sI - prevI;
|
int s0 = s;
|
||||||
prevI = sI;
|
|
||||||
|
|
||||||
return I;
|
static int a1, a2;
|
||||||
|
s = s0 - a2;
|
||||||
|
a2 = a1;
|
||||||
|
a1 = s0;
|
||||||
|
s0 = s;
|
||||||
|
|
||||||
|
static int b1, b2;
|
||||||
|
s = s0 - b2;
|
||||||
|
b2 = b1;
|
||||||
|
b1 = s0;
|
||||||
|
s0 = s;
|
||||||
|
|
||||||
|
return s >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static int nextQ()
|
inline static int nextQ()
|
||||||
{
|
{
|
||||||
static int prevQ2, prevQ1, prevQ;
|
static uint16_t py, px;
|
||||||
|
|
||||||
int sQ2 = pio_sm_get_blocking_unsafe(PIO, SM_SIN);
|
uint32_t yx = pio_sm_get_blocking_unsafe(PIO, SM_SIN);
|
||||||
|
uint16_t y = yx >> 16;
|
||||||
|
uint16_t x = yx;
|
||||||
|
|
||||||
int Q2 = sQ2 - prevQ2;
|
uint16_t ny = py - y;
|
||||||
prevQ2 = sQ2;
|
uint16_t nx = px - x;
|
||||||
|
|
||||||
int sQ1 = pio_sm_get_blocking_unsafe(PIO, SM_SIN);
|
py = y;
|
||||||
int Q1 = sQ1 - prevQ1;
|
px = x;
|
||||||
prevQ1 = sQ1;
|
|
||||||
|
|
||||||
int sQ = Q2 + Q2 + Q1;
|
int s = ((int)ny << 1) + (int)nx;
|
||||||
int Q = sQ - prevQ;
|
int s0 = s;
|
||||||
prevQ = sQ;
|
|
||||||
|
|
||||||
return Q;
|
static int a1, a2;
|
||||||
|
s = s0 - a2;
|
||||||
|
a2 = a1;
|
||||||
|
a1 = s0;
|
||||||
|
s0 = s;
|
||||||
|
|
||||||
|
static int b1, b2;
|
||||||
|
s = s0 - b2;
|
||||||
|
b2 = b1;
|
||||||
|
b1 = s0;
|
||||||
|
s0 = s;
|
||||||
|
|
||||||
|
return s >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rf_rx(void)
|
static void rf_rx(void)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue