Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
fe7251ba
Commit
fe7251ba
authored
Oct 25, 2013
by
Tomasz Wlostowski
Committed by
Alessandro Rubini
Jan 12, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
softpll: biquad filter implementation
parent
1c5873ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
spll_common.c
rt/softpll/spll_common.c
+28
-0
spll_common.h
rt/softpll/spll_common.h
+9
-0
No files found.
rt/softpll/spll_common.c
View file @
fe7251ba
...
...
@@ -139,3 +139,31 @@ void spll_enable_tagger(int channel, int enable)
// TRACE("%s: ch %d, OCER 0x%x, RCER 0x%x\n", __FUNCTION__, channel, SPLL->OCER, SPLL->RCER);
}
void
biquad_init
(
spll_biquad_t
*
bq
,
const
int
*
coefs
,
int
shift
)
{
memset
(
bq
,
0
,
sizeof
(
spll_biquad_t
));
memcpy
(
bq
->
coefs
,
coefs
,
5
*
sizeof
(
int
));
bq
->
shift
=
shift
;
}
int
biquad_update
(
spll_biquad_t
*
bq
,
int
x
)
{
register
int
y
=
0
;
y
+=
bq
->
coefs
[
0
]
*
x
;
y
+=
bq
->
coefs
[
1
]
*
bq
->
xd
[
0
];
y
+=
bq
->
coefs
[
2
]
*
bq
->
xd
[
1
];
y
-=
bq
->
coefs
[
3
]
*
bq
->
yd
[
0
];
y
-=
bq
->
coefs
[
4
]
*
bq
->
yd
[
1
];
y
>>=
bq
->
shift
;
bq
->
xd
[
1
]
=
bq
->
xd
[
0
];
bq
->
xd
[
0
]
=
x
;
bq
->
yd
[
1
]
=
bq
->
yd
[
0
];
bq
->
yd
[
0
]
=
y
;
return
y
;
}
rt/softpll/spll_common.h
View file @
fe7251ba
...
...
@@ -58,6 +58,12 @@ typedef struct {
int
y_d
;
}
spll_lowpass_t
;
typedef
struct
{
int
coefs
[
5
];
/* Biquad coefficients: b0 b1 b2 a1 a2 */
int
shift
;
/* bit shift for the coeffs / output */
int
yd
[
2
],
xd
[
2
];
/* I/O delay lines */
}
spll_biquad_t
;
/* initializes the PI controller state. Currently almost a stub. */
void
pi_init
(
spll_pi_t
*
pi
);
...
...
@@ -72,4 +78,7 @@ int lowpass_update(spll_lowpass_t *lp, int x);
void
spll_enable_tagger
(
int
channel
,
int
enable
);
void
biquad_init
(
spll_biquad_t
*
bq
,
const
int
*
coefs
,
int
shift
);
int
biquad_update
(
spll_biquad_t
*
bq
,
int
x
);
#endif // __SPLL_COMMON_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment