Go to the documentation of this file.
28 #define SENSOR_ID (1U)
29 #define SENSOR_TIMEOUT_MS (10000U)
68 #define UART_LOG_BUFFER_SIZE 100
208 static void uart_log(
const char *format, ...);
268 uint32_t estimated_update_rate_mhz =
g_application_state.presence_estimated_frame_rate_mhz;
272 return estimated_update_rate_mhz;
307 int16_t temperature =
g_resources.most_recent_temperature;
325 bool setup_status =
true;
327 printf(
"I2C Example Cargo\n");
338 printf(
"ERROR: acc_rss_hal_register() failed\n\n");
341 setup_status =
false;
383 uart_log(
"Enter low power state\n");
428 printf(
"ERROR: Could not get next result\n");
443 printf(
"ERROR: cargo_prepare_presence() failed\n");
454 uint32_t sleep_time_ms = (uint32_t)(1000.0f /
g_resources.config.presence.update_rate);
474 printf(
"ERROR: Could not get next result\n");
502 printf(
"ERROR: Unknown command: %" PRIu32
"", command);
544 uart_log(
"Application Status = 0x%" PRIx32
"\n", temp_application_status);
557 uart_log(
"Application Status = 0x%" PRIx32
"\n", temp_application_status);
588 printf(
"ERROR: acc_sensor_create() failed\n");
600 bool cal_complete =
false;
624 printf(
"ERROR: acc_sensor_calibrate() failed\n");
636 bool calibration_done =
false;
643 while (status && !calibration_done)
645 if (full_calibration)
668 if (status && !calibration_done)
691 printf(
"ERROR: acc_sensor_hibernate_on failed\n");
706 printf(
"ERROR: acc_sensor_hibernate_off failed\n");
715 g_resources.config.presence.rate_is_app_driven =
true;
730 printf(
"ERROR: cargo_handle_create() failed\n");
745 printf(
"ERROR: cargo_get_buffer_size() failed\n");
761 printf(
"ERROR: sensor buffer allocation failed\n");
776 printf(
"ERROR: cargo_get_distance_cal_result_static_size() failed\n");
781 if (status && (
g_resources.distance_cal_result_static_size > 0U))
792 printf(
"ERROR: Cargo buffer allocation failed\n");
813 printf(
"ERROR: apply application config failed\n");
822 if (
g_resources.config.presence.update_rate > 10.0f)
824 printf(
"Presence update rate should be lower than 10Hz for optimal current consumption.\n");
841 printf(
"ERROR: cargo_prepare_utilization() failed\n");
848 printf(
"ERROR: acc_sensor_measure() failed\n");
857 printf(
"ERROR: Sensor interrupt timeout\n");
866 printf(
"ERROR: acc_sensor_read() failed\n");
875 bool result_available =
false;
885 printf(
"ERROR: cargo_process_utilization() failed\n");
890 g_resources.utilization_result_available = result_available;
931 printf(
"ERROR: acc_sensor_measure() failed\n");
940 printf(
"ERROR: Sensor interrupt timeout\n");
949 printf(
"ERROR: acc_sensor_read() failed\n");
965 printf(
"ERROR: cargo_process_presence() failed\n");
1052 g_application_state.presence_estimated_frame_rate_mhz = (diff_ms > 0) ? (1000000 / diff_ms) : 0;
1061 g_resources.most_recent_temperature = temperature;
1077 uart_log(
"Enter low power state\n");
1079 uart_log(
"Exit low power state\n");
1121 va_start(ap, format);
1135 printf(
"%s", log_buffer);
static bool utilization_get_next(void)
Get next utilization level measurement.
acc_processing_result_t * processing_result
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_BUSY_MASK
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CONFIG_APPLY_ERROR_MASK
static void module_low_power(void)
Try to set module in low power mode.
static void presence_reset_burst_result(void)
Reset presence burst result.
float max_inter_presence_score
cargo_handle_t * cargo_handle_create(const cargo_config_t *cargo_config)
Create a cargo handle.
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
uint32_t distance_cal_result_static_size
bool cargo_process_presence(cargo_handle_t *handle, void *buffer, cargo_result_t *cargo_result, acc_detector_presence_result_t *nullable_presence_result)
Process Sparse IQ data into a Cargo result.
uint32_t acc_integration_get_time(void)
Get current time.
int16_t i2c_example_cargo_get_temperature(void)
Get most recently measured temperature.
cargo_config_t * i2c_example_cargo_get_config(void)
Get pointer to internal cargo config struct.
#define EXAMPLE_CARGO_REG_COMMAND_ENUM_RESET_MODULE
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
bool cargo_prepare_presence(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare Cargo presence for measurements.
acc_cal_result_t sensor_cal_result
void i2c_application_system_reset(void)
Reset the system.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_SENSOR_CALIBRATE_OK_MASK
int16_t most_recent_temperature
uint32_t i2c_example_cargo_get_status(void)
Get cargo example app status.
void i2c_example_cargo_copy_presence_burst_result_fields(cargo_result_t *dst_result)
Copy presence example app cargo result.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_SENSOR_CALIBRATE_ERROR_MASK
acc_processing_result_t processing_result
static void apply_application_config(void)
Apply config.
The result from a completed calibration.
uint8_t * distance_cal_result_static
static void application_status_clr_bits(uint32_t bit_mask)
Clear bits in the i2c_application_status.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_SENSOR_CREATE_OK_MASK
void acc_integration_critical_section_exit(void)
uint32_t i2c_example_cargo_get_actual_presence_update_rate(void)
Get the estimated presence update rate of the.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CARGO_BUFFER_OK_MASK
static struct @4 g_presence_burst_result
static void update_most_recent_temperature(int16_t temperature)
Set most recent temperature to the passed temperature.
void cargo_config_initialize(cargo_config_t *cargo_config, cargo_preset_t preset)
Initialize cargo config struct with a preset.
uint32_t i2c_example_cargo_get_measure_counter(void)
Get the count of number of measurements performed.
Configuration struct for cargo.
static void application_status_set_bits(uint32_t bit_mask)
Set bits in the i2c_application_status.
void example_cargo_reg_protocol_setup(void)
float inter_presence_score
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
bool i2c_example_cargo_command(uint32_t command)
Send command to be executed to cargo i2c app.
static uint32_t get_command(void)
Get the i2c_detector_command values.
static bool validate_application_config_for_i2c(void)
Validate Cargo config for this I2C application.
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
uint32_t i2c_application_command
uint32_t i2c_application_status
static void increment_measure_counter(void)
Increment measure counter by one.
static void create_sensor(void)
Create sensor.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CARGO_CALIBRATE_ERROR_MASK
void i2c_application_system_wait_for_interrupt(void)
Wait for interrupt to occur.
Presence detector results container.
The result from a completed calibration update.
static void update_presence_update_rate_estimate(void)
Update presence frame estimation.
static struct @3 g_application_state
bool cargo_calibrate(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, uint8_t *distance_cal_result_static, uint32_t distance_cal_result_static_size, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, bool *calibration_complete)
Calibrate Cargo.
static void presence_update_burst_result(const cargo_result_t *cargo_result)
Update presence brust result.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CARGO_CALIBRATE_OK_MASK
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
bool utilization_result_available
bool acc_sensor_hibernate_off(const acc_sensor_t *sensor)
Restore sensor after exiting hibernation.
static bool application_status_test_bits(uint32_t bit_mask)
Test bits in the i2c_application_status.
const char * acc_version_get(void)
Get the version of the Acconeer software.
int acconeer_main(int argc, char *argv[])
Assembly test example.
#define EXAMPLE_CARGO_REG_COMMAND_ENUM_MEASURE_UTILIZATION_LEVEL
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.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CARGO_CREATE_ERROR_MASK
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CARGO_CREATE_OK_MASK
static void uart_log(const char *format,...)
UART logging function (can be enabled/disabled by command)
bool cargo_get_buffer_size(const cargo_handle_t *handle, uint32_t *buffer_size)
Get the required buffer sensor data buffer size.
bool cargo_get_distance_cal_result_static_size(const cargo_handle_t *handle, uint32_t *distance_cal_result_static_size)
Get the required buffer for static distance detector calibration.
static bool enter_hibernation(void)
Enter sensor hibernation state.
#define EXAMPLE_CARGO_REG_COMMAND_ENUM_MEASURE_PRESENCE
#define SENSOR_TIMEOUT_MS
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_SENSOR_BUFFER_ERROR_MASK
Distance Detector result returned from acc_detector_distance_process.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CONFIG_APPLY_OK_MASK
void i2c_application_system_set_ready_pin(bool enable)
Set the ready pin state.
float intra_presence_score
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
void i2c_application_set_periodic_wakeup(uint32_t period_ms)
Set up a periodic timer used to wake up the system from sleep.
#define EXAMPLE_CARGO_REG_COMMAND_ENUM_LOG_CONFIGURATION
bool acc_sensor_hibernate_on(acc_sensor_t *sensor)
Prepare sensor for entering hibernation.
#define ACC_LOG_FLOAT_TO_INTEGER(a)
static bool exit_hibernation(void)
Exit sensor hibernation state.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_APPLICATION_ERROR_MASK
static bool calibrate_sensor(void)
Calibrate sensor.
void i2c_application_system_init(void)
Init the system.
void cargo_config_log(const cargo_config_t *cargo_config)
Log cargo config to debug uart.
void i2c_example_cargo_copy_utilization_result_fields(cargo_result_t *dst_result)
Copy utilization example app cargo result.
float max_intra_presence_score
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_CARGO_BUFFER_ERROR_MASK
bool i2c_application_is_periodic_wakeup(void)
Test if a periodic wake up has occurred.
void acc_integration_critical_section_enter(void)
#define EXAMPLE_CARGO_REG_COMMAND_ENUM_ENABLE_UART_LOGS
uint32_t presence_estimated_frame_rate_mhz
static bool do_cargo_calibration(bool full_calibration)
Performs cargo calibration.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_RSS_REGISTER_OK_MASK
bool cargo_process_utilization(cargo_handle_t *handle, uint8_t *distance_cal_result_static, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, void *buffer, cargo_result_t *cargo_result, bool *result_available, acc_detector_distance_result_t *nullable_distance_result)
Process Sparse IQ data into a Cargo result.
static struct @2 g_resources
static void log_cargo_result_on_uart(const cargo_result_t *result)
Print the application result.
#define EXAMPLE_CARGO_REG_COMMAND_ENUM_APPLY_CONFIGURATION
acc_detector_cal_result_dynamic_t distance_cal_result_dynamic
cargo_mode_t cargo_current_mode_get(const cargo_handle_t *handle)
Get current mode of the cargo handle.
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_SENSOR_CREATE_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.
#define UART_LOG_BUFFER_SIZE
#define PRIfloat
Specifier for printing float type using integers.
uint32_t presence_last_tick_ms
#define EXAMPLE_CARGO_REG_COMMAND_ENUM_DISABLE_UART_LOGS
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
bool cargo_update_calibration(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, bool *calibration_complete)
Update Cargo calibration.
bool i2c_application_system_test_wakeup_pin(void)
Check if wakeup pin is high.
bool cargo_prepare_utilization(cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare Cargo utilization for measurements.
struct acc_sensor acc_sensor_t
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_FIELD_SENSOR_BUFFER_OK_MASK
static bool presence_get_next(void)
Get next presence measurement.
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.