Go to the documentation of this file.
26 #define SENSOR_ID (1U)
27 #define SENSOR_TIMEOUT_MS (10000U)
53 #define UART_LOG_BUFFER_SIZE 100
171 static void uart_log(
const char *format, ...);
300 bool setup_status =
true;
301 bool get_next_frame =
false;
303 printf(
"I2C Ref App Breathing\n");
314 printf(
"ERROR: acc_rss_hal_register() failed\n\n");
316 setup_status =
false;
333 printf(
"ERROR: ref_app_breathing_config_create() failed\n\n");
334 setup_status =
false;
358 get_next_frame =
false;
365 printf(
"ERROR: Could not get next result\n");
461 printf(
"ERROR: Could not start application\n");
476 printf(
"ERROR: Could not stop application\n");
495 printf(
"ERROR: Unknown command: %" PRIu32
"", command);
510 uart_log(
"App Status = 0x%" PRIx32
"\n", temp_app_status);
523 uart_log(
"App Status = 0x%" PRIx32
"\n", temp_app_status);
546 if (resources->
sensor != NULL)
553 printf(
"ERROR: acc_sensor_create() failed\n");
563 bool cal_complete =
false;
564 const uint16_t calibration_retries = 1U;
567 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
574 if (status && !cal_complete)
578 }
while (status && !cal_complete);
591 printf(
"ERROR: acc_sensor_calibrate() failed\n");
607 if (resources->
handle != NULL)
614 printf(
"ERROR: ref_app_breathing_create() failed\n");
627 printf(
"ERROR: ref_app_breathing_get_buffer_size() failed\n");
635 if (resources->
buffer != NULL)
643 printf(
"ERROR: sensor buffer allocation failed\n");
659 printf(
"ERROR: apply application config failed\n");
670 uart_log(
"Start ref app breathing\n");
681 printf(
"ERROR: ref_app_breathing_prepare() failed\n");
697 uart_log(
"Stop ref app breathing\n");
719 printf(
"ERROR: acc_sensor_measure() failed\n");
728 printf(
"ERROR: Sensor interrupt timeout\n");
737 printf(
"ERROR: acc_sensor_read() failed\n");
752 printf(
"ERROR: ref_app_breathing_process() failed\n");
814 uart_log(
"Enter low power state\n");
832 printf(
"ERROR: acc_sensor_hibernate_on failed\n");
847 printf(
"ERROR: acc_sensor_hibernate_off failed\n");
858 uart_log(
"Breaths: %" PRIu16
" bpm\n", (uint16_t)
result->breathing_rate);
868 va_start(ap, format);
static bool exit_hibernate(acc_sensor_t *sensor)
Exit sensor hibernation state.
@ REF_APP_BREATHING_APP_STATE_ESTIMATE_BREATHING_RATE
ref_app_breathing_config_t * i2c_ref_app_breathing_get_config(void)
Get ref app breathing configuration handle.
bool ref_app_breathing_prepare(ref_app_breathing_handle_t *handle, ref_app_breathing_config_t *config, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare the application to do a measurement.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_ERROR_MASK
#define REF_APP_BREATHING_REG_COMMAND_ENUM_START_APP
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_BUSY_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_OK_MASK
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
@ REF_APP_BREATHING_APP_STATE_INIT
uint32_t acc_integration_get_time(void)
Get current time.
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
static bool ref_app_breathing_active
void i2c_application_system_reset(void)
Reset the system.
#define REF_APP_BREATHING_REG_COMMAND_ENUM_RESET_MODULE
bool ref_app_breathing_get_buffer_size(ref_app_breathing_handle_t *handle, uint32_t *buffer_size)
Get the buffer size needed for the provided ref app breathing handle.
acc_processing_result_t processing_result
The result from a completed calibration.
ref_app_breathing_handle_t * ref_app_breathing_create(ref_app_breathing_config_t *config)
Create a handle for the ref app breathing.
void acc_integration_critical_section_exit(void)
@ ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
static void uart_log(const char *format,...)
UART logging function (can be enabled/disabled by command)
Breathing application results container.
#define REF_APP_BREATHING_REG_COMMAND_ENUM_LOG_CONFIGURATION
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_POS
static bool uart_logs_enabled
void ref_app_breathing_reg_protocol_setup(void)
ref_app_breathing_config_t * config
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_OK_MASK
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_OK_MASK
uint32_t i2c_ref_app_breathing_get_frame_rate_mhz(void)
Get the actual frame rate for the current ref app breathing configuration.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_ERROR_MASK
void ref_app_breathing_reg_protocol_write_default(void)
static void module_low_power(void)
Try to set module in low power mode.
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
ref_app_breathing_config_t * ref_app_breathing_config_create(void)
Create a configuration for the ref app breathing.
static bool enter_hibernate(acc_sensor_t *sensor)
Enter sensor hibernation state.
static bool calibrate_sensor(ref_app_breathing_resources_t *resources)
Calibrate sensor.
#define REF_APP_BREATHING_REG_COMMAND_ENUM_APPLY_CONFIGURATION
ref_app_breathing_app_state_t i2c_ref_app_breathing_get_app_state(void)
Get app state.
void i2c_application_system_wait_for_interrupt(void)
Wait for interrupt to occur.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_ERROR_MASK
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_STICKY_MASK
uint32_t i2c_ref_app_breathing_get_result(void)
Get ref app breathing result.
static uint32_t get_command(void)
Get the i2c_app_command values.
static void create_sensor(ref_app_breathing_resources_t *resources)
Create sensor.
acc_detector_presence_result_t presence_result
bool ref_app_breathing_process(ref_app_breathing_handle_t *handle, void *buffer, ref_app_breathing_result_t *result)
Process the data.
ref_app_breathing_result_t result
static uint32_t i2c_app_status
static uint32_t i2c_app_command
ref_app_breathing_app_state_t app_state
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_ERROR_MASK
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
static bool app_get_next(ref_app_breathing_resources_t *resources)
Get next breathing measurement.
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_ERROR_MASK
bool acc_sensor_hibernate_off(const acc_sensor_t *sensor)
Restore sensor after exiting hibernation.
const char * acc_version_get(void)
Get the version of the Acconeer software.
static ref_app_breathing_app_state_t app_state
static bool result_ready_sticky
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK
void i2c_application_enter_low_power_state(void)
Make the MCU enter its low power state.
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
void acc_detector_presence_config_inter_frame_idle_state_set(acc_detector_presence_config_t *presence_config, acc_config_idle_state_t idle_state)
Set inter frame idle state.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_OK_MASK
float i2c_ref_app_breathing_get_breathing_rate(void)
Get breathing rate.
static uint32_t breathing_frame_rate_mhz
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_OK_MASK
void i2c_application_system_set_ready_pin(bool enable)
Set the ready pin state.
#define SENSOR_TIMEOUT_MS
uint32_t i2c_ref_app_breathing_get_status(void)
Get ref app breathing status.
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_OK_MASK
void i2c_application_set_periodic_wakeup(uint32_t period_ms)
Set up a periodic timer used to wake up the system from sleep.
#define REF_APP_BREATHING_REG_COMMAND_ENUM_STOP_APP
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_OK_MASK
bool acc_sensor_hibernate_on(acc_sensor_t *sensor)
Prepare sensor for entering hibernation.
void i2c_application_system_init(void)
Init the system.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_ERROR_MASK
static bool app_activate(ref_app_breathing_resources_t *resources, bool enable)
Activate application.
static uint32_t breathing_frame_counter
static void app_status_set_bits(uint32_t bit_mask)
Set bits in the i2c_app_status.
int acconeer_main(int argc, char *argv[])
Assembly test example.
void acc_detector_presence_config_log(acc_detector_presence_config_t *presence_config)
Print a configuration to the log.
bool i2c_application_is_periodic_wakeup(void)
Test if a periodic wake up has occurred.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_ERROR_MASK
float acc_detector_presence_config_frame_rate_get(const acc_detector_presence_config_t *presence_config)
Get the frame rate.
void acc_integration_critical_section_enter(void)
ref_app_breathing_handle_t * handle
static void command_handler(uint32_t command)
Execute the command sent from the host.
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_ERROR_MASK
bool acc_sensor_calibrate(acc_sensor_t *sensor, bool *cal_complete, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Calibrate a sensor.
static void print_breathing_result(ref_app_breathing_result_t *result)
Print the ref app breathing result.
Breathing application config container.
static void apply_app_config(ref_app_breathing_resources_t *resources)
Apply application config.
#define REF_APP_BREATHING_REG_COMMAND_ENUM_ENABLE_UART_LOGS
uint32_t i2c_ref_app_breathing_get_counter(void)
Get measure counter.
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_MASK
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
bool i2c_application_system_test_wakeup_pin(void)
Check if wakeup pin is high.
static float breathing_rate
static uint32_t breathing_last_tick_ms
static void app_status_clr_bits(uint32_t bit_mask)
Clear bits in the i2c_app_status.
struct acc_sensor acc_sensor_t
#define REF_APP_BREATHING_REG_COMMAND_ENUM_DISABLE_UART_LOGS
#define UART_LOG_BUFFER_SIZE
ref_app_breathing_app_state_t
State of the application.
static ref_app_breathing_resources_t app_resources
acc_cal_result_t sensor_cal_result
bool i2c_ref_app_breathing_command(uint32_t command)
Send command to be executed to i2c ref app breathing.
void acc_detector_presence_config_frame_rate_app_driven_set(acc_detector_presence_config_t *presence_config, bool enable)
Set if the application should maintain the requested frame rate.
acc_detector_presence_config_t * presence_config
static bool app_status_test_bits(uint32_t bit_mask)
Test bits in the i2c_app_status.
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.