Odometer

This module provides functionalities for managing the Odometer system, including initialization, distance calculation, unit conversion, ABS factor adjustments, and runtime updates to ensure accurate representation of vehicle mileage.

Configuration Parameters

All API functions have the first argument as the module instance.

Configuration

Name

Description

Range

enable_module

Enables Odometer functionality.

0 (disabled) or 1 (enabled)

odo_reset_count

Maximum reset count for the odometer.

0 to 255

abs_factor

ABS adjustment factor.

0 to 100

max_reset_distance

Maximum resettable distance (in chosen unit).

1 to 999999

max_display_value

Maximum displayable odometer value.

1 to 9999999

display_mode_state

Display mode (e.g., kilometers or miles).

0 (km) or 1 (miles)

APIs

The Odometer module provides the following APIs for initialization, processing, and updates:

API Functions

Function

Description

rs_am_odometer_init

Initializes the odometer system with default configuration values.

rs_am_odometer_process

Processes the odometer system by calculating and updating distances.

am_odometer_notify

Receives event messages for the odometer and updates the runtime data.

Error Codes

Each API returns success or failure codes. For detailed information, refer to:

Odometer Module Header Details

The header file for the Odometer module, rs_am_odometer.h, defines the necessary structures and APIs.

Typedefs

typedef struct tag_rs_odometer_config rs_odometer_config_t

Includes.

odometer configuration data structure

typedef struct tag_rs_odometer_runtime rs_odometer_runtime_t

odometer runtime data structure

typedef struct tag_rs_odo_output rs_odo_output_t

odometer output data structure

typedef struct tag_rs_am_odometer rs_am_odometer_t

Contains information about odometer.

Functions

rs_ret_val_t rs_am_odometer_init(rs_am_odometer_t *ptr_odometer)

Initializes the odometer module.

Sets up default configuration and runtime values and registers the message handler for odometer events with the dispatcher.

Parameters:

ptr_odometer[in] Pointer to the odometer data structure to initialize.

Returns:

Returns success on successful initialization.

rs_ret_val_t rs_am_odometer_process(rs_am_odometer_t *ptr_odometer)

Periodically processes the odometer data.

Checks the odometer state, processes raw data, converts units, updates the display, and dispatches the final odometer value to consumers.

Parameters:

ptr_odometer[in] Pointer to the odometer data structure.

Returns:

Returns success after processing the odometer data.

struct tag_rs_odometer_config
#include <rs_am_odometer.h>

Includes.

odometer configuration data structure

Public Members

uint8_t enable_module

Enable/disable odometer functionality.

uint8_t odo_reset_count

Maximum reset count.

uint8_t abs_factor

ABS adjustment factor.

uint32_t max_reset_distance

Maximum resettable distance.

uint8_t odo_reset_state

Current odometer state.

uint32_t max_display_value

Maximum displayable value.

uint8_t display_mode_state

Display mode (e.g., km/miles)

struct tag_rs_odometer_runtime
#include <rs_am_odometer.h>

odometer runtime data structure

Public Members

uint32_t present_value

Current odometer value.

uint32_t prev_value

Previous odometer value.

uint32_t raw_value

Raw odometer data.

uint32_t raw_value_m

Raw data in meters.

uint32_t converted_value

Converted odometer value.

uint32_t final_value

Final odometer value for display.

uint8_t abs_status

ABS status.

struct tag_rs_odo_output
#include <rs_am_odometer.h>

odometer output data structure

Public Members

uint32_t display_value

Odometer display value.

uint8_t fault_state

Fault state of odometer.

struct tag_rs_am_odometer
#include <rs_am_odometer.h>

Contains information about odometer.

Public Members

rs_odometer_config_t config

Configuration data.

rs_odometer_runtime_t runtime

Runtime data.

rs_odo_output_t output

Output data.