Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
François Revol
firmware
Commits
3aca1482
Commit
3aca1482
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
feat(bme680): Act as shim if BSEC is active
parent
ad325247
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
epicardium/modules/bme680.c
+15
-0
15 additions, 0 deletions
epicardium/modules/bme680.c
epicardium/modules/bsec.c
+27
-8
27 additions, 8 deletions
epicardium/modules/bsec.c
epicardium/modules/modules.h
+4
-0
4 additions, 0 deletions
epicardium/modules/modules.h
with
46 additions
and
8 deletions
epicardium/modules/bme680.c
+
15
−
0
View file @
3aca1482
...
...
@@ -67,6 +67,13 @@ int epic_bme680_init()
{
int8_t
result
=
BME680_OK
;
if
(
bsec_active
())
{
/* If the proprietary Bosch BSEC libary is in use
* we redirect calls to that. It always runs
* in the background
*/
return
0
;
}
if
(
initialized
)
{
return
0
;
}
...
...
@@ -133,6 +140,10 @@ int epic_bme680_deinit()
* penalty.
*/
if
(
bsec_active
())
{
return
0
;
}
#if 0
if (!initialized) {
return 0;
...
...
@@ -152,6 +163,10 @@ int epic_bme680_read_sensors(struct bme680_sensor_data *data)
{
int8_t
result
=
BME680_OK
;
if
(
bsec_active
())
{
return
bsec_read_bme680
(
data
);
}
if
(
!
initialized
)
{
LOG_ERR
(
"bme680"
,
"bme680 sensor not initialized"
);
return
-
EINVAL
;
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/bsec.c
+
27
−
8
View file @
3aca1482
...
...
@@ -17,6 +17,9 @@
#include
<stdio.h>
TaskHandle_t
bsec_task_id
;
static
struct
bme680_sensor_data
last_bme680_data
;
static
int64_t
last_bme680_timestamp
;
static
bool
active
;
// From generic_18v_3s_4d/bsec_serialized_configurations_iaq.c
static
const
uint8_t
bsec_config_generic_18v_3s_4d
[
454
]
=
{
...
...
@@ -108,9 +111,14 @@ void output_ready(
float
co2_equivalent
,
float
breath_voc_equivalent
)
{
last_bme680_data
.
temperature
=
temperature
;
last_bme680_data
.
humidity
=
humidity
;
last_bme680_data
.
pressure
=
pressure
/
100
.;
last_bme680_data
.
gas_resistance
=
gas
;
last_bme680_timestamp
=
timestamp
;
return
;
printf
(
"bosch data time: %u, iaq: %u, iaq_a: %u, temp10: %u, hum10: %u, pres: %u, raw_temp10: %u, raw_hum10: %u, gas: %u, static_iaq: %u, co21e6: %u, breath_voc1e6: %u
\n
"
,
(
unsigned
int
)(
timestamp
/
9
e6
),
(
unsigned
int
)(
timestamp
/
1
e6
),
(
unsigned
int
)(
iaq
),
(
unsigned
int
)(
iaq_accuracy
),
(
unsigned
int
)(
temperature
*
10
),
...
...
@@ -289,15 +297,26 @@ static void delay(uint32_t msec)
vTaskDelay
(
pdMS_TO_TICKS
(
msec
));
}
/*!
* @brief Main function which configures BSEC library and then reads and processes the data from sensor based
* on timer ticks
*
* @return result of the processing
*/
bool
bsec_active
(
void
)
{
return
active
;
}
int
bsec_read_bme680
(
struct
bme680_sensor_data
*
data
)
{
if
(
!
active
)
{
return
BME680_E_COM_FAIL
;
}
while
(
last_bme680_timestamp
==
0
)
vTaskDelay
(
pdMS_TO_TICKS
(
10
));
*
data
=
last_bme680_data
;
return
BME680_OK
;
}
void
vBSECTask
(
void
*
pvParameters
)
{
return_values_init
ret
;
active
=
true
;
bsec_task_id
=
xTaskGetCurrentTaskHandle
();
/* Call to the function which initializes the BSEC library */
...
...
@@ -317,7 +336,7 @@ void vBSECTask(void *pvParameters)
#endif
if
(
ret
.
bme680_status
)
{
printf
(
"bme680 init failed
\n
"
);
/* Could not intialize BME680
or BSEC library
*/
/* Could not intialize BME680 */
while
(
1
)
;
}
else
if
(
ret
.
bsec_status
)
{
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/modules.h
+
4
−
0
View file @
3aca1482
...
...
@@ -136,7 +136,11 @@ void max30001_mutex_init(void);
/* ---------- GPIO --------------------------------------------------------- */
extern
gpio_cfg_t
gpio_configs
[];
/* ---------- BSEC / BME680 ------------------------------------------------ */
void
vBSECTask
(
void
*
pvParameters
);
bool
bsec_active
(
void
);
struct
bme680_sensor_data
;
int
bsec_read_bme680
(
struct
bme680_sensor_data
*
data
);
/* ---------- Sleep -------------------------------------------------------- */
void
sleep_deepsleep
(
void
);
...
...
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