Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pico-oscilloscope
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Akira Lane
pico-oscilloscope
Commits
875a368c
Commit
875a368c
authored
3 years ago
by
Akira
Browse files
Options
Downloads
Patches
Plain Diff
removed unnecessary callback
parent
becb19d4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
oscilloscope.c
+5
-19
5 additions, 19 deletions
oscilloscope.c
oscilloscope.h
+0
-3
0 additions, 3 deletions
oscilloscope.h
oscilloscope_incomplete.c
+5
-15
5 additions, 15 deletions
oscilloscope_incomplete.c
with
10 additions
and
37 deletions
oscilloscope.c
+
5
−
19
View file @
875a368c
...
@@ -13,7 +13,6 @@ int16_t *raw_buffer_b;
...
@@ -13,7 +13,6 @@ int16_t *raw_buffer_b;
bool
active_buffer
;
// 0 for a, 1 for b
bool
active_buffer
;
// 0 for a, 1 for b
unsigned
int
dma_channel
;
unsigned
int
dma_channel
;
samples_ready_handler_t
samples_ready_handler
;
volatile
int
samples_read
;
volatile
int
samples_read
;
int16_t
sample_buffer
[
SAMPLE_BUFFER_SIZE
];
int16_t
sample_buffer
[
SAMPLE_BUFFER_SIZE
];
...
@@ -37,7 +36,6 @@ int main()
...
@@ -37,7 +36,6 @@ int main()
// microphone setup
// microphone setup
setup_adc
();
setup_adc
();
setup_dma
();
setup_dma
();
set_samples_ready_handler
(
on_samples_ready
);
start_listening
();
start_listening
();
unsigned
int
num_samples
=
0
;
unsigned
int
num_samples
=
0
;
...
@@ -58,7 +56,6 @@ int main()
...
@@ -58,7 +56,6 @@ int main()
sleep_ms
(
50
);
sleep_ms
(
50
);
ST7735_FillScreen
(
ST7735_BLACK
);
// clean
ST7735_FillScreen
(
ST7735_BLACK
);
// clean
}
}
}
}
...
@@ -136,31 +133,20 @@ void dma_handler()
...
@@ -136,31 +133,20 @@ void dma_handler()
// swap buffers
// swap buffers
active_buffer
=
!
active_buffer
;
active_buffer
=
!
active_buffer
;
samples_ready_handler
();
on_samples_ready
();
}
void
set_samples_ready_handler
(
samples_ready_handler_t
handler
)
{
samples_ready_handler
=
handler
;
}
}
int
read_samples
(
int16_t
*
buffer
,
size_t
samples
)
void
on_samples_ready
()
{
{
uint16_t
*
in
=
active_buffer
?
raw_buffer_a
:
raw_buffer_b
;
uint16_t
*
in
=
active_buffer
?
raw_buffer_a
:
raw_buffer_b
;
int16_t
*
out
=
buffer
;
int16_t
*
out
=
sample_
buffer
;
for
(
size_t
i
=
0
;
i
<
samples
;
i
++
)
for
(
size_t
i
=
0
;
i
<
SAMPLE_BUFFER_SIZE
;
i
++
)
{
{
*
out
++
=
*
in
++
-
bias
;
*
out
++
=
*
in
++
-
bias
;
}
}
return
samples
;
samples_read
=
SAMPLE_BUFFER_SIZE
;
}
void
on_samples_ready
()
{
samples_read
=
read_samples
(
sample_buffer
,
SAMPLE_BUFFER_SIZE
);
}
}
void
debug_write_to_screen
(
char
debug_string
[])
{
void
debug_write_to_screen
(
char
debug_string
[])
{
...
...
This diff is collapsed.
Click to expand it.
oscilloscope.h
+
0
−
3
View file @
875a368c
...
@@ -14,15 +14,12 @@
...
@@ -14,15 +14,12 @@
#include
"lib/st7735.h"
#include
"lib/st7735.h"
#include
"lib/ICM20948.h"
#include
"lib/ICM20948.h"
typedef
void
(
*
samples_ready_handler_t
)(
void
);
void
setup_adc
();
void
setup_adc
();
void
setup_dma
();
void
setup_dma
();
void
start_listening
();
void
start_listening
();
void
dma_handler
();
void
dma_handler
();
void
set_samples_ready_handler
(
samples_ready_handler_t
handler
);
int
read_samples
(
int16_t
*
buffer
,
size_t
samples
);
int
read_samples
(
int16_t
*
buffer
,
size_t
samples
);
void
on_samples_ready
();
void
on_samples_ready
();
...
...
This diff is collapsed.
Click to expand it.
oscilloscope_incomplete.c
+
5
−
15
View file @
875a368c
...
@@ -62,7 +62,7 @@ void start_listening()
...
@@ -62,7 +62,7 @@ void start_listening()
void
dma_handler
()
void
dma_handler
()
{
{
// TODO: get the samples from DMA into main()
// TODO: get the samples from DMA into main()
// hint: call samples_ready
_handler
at the end
// hint: call
on_
samples_ready at the end
}
}
void
setup_adc
()
void
setup_adc
()
...
@@ -112,27 +112,17 @@ void setup_dma()
...
@@ -112,27 +112,17 @@ void setup_dma()
}
}
void
set_samples_ready_handler
(
samples_ready_handler_t
handler
)
void
on_samples_ready
()
{
samples_ready_handler
=
handler
;
}
int
read_samples
(
int16_t
*
buffer
,
size_t
samples
)
{
{
uint16_t
*
in
=
active_buffer
?
raw_buffer_a
:
raw_buffer_b
;
uint16_t
*
in
=
active_buffer
?
raw_buffer_a
:
raw_buffer_b
;
int16_t
*
out
=
buffer
;
int16_t
*
out
=
sample_
buffer
;
for
(
size_t
i
=
0
;
i
<
samples
;
i
++
)
for
(
size_t
i
=
0
;
i
<
SAMPLE_BUFFER_SIZE
;
i
++
)
{
{
*
out
++
=
*
in
++
-
bias
;
*
out
++
=
*
in
++
-
bias
;
}
}
return
samples
;
samples_read
=
SAMPLE_BUFFER_SIZE
;
}
void
on_samples_ready
()
{
samples_read
=
read_samples
(
sample_buffer
,
SAMPLE_BUFFER_SIZE
);
}
}
void
debug_write_to_screen
(
char
debug_string
[])
{
void
debug_write_to_screen
(
char
debug_string
[])
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment