Speedometer

This module provides a set of functionalities for managing the Speedometer system, including initialization, speed factor conversion, speed ramping, and hysteresis filtering to ensure smooth transitions and accurate display of speed data.

Configuration Parameters

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

Configuration

Name

Description

Range

enable

Enables Speedometer functionality.

0 (disabled) or 1 (enabled)

scaling_multiplier

Multiplier for scaling the raw speed data to a displayable value.

Positive integer values.

scaling_divisor

Divisor for scaling the raw speed data.

Positive integer values.

ramp_value

Value for ramping speed adjustments.

0 to 255

max_speed

Maximum speed limit for the speedometer.

0 to 255 (unit: defined by unit)

speedo_hysteresis

Speedometer Hysteresis value.

0 to 255

APIs

The Speedometer module provides the following APIs to initialize, process, and update the speedometer data:

API Functions

Function

Description

rs_am_speedometer_init

Initializes the speedometer system with default configuration values.

rs_am_speedometer_process

Processes the speedometer system by updating the speed data based on current conditions.

Error Codes

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

Speedometer Module Header Details

The header file for speedometer modules, rs_am_speedometer.h, defines the required structures and APIs for initialization and processing.

Typedefs

typedef struct tag_rs_speed_config rs_speed_config_t

Includes.

Speedometer configuration data structure

typedef struct tag_rs_speed_runtime rs_speed_runtime_t

Speedometer runtime data structure.

typedef struct tag_rs_speed_output rs_speed_output_t

Speedometer output data structure.

typedef struct tag_rs_am_speedometer rs_am_speedometer_t

Contains information about Speedometer.

Functions

rs_ret_val_t rs_am_speedometer_init(rs_am_speedometer_t *ptr_speedometer)

Initializes the speedometer system with default configuration values.

This function sets up the speedometer configuration structure with default values, including enabling the system, setting max speed, ramp time, and scaling factors.

Parameters:

ptr_speedometer[in] A pointer to the rs_am_speedometer_t structure that needs to be initialized.

Returns:

Returns a result code indicating the success of the initialization.

rs_ret_val_t rs_am_speedometer_process(rs_am_speedometer_t *ptr_speedometer)

Executes the periodic task for updating the speedometer data.

This function checks if the speedometer system is enabled and then performs the necessary speed factor conversion based on the current speed data.

Parameters:

ptr_speedometer[in] A pointer to the rs_am_speedometer_t structure to process.

Returns:

Returns a result code indicating the success of the task execution.

struct tag_rs_speed_config
#include <rs_am_speedometer.h>

Includes.

Speedometer configuration data structure

Public Members

uint8_t enable

Flag to enable or disable speedometer.

uint8_t scaling_multiplier

Multiplier for scaling the speed values.

uint8_t scaling_divisor

Divisor for scaling the speed values.

uint8_t ramp_value

Ramp value for speed adjustments.

uint8_t max_speed

Maximum speed limit for the speedometer.

uint8_t speedo_hysteresis

Speedometer Hysteresis value.

struct tag_rs_speed_runtime
#include <rs_am_speedometer.h>

Speedometer runtime data structure.

Public Members

uint16_t raw_speed

Raw speed value.

uint16_t factored_spd

factore speed value

uint16_t filtered_spd

filter speed value

uint8_t module_ready

Flag indicating if the speedometer module is ready.

uint8_t ramping_value

Speed for ramping.

uint8_t update_counter

Update counter for controlling ramp delay.

struct tag_rs_speed_output
#include <rs_am_speedometer.h>

Speedometer output data structure.

Public Members

uint8_t calculated_spd

Calculated speed value.

uint8_t ramping_spd

Speed value during ramping.

uint8_t prev_display_spd

Previous speed value displayed.

uint16_t display_spd

Displayed speed value.

uint16_t filtered_display_spd

Filtered version of the display speed.

uint8_t angular_spd

Angular speed corresponding to the vehicle’s speed.

uint8_t state

Operational state (low/high voltage, failure, etc.)

struct tag_rs_am_speedometer
#include <rs_am_speedometer.h>

Contains information about Speedometer.

Public Members

rs_speed_config_t config

Speedometer configuration parameters.

rs_speed_runtime_t runtime

Speedometer runtime data.

rs_speed_output_t output

Speedometer output data.