Trip Meter

This module provides a set of functionalities for managing the Trip Meter system, including initialization, distance tracking, average speed calculation, and configuration management to track the vehicle’s trips effectively.

Configuration Parameters

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

Configuration

Name

Description

Range

enable

Enables Trip Meter functionality.

0 (disabled) or 1 (enabled)

trip_unit

Defines the unit for distance (either kilometers or miles).

0 (km) or 1 (miles)

max_trip_distance

Maximum distance allowed for a single trip.

1 to 9999 (km or miles)

avg_speed_enabled

Enables average speed calculation during the trip.

0 (disabled) or 1 (enabled)

trip_reset

Resets the current trip data.

0 (no reset) or 1 (reset)

APIs

The Trip Meter module provides the following APIs to initialize, process, and update the trip data:

API Functions

Function

Description

rs_am_tripmeter_init

Initializes the trip meter system with default configuration values.

rs_am_tripmeter_process

Processes the trip meter system by tracking distance and updating trip data.

Error Codes

Each API for the trip meter module returns success or failure codes. For detailed information on the error codes, please refer to the following section:

Trip Meter Module Header Details

The header file for trip meter modules, rs_am_trip.h, defines the required structures and APIs for initialization and processing.

Defines

RS_AM_TRIP_TIMER_BUFF_SIZE

Includes.

Timer buffer size

MAX_TRIP

Maximum Trip meter.

OVERALL_TRIP

Overall Trip meter.

Typedefs

typedef struct tag_rs_tripmeter_config rs_tripmeter_config_t

Configuration structure for the trip meter.

typedef struct tag_rs_tripmeter_runtime rs_tripmeter_runtime_t

Runtime structure for the trip meter.

typedef struct tag_rs_tripmeter_output rs_tripmeter_output_t

Output structure for the trip meter.

typedef struct tag_rs_am_tripmeter rs_am_tripmeter_t

Full structure combining trip meter data and trip AFE data.

Functions

rs_ret_val_t rs_am_tripmeter_init(rs_am_tripmeter_t *ptr_tripmeter)

Initializes the trip meter module by setting default values and preparing structures for operation.

Initializes the trip meter module.

Parameters:

ptr_tripmeter[in] Pointer to the trip meter structure to be initialized.

Returns:

rs_ret_val_t Result code indicating success initialization.

rs_ret_val_t rs_am_tripmeter_process(rs_am_tripmeter_t *ptr_tripmeter)

Main function for the tripmeter module.

Executes the main functionality of the tripmeter, including updates and conversions as required.

Parameters:

ptr_tripmeter[in] Pointer to the tripmeter structure containing configuration and runtime data.

Returns:

rs_ret_val_t Result code indicating success of the process.

struct tag_rs_tripmeter_config
#include <rs_am_trip.h>

Configuration structure for the trip meter.

Public Members

uint32_t start_time

Start time.

uint32_t max_trip_value

Maximum distance for an individual trip.

uint8_t trip_enable

Flag to enable/disable trip functionality (1 = enabled).

uint8_t trip_reset_state

Flag to reset the trip data (1 = reset).

uint8_t display_mode

Mode for displaying distance (e.g., km or miles).

uint8_t display_trip_state

Flag to select display trip data (1 = trip A), (2 = trip B).

uint8_t max_trip

Select the number of Trip meter.

struct tag_rs_tripmeter_runtime
#include <rs_am_trip.h>

Runtime structure for the trip meter.

Public Members

uint32_t total_trip_distance

Total distance of the current trip.

uint32_t total_trip_distance_in_M

Total trip distance in meters.

uint32_t last_trip_distance_KM

Last trip distance in kilometers.

uint32_t current_trip_distance

Current trip distance in meters.

uint32_t last_trip_distance

Last trip distance in meters.

uint32_t actual_trip_distance

Actual distance covered during the current trip.

uint32_t fuel_consumed

Amount of fuel consumed during the trip.

uint32_t total_fuel_consumed

Total fuel consumed across all trips.

uint32_t afe

Average Fuel Efficiency (AFE) during the trip.

uint32_t trip_start_time

Start time of the current trip.

uint32_t total_trip_time

Total time spent during the trip.

uint32_t elapsed_time_sec

Elapsed time in seconds for the trip.

uint32_t average_speed

Average speed during the trip.

struct tag_rs_tripmeter_output
#include <rs_am_trip.h>

Output structure for the trip meter.

Public Members

uint32_t display_trip_distance

Displayable trip distance (e.g., in km or miles).

uint32_t display_average_speed

Displayed average speed for the trip.

uint8_t display_timer[RS_AM_TRIP_TIMER_BUFF_SIZE]

Displayed timer for the trip in a time format.

uint32_t display_afe

Displayed Average Fuel Efficiency (AFE).

struct tag_rs_am_tripmeter
#include <rs_am_trip.h>

Full structure combining trip meter data and trip AFE data.

Public Members

rs_tripmeter_config_t config

Configuration data for the trip meter.

rs_tripmeter_runtime_t runtime[MAX_TRIP]

Runtime data for the trip meter.

rs_tripmeter_output_t output[MAX_TRIP]

Output data to be displayed for the trip meter.