i2c_ref_app_breathing.c File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "acc_definitions_a121.h"
#include "acc_detector_presence.h"
#include "acc_hal_definitions_a121.h"
#include "acc_hal_integration_a121.h"
#include "acc_integration.h"
#include "acc_rss_a121.h"
#include "acc_version.h"
#include "acc_reg_protocol.h"
#include "i2c_application_system.h"
#include "i2c_ref_app_breathing.h"
#include "ref_app_breathing_reg_protocol.h"

Go to the source code of this file.

Data Structures

struct  ref_app_breathing_resources_t
 

Macros

#define SENSOR_ID   (1U)
 
#define SENSOR_TIMEOUT_MS   (10000U)
 
#define UART_LOG_BUFFER_SIZE   100
 

Functions

static uint32_t get_command (void)
 Get the i2c_app_command values. More...
 
static void command_handler (uint32_t command)
 Execute the command sent from the host. More...
 
static void app_status_set_bits (uint32_t bit_mask)
 Set bits in the i2c_app_status. More...
 
static void app_status_clr_bits (uint32_t bit_mask)
 Clear bits in the i2c_app_status. More...
 
static bool app_status_test_bits (uint32_t bit_mask)
 Test bits in the i2c_app_status. More...
 
static void create_sensor (ref_app_breathing_resources_t *resources)
 Create sensor. More...
 
static bool calibrate_sensor (ref_app_breathing_resources_t *resources)
 Calibrate sensor. More...
 
static void apply_app_config (ref_app_breathing_resources_t *resources)
 Apply application config. More...
 
static bool app_activate (ref_app_breathing_resources_t *resources, bool enable)
 Activate application. More...
 
static bool app_get_next (ref_app_breathing_resources_t *resources)
 Get next breathing measurement. More...
 
static void module_low_power (void)
 Try to set module in low power mode. More...
 
static bool enter_hibernate (acc_sensor_t *sensor)
 Enter sensor hibernation state. More...
 
static bool exit_hibernate (acc_sensor_t *sensor)
 Exit sensor hibernation state. More...
 
static void print_breathing_result (ref_app_breathing_result_t *result)
 Print the ref app breathing result. More...
 
static void uart_log (const char *format,...)
 UART logging function (can be enabled/disabled by command) More...
 
ref_app_breathing_config_ti2c_ref_app_breathing_get_config (void)
 Get ref app breathing configuration handle. More...
 
bool i2c_ref_app_breathing_command (uint32_t command)
 Send command to be executed to i2c ref app breathing. More...
 
uint32_t i2c_ref_app_breathing_get_status (void)
 Get ref app breathing status. More...
 
uint32_t i2c_ref_app_breathing_get_result (void)
 Get ref app breathing result. More...
 
float i2c_ref_app_breathing_get_breathing_rate (void)
 Get breathing rate. More...
 
ref_app_breathing_app_state_t i2c_ref_app_breathing_get_app_state (void)
 Get app state. More...
 
uint32_t i2c_ref_app_breathing_get_counter (void)
 Get measure counter. More...
 
uint32_t i2c_ref_app_breathing_get_frame_rate_mhz (void)
 Get the actual frame rate for the current ref app breathing configuration. More...
 
int acconeer_main (int argc, char *argv[])
 Assembly test example. More...
 

Variables

static ref_app_breathing_resources_t app_resources = {0}
 
static uint32_t i2c_app_command = 0U
 
static uint32_t i2c_app_status = 0U
 
static bool ref_app_breathing_active = false
 
static bool result_ready = false
 
static bool result_ready_sticky = false
 
static float breathing_rate = 0.0f
 
static ref_app_breathing_app_state_t app_state = REF_APP_BREATHING_APP_STATE_INIT
 
static uint32_t breathing_frame_counter = 0U
 
static uint32_t breathing_last_tick_ms = 0U
 
static uint32_t breathing_frame_rate_mhz = 0U
 
static bool uart_logs_enabled = false
 

Macro Definition Documentation

◆ SENSOR_ID

#define SENSOR_ID   (1U)

Definition at line 26 of file i2c_ref_app_breathing.c.

◆ SENSOR_TIMEOUT_MS

#define SENSOR_TIMEOUT_MS   (10000U)

Definition at line 27 of file i2c_ref_app_breathing.c.

