IEC 61851#

Functions

struct iec61851 *iec61851_create(struct pilot *pilot, struct relay *relay)#

Create a new IEC 61851 instance.

Parameters:
  • pilot[in] Pointer to the pilot structure.

  • relay[in] Pointer to the relay structure.

Returns:

Pointer to the created IEC 61851 instance.

void iec61851_destroy(struct iec61851 *self)#

Destroy an IEC 61851 instance.

Parameters:

self[in] Pointer to the IEC 61851 instance to be destroyed.

iec61851_state_t iec61851_state(struct iec61851 *self)#

Get the current state of the IEC 61851 instance.

Parameters:

self[in] Pointer to the IEC 61851 instance.

Returns:

Current state of the IEC 61851 instance.

void iec61851_start_pwm(struct iec61851 *self, const uint8_t pct)#

Start the PWM signal with a specified duty cycle.

Parameters:
  • self[in] Pointer to the IEC 61851 instance.

  • pct[in] Duty cycle percentage for the PWM signal.

void iec61851_set_current(struct iec61851 *self, const uint32_t milliampere)#

Set the current limit for the IEC 61851 instance.

Parameters:
  • self[in] Pointer to the IEC 61851 instance.

  • milliampere[in] Current limit in milliamperes.

void iec61851_stop_pwm(struct iec61851 *self)#

Stop the PWM signal.

Parameters:

self[in] Pointer to the IEC 61851 instance.

void iec61851_set_state_f(struct iec61851 *self)#

Set the state to ‘F’ for the IEC 61851 instance.

Parameters:

self[in] Pointer to the IEC 61851 instance.

uint8_t iec61851_get_pwm_duty(struct iec61851 *self)#

Get the current PWM duty cycle.

Parameters:

self[in] Pointer to the IEC 61851 instance.

Returns:

Current PWM duty cycle percentage.

uint8_t iec61851_get_pwm_duty_target(struct iec61851 *self)#

Get the PWM duty cycle target for the IEC 61851 protocol.

This function retrieves the target duty cycle for the Pulse Width Modulation (PWM) signal used in the IEC 61851 protocol.

Parameters:

self[in] Pointer to the iec61851 structure.

Returns:

uint8_t The target PWM duty cycle.

void iec61851_start_power_supply(struct iec61851 *self)#

Start the power supply.

Parameters:

self[in] Pointer to the IEC 61851 instance.

void iec61851_stop_power_supply(struct iec61851 *self)#

Stop the power supply.

Parameters:

self[in] Pointer to the IEC 61851 instance.

bool iec61851_is_supplying_power(struct iec61851 *self)#

Check if the power supply is active.

Parameters:

self[in] Pointer to the IEC 61851 instance.

Returns:

true if the power supply is active, false otherwise.

bool iec61851_is_charging(struct iec61851 *self)#

Check if the instance is in charging state.

Parameters:

self[in] Pointer to the IEC 61851 instance.

Returns:

true if the instance is charging, false otherwise.

bool iec61851_is_charging_state(const iec61851_state_t state)#

Check if a given state is a charging state.

Parameters:

state[in] State to be checked.

Returns:

true if the state is a charging state, false otherwise.

bool iec61851_is_occupied(struct iec61851 *self)#

Check if the instance is occupied.

Parameters:

self[in] Pointer to the IEC 61851 instance.

Returns:

true if the instance is occupied, false otherwise.

bool iec61851_is_occupied_state(const iec61851_state_t state)#

Check if a given state is an occupied state.

Parameters:

state[in] State to be checked.

Returns:

true if the state is an occupied state, false otherwise.

bool iec61851_is_error(struct iec61851 *self)#

Check if the instance is in an error state.

Parameters:

self[in] Pointer to the IEC 61851 instance.

Returns:

true if the instance is in an error state, false otherwise.

bool iec61851_is_error_state(const iec61851_state_t state)#

Check if a given state is an error state.

Parameters:

state[in] State to be checked.

Returns:

true if the state is an error state, false otherwise.

const char *iec61851_stringify_state(const iec61851_state_t state)#

Convert the state to a string representation.

This function converts the given state to its string representation.

Parameters:

state[in] The state to convert.

Returns:

The string representation of the state.

uint32_t iec61851_duty_to_milliampere(const uint8_t duty)#

Converts duty cycle percentage to current in milliamperes.

This function takes a duty cycle percentage value and converts it to the equivalent current in milliamperes.

Parameters:

duty[in] The duty cycle percentage value.

Returns:

The equivalent current in milliamperes.

uint8_t iec61851_milliampere_to_duty(const uint32_t milliampere)#

Converts current in milliamperes to duty cycle percentage.

This function takes a current value in milliamperes and converts it to the equivalent duty cycle percentage.

Parameters:

milliampere[in] The current value in milliamperes.

Returns:

The equivalent duty cycle percentage.

Enums

enum iec61851_state_t#

Values:

enumerator IEC61851_STATE_A#
enumerator IEC61851_STATE_B#
enumerator IEC61851_STATE_C#
enumerator IEC61851_STATE_D#
enumerator IEC61851_STATE_E#
enumerator IEC61851_STATE_F#

Defines

IEC61851_EV_RESPONSE_TIMEOUT_SEC 6 /* IEC 61851-1, seq. 10.2 */#