Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
card10
firmware
Commits
7d75f9bc
Commit
7d75f9bc
authored
May 03, 2019
by
schneider
Browse files
feat(testapp): Use ECG together with oled
parent
c618fb9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
testapp/Makefile
View file @
7d75f9bc
...
...
@@ -66,6 +66,9 @@ CMSIS_ROOT=$(LIBS_DIR)/CMSIS
# Source files for this test (add path to VPATH below)
SRCS
=
main.c
SRCS
+=
../lib/card10/oled96.c
SRCS
+=
../lib/card10/fonts.c
# Where to find source files for this test
VPATH
=
.
...
...
testapp/main.c
View file @
7d75f9bc
...
...
@@ -43,6 +43,8 @@
/***** Includes *****/
#include
<stdio.h>
#include
<stdint.h>
#include
<string.h>
#include
<stdlib.h>
#include
"mxc_config.h"
#include
"led.h"
#include
"board.h"
...
...
@@ -51,6 +53,7 @@
#include
"rtc.h"
#include
"spi.h"
#include
"MAX30003.h"
#include
"oled96.h"
/***** Definitions *****/
...
...
@@ -174,6 +177,62 @@ void ecg_config(void)
return
;
}
uint8_t
content
[
1024
];
void
clear
(
void
)
{
memset
(
content
,
0x00
,
1024
);
}
void
set
(
uint8_t
index
,
int8_t
val
)
{
uint8_t
*
p
=
&
content
[
index
];
if
(
val
<
-
31
)
val
=
-
31
;
if
(
val
>
32
)
val
=
32
;
int8_t
pos
=
-
val
+
32
;
p
+=
(
pos
/
8
)
*
128
;
*
p
|=
(
1
<<
(
pos
%
8
));
}
int16_t
samples
[
256
];
void
update
(
void
)
{
clear
();
int16_t
scale
=
0
;
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
if
(
abs
(
samples
[
i
])
>
scale
)
{
scale
=
abs
(
samples
[
i
]);
}
}
scale
/=
32
;
for
(
int
i
=
0
;
i
<
128
;
i
++
)
{
set
(
i
,
((
samples
[
i
*
2
]
+
samples
[
i
*
2
+
1
])
/
scale
)
/
2
);
}
oledset
(
content
);
}
uint8_t
sample_count
=
0
;
void
add_sample
(
int16_t
sample
)
{
memmove
(
samples
,
samples
+
1
,
sizeof
(
*
samples
)
*
255
);
samples
[
255
]
=
sample
;
sample_count
++
;
if
(
sample_count
==
5
)
{
update
();
sample_count
=
0
;
}
}
// *****************************************************************************
int
main
(
void
)
{
...
...
@@ -198,6 +257,12 @@ int main(void)
}
}
oledInit
(
0x3c
,
0
,
0
);
oledFill
(
0x00
);
oledWriteString
(
0
,
0
,
" card10"
,
1
);
TMR_Delay
(
MXC_TMR0
,
MSEC
(
1500
),
0
);
// Enable 32 kHz output
//RTC_SquareWave(MXC_RTC, SQUARE_WAVE_ENABLED, F_32KHZ, NOISE_IMMUNE_MODE, NULL);
...
...
@@ -226,14 +291,6 @@ int main(void)
printf
(
"%02x: 0x%06x
\n
"
,
i
,
val
);
}
while
(
0
)
{
LED_On
(
0
);
TMR_Delay
(
MXC_TMR0
,
MSEC
(
500
),
0
);
LED_Off
(
0
);
TMR_Delay
(
MXC_TMR0
,
MSEC
(
500
),
0
);
//printf("count = %d\n", count++);
}
ecg_write_reg
(
SYNCH
,
0
);
uint32_t
ecgFIFO
,
readECGSamples
,
idx
,
ETAG
[
32
],
status
;
...
...
@@ -288,7 +345,8 @@ int main(void)
// Print results
for
(
idx
=
0
;
idx
<
readECGSamples
;
idx
++
)
{
printf
(
"%6d
\r\n
"
,
ecgSample
[
idx
]);
//printf("%6d\r\n", ecgSample[idx]);
add_sample
(
ecgSample
[
idx
]);
}
}
...
...
Write
Preview
Supports
Markdown
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