◆ UART_LOG_BUFFER_SIZE

#define UART_LOG_BUFFER_SIZE   100

Definition at line 53 of file i2c_ref_app_breathing.c.

Function Documentation

◆ acconeer_main()

int acconeer_main ( int  argc,
char *  argv[] 
)

Assembly test example.

Touchless button application.

Tank level reference application.

Smart presence reference application.

Parking application.

Breathing example application.

Waste level application.

Vibration example.

Surface velocity example application.

Service subsweeps example.

Service multple configurations example.

Low power service example.

Service sensor calibration caching example.

Service example.

Processing subtract adaptive background example.

Processing static presence example.

Processing peak interpolation example.

Processing noncoherent mean example.

Processing coherent mean example.

Processing amplitude example.

hand motion application

Detector presence example with multiple configurations.

Low power detector presence example.

Detector presence example.

Detector distance example with iq data print.

Distance detector low power example.

Detector distance with calibration caching example.

Detector distance example.

Control helper example.

Cargo application.

Returns
Returns EXIT_SUCCESS if successful, otherwise EXIT_FAILURE

Test if measure on wake up is enable Do a measurement if the the detector is ready (configured and calibrated)

Test if measure on wake up is enable Do a measurement if the the detector is ready (configured and calibrated)

Definition at line 295 of file i2c_ref_app_breathing.c.

◆ app_activate()

static bool app_activate ( ref_app_breathing_resources_t resources,
bool  enable 
)
static

Activate application.

This function will activate the application

Parameters
[in]resourcesApplication resources struct
[in]enableset to true to enable the application
Returns
true if successful

Definition at line 664 of file i2c_ref_app_breathing.c.

◆ app_get_next()

static bool app_get_next ( ref_app_breathing_resources_t resources)
static

Get next breathing measurement.

Parameters
[in]resourcesApplication resources struct
Returns
true if successful

Definition at line 708 of file i2c_ref_app_breathing.c.

◆ app_status_clr_bits()

static void app_status_clr_bits ( uint32_t  bit_mask)
static

Clear bits in the i2c_app_status.

The i2c_app_status is protected by a critical section

Parameters
[in]bit_maskThe bit_mask to clear

Definition at line 513 of file i2c_ref_app_breathing.c.

◆ app_status_set_bits()

static void app_status_set_bits ( uint32_t  bit_mask)
static

Set bits in the i2c_app_status.

The i2c_app_status is protected by a critical section

Parameters
[in]bit_maskThe bit_mask to set

Definition at line 500 of file i2c_ref_app_breathing.c.

◆ app_status_test_bits()

static bool app_status_test_bits ( uint32_t  bit_mask)
static

Test bits in the i2c_app_status.

The i2c_app_status is protected by a critical section

Parameters
[in]bit_maskThe bit_mask to test
Returns
true if all the bits in bit_mask is set in i2c_app_status

Definition at line 526 of file i2c_ref_app_breathing.c.

◆ apply_app_config()

static void apply_app_config ( ref_app_breathing_resources_t resources)
static

Apply application config.

This function will create the ref app breathing and allocate the needed memory

Parameters
[in]resourcesApplication resources struct

Definition at line 597 of file i2c_ref_app_breathing.c.

◆ calibrate_sensor()

static bool calibrate_sensor ( ref_app_breathing_resources_t resources)
static

Calibrate sensor.

Parameters
[in]resourcesApplication resources struct
Returns
true if successful

Definition at line 557 of file i2c_ref_app_breathing.c.

◆ command_handler()

static void command_handler ( uint32_t  command)
static

Execute the command sent from the host.

Parameters
[in]commandThe command to execute

Definition at line 440 of file i2c_ref_app_breathing.c.

◆ create_sensor()

static void create_sensor ( ref_app_breathing_resources_t resources)
static

Create sensor.

Parameters
[in]resourcesApplication resources struct

Definition at line 538 of file i2c_ref_app_breathing.c.

◆ enter_hibernate()

static bool enter_hibernate ( acc_sensor_t sensor)
static

Enter sensor hibernation state.

Definition at line 826 of file i2c_ref_app_breathing.c.

◆ exit_hibernate()

static bool exit_hibernate ( acc_sensor_t sensor)
static

Exit sensor hibernation state.

Definition at line 840 of file i2c_ref_app_breathing.c.

◆ get_command()

static uint32_t get_command ( void  )
static

Get the i2c_app_command values.

The i2c_app_command is cleared during this read The read and clear are protected by a critical section

Returns
The command sent from the host

Definition at line 426 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_command()

bool i2c_ref_app_breathing_command ( uint32_t  command)

Send command to be executed to i2c ref app breathing.

Parameters
[in]commandThe command to be executed
Returns
true if successful

Definition at line 182 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_get_app_state()

ref_app_breathing_app_state_t i2c_ref_app_breathing_get_app_state ( void  )

Get app state.

Returns
A state of the application

Definition at line 257 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_get_breathing_rate()

float i2c_ref_app_breathing_get_breathing_rate ( void  )

Get breathing rate.

Returns
The breathing rate

Definition at line 245 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_get_config()

ref_app_breathing_config_t* i2c_ref_app_breathing_get_config ( void  )

Get ref app breathing configuration handle.

Returns
ref app breathing configuration handle

Definition at line 177 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_get_counter()

uint32_t i2c_ref_app_breathing_get_counter ( void  )

Get measure counter.

The counter will be increased every time the application completes a measure

Returns
measure counter from the application

Definition at line 269 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_get_frame_rate_mhz()

uint32_t i2c_ref_app_breathing_get_frame_rate_mhz ( void  )

Get the actual frame rate for the current ref app breathing configuration.

Returns
The frame rate in mHz

Definition at line 281 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_get_result()

uint32_t i2c_ref_app_breathing_get_result ( void  )

Get ref app breathing result.

Returns
result from ref app breathing

Definition at line 216 of file i2c_ref_app_breathing.c.

◆ i2c_ref_app_breathing_get_status()

uint32_t i2c_ref_app_breathing_get_status ( void  )

Get ref app breathing status.

Returns
status from ref app breathing

Definition at line 204 of file i2c_ref_app_breathing.c.

◆ module_low_power()

static void module_low_power ( void  )
static

Try to set module in low power mode.

Definition at line 803 of file i2c_ref_app_breathing.c.

◆ print_breathing_result()

static void print_breathing_result ( ref_app_breathing_result_t result)
static

Print the ref app breathing result.

Only available when the UART logs have been enabled with ENABLE_UART_LOGS

Parameters
[in]resultThe ref app breathing result

Definition at line 854 of file i2c_ref_app_breathing.c.

◆ uart_log()

static void uart_log ( const char *  format,
  ... 
)
static

UART logging function (can be enabled/disabled by command)

Definition at line 862 of file i2c_ref_app_breathing.c.

Variable Documentation

◆ app_resources

ref_app_breathing_resources_t app_resources = {0}
static

Definition at line 40 of file i2c_ref_app_breathing.c.

◆ app_state

◆ breathing_frame_counter

uint32_t breathing_frame_counter = 0U
static

Definition at line 48 of file i2c_ref_app_breathing.c.

◆ breathing_frame_rate_mhz

uint32_t breathing_frame_rate_mhz = 0U
static

Definition at line 50 of file i2c_ref_app_breathing.c.

◆ breathing_last_tick_ms

uint32_t breathing_last_tick_ms = 0U
static

Definition at line 49 of file i2c_ref_app_breathing.c.

◆ breathing_rate

float breathing_rate = 0.0f
static

Definition at line 46 of file i2c_ref_app_breathing.c.

◆ i2c_app_command

uint32_t i2c_app_command = 0U
static

Definition at line 41 of file i2c_ref_app_breathing.c.

◆ i2c_app_status

uint32_t i2c_app_status = 0U
static

Definition at line 42 of file i2c_ref_app_breathing.c.

◆ ref_app_breathing_active

bool ref_app_breathing_active = false
static

Definition at line 43 of file i2c_ref_app_breathing.c.

◆ result_ready

bool result_ready = false
static
Examples
ref_app_tank_level.c.

Definition at line 44 of file i2c_ref_app_breathing.c.

◆ result_ready_sticky

bool result_ready_sticky = false
static

Definition at line 45 of file i2c_ref_app_breathing.c.

◆ uart_logs_enabled

bool uart_logs_enabled = false
static

Definition at line 51 of file i2c_ref_app_breathing.c.