no-OS
Classes | Macros | Enumerations | Functions
state_machine.h File Reference

STOUT state machine header file. More...

#include <stdint.h>
Include dependency graph for state_machine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  stout
 Structure for Stout machine. More...
 
struct  rms_adc_values
 

Macros

#define FIRMWARE_VERSION   ("v30923")
 
#define LED_NO   (4u)
 

Enumerations

enum  charger_state_e {
  STATE_POWER_ON = 0,
  STATE_RCD_SELF_TEST,
  STATE_A,
  STATE_B,
  STATE_C,
  STATE_D,
  STATE_RELAY_OPEN,
  STATE_CHECK_RELAY,
  STATE_FAULT
}
 ADE9113 waveorm data. More...
 
enum  interface_err_status_e {
  INTF_NO_ERR = 0,
  INTF_RELAY_ERR,
  INTF_INPUT_V_ERR,
  INTF_INPUT_V_ERR_U,
  INTF_INPUT_V_ERR_O,
  INTF_RCD_ERROR,
  INTF_INIT_RCD_ERROR,
  INTF_PILOT_ERROR,
  INTF_DIODE_ERR,
  INTF_OVERCURRENT_ERR,
  INTF_TEMPERATURE_ERR,
  INTF_PE_ERROR
}
 State machine fault condition. More...
 
enum  state_machine_events_e {
  S_M_UNDERVOLTAGE = 0,
  S_M_RCD,
  S_M_OVERCURRENT,
  S_M_DISCONNECTED,
  S_M_DIODE_ERR,
  S_M_CP_ERROR,
  S_M_RCD_TEST_TRIGGERED,
  S_M_RCD_TEST_COMPLETED,
  S_M_RCD_TEST_FAIL,
  S_M_VENTILATION_REQ,
  S_M_OVERCURRENT_WAIT,
  S_M_NO_EVENT,
  S_M_INITIAL_CHECK_DONE,
  S_M_WAIT,
  S_M_EV_CONNECTED,
  S_M_CHARGING,
  S_M_CHARGING_D,
  S_M_CHARGING_STOPPED,
  S_M_EVSE_READY,
  S_M_CHARGING_REQ,
  S_M_CHARGING_START,
  S_M_STOP_CHARGING,
  S_M_STOP_CHARGING_2,
  S_M_CHECK_STUCK_RELAY,
  S_M_CHECK_RELAY_PASSED,
  S_M_WAIT_B,
  S_M_DIODE_ERR_CHECK,
  S_M_DIODE_CHECK_DONE,
  S_M_VIN_RECOVER,
  S_M_UNDERVOLTAGE_WAIT,
  S_M_OVER_TEMPERATURE_1,
  S_M_OVER_TEMPERATURE_2,
  S_M_OVERVOLTAGE,
  S_M_PE_ERROR
}
 State machine event. More...
 

Functions

int state_machine ()
 State machine main execution. More...
 
enum state_machine_events_e state_machine_det_event_cp (struct stout *stout, enum state_machine_events_e event_in)
 Determine next state based on CP measurements and previous events. More...
 
enum state_machine_events_e state_machine_det_event_supply (struct stout *stout, enum state_machine_events_e event_in)
 Determine next state based on supply measurements and previous events. More...
 
enum state_machine_events_e state_machine_det_event_temperature (struct stout *stout, enum state_machine_events_e event_in)
 Determine next state based on temperature measurements and previous events. More...
 
uint16_t get_action (void)
 Get take action flag. More...
 
void set_action_flag (void)
 Set take action flag. More...
 
void reset_action_flag (void)
 Reset take action flag. More...
 
void inc_action_flag (void)
 Increment take action flag. More...
 
void start_charging (void)
 Signal that EV starts charging. More...
 
void stop_charging (void)
 Signal that EV stops charging. More...
 
uint8_t car_is_charging (void)
 Get charging state. More...
 

Detailed Description

STOUT state machine header file.

Author
GMois (georg.nosp@m.e.mo.nosp@m.is@an.nosp@m.alog.nosp@m..com), REtz (radu..nosp@m.etz@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright (c) 2023 Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ FIRMWARE_VERSION

#define FIRMWARE_VERSION   ("v30923")

◆ LED_NO

#define LED_NO   (4u)

Enumeration Type Documentation

◆ charger_state_e

ADE9113 waveorm data.

Enumerator
STATE_POWER_ON 
STATE_RCD_SELF_TEST 
STATE_A 
STATE_B 
STATE_C 
STATE_D 
STATE_RELAY_OPEN 
STATE_CHECK_RELAY 
STATE_FAULT 

◆ interface_err_status_e

State machine fault condition.

Enumerator
INTF_NO_ERR 
INTF_RELAY_ERR 
INTF_INPUT_V_ERR 
INTF_INPUT_V_ERR_U 
INTF_INPUT_V_ERR_O 
INTF_RCD_ERROR 
INTF_INIT_RCD_ERROR 
INTF_PILOT_ERROR 
INTF_DIODE_ERR 
INTF_OVERCURRENT_ERR 
INTF_TEMPERATURE_ERR 
INTF_PE_ERROR 

◆ state_machine_events_e

State machine event.

Enumerator
S_M_UNDERVOLTAGE 
S_M_RCD 
S_M_OVERCURRENT 
S_M_DISCONNECTED 
S_M_DIODE_ERR 
S_M_CP_ERROR 
S_M_RCD_TEST_TRIGGERED 
S_M_RCD_TEST_COMPLETED 
S_M_RCD_TEST_FAIL 
S_M_VENTILATION_REQ 
S_M_OVERCURRENT_WAIT 
S_M_NO_EVENT 
S_M_INITIAL_CHECK_DONE 
S_M_WAIT 
S_M_EV_CONNECTED 
S_M_CHARGING 
S_M_CHARGING_D 
S_M_CHARGING_STOPPED 
S_M_EVSE_READY 
S_M_CHARGING_REQ 
S_M_CHARGING_START 
S_M_STOP_CHARGING 
S_M_STOP_CHARGING_2 
S_M_CHECK_STUCK_RELAY 
S_M_CHECK_RELAY_PASSED 
S_M_WAIT_B 
S_M_DIODE_ERR_CHECK 
S_M_DIODE_CHECK_DONE 
S_M_VIN_RECOVER 
S_M_UNDERVOLTAGE_WAIT 
S_M_OVER_TEMPERATURE_1 
S_M_OVER_TEMPERATURE_2 
S_M_OVERVOLTAGE 
S_M_PE_ERROR 

Function Documentation

◆ car_is_charging()

uint8_t car_is_charging ( void  )

Get charging state.

Get charging state

Returns
charging state - 1 charging, 0 - not charging

◆ get_action()

uint16_t get_action ( void  )

Get take action flag.

Get take action flag

Returns
flag value
Here is the caller graph for this function:

◆ inc_action_flag()

void inc_action_flag ( void  )

Increment take action flag.

Increment take action flag

Returns
none

◆ reset_action_flag()

void reset_action_flag ( void  )

Reset take action flag.

Reset take action flag

Returns
none
Here is the caller graph for this function:

◆ set_action_flag()

void set_action_flag ( void  )

Set take action flag.

Set take action flag

Returns
none
Here is the caller graph for this function:

◆ start_charging()

void start_charging ( void  )

Signal that EV starts charging.

Signal that EV starts charging

Returns
none

◆ state_machine()

int state_machine ( )

State machine main execution.

Main routine

Returns
Result of the example execution. If working correctly, will execute continuously the while(1) loop.
Here is the caller graph for this function:

◆ state_machine_det_event_cp()

enum state_machine_events_e state_machine_det_event_cp ( struct stout stout,
enum state_machine_events_e  event_in 
)

Determine next state based on CP measurements and previous events.

Determine next state, CP measurements

Parameters
stout- state machine descriptor
event_in- previous event
Returns
event that took place
Here is the caller graph for this function:

◆ state_machine_det_event_supply()

enum state_machine_events_e state_machine_det_event_supply ( struct stout stout,
enum state_machine_events_e  event_in 
)

Determine next state based on supply measurements and previous events.

Determine next state, supply measurements

Parameters
stout- state machine descriptor
event_in- previous event
Returns
event that took place
Here is the caller graph for this function:

◆ state_machine_det_event_temperature()

enum state_machine_events_e state_machine_det_event_temperature ( struct stout stout,
enum state_machine_events_e  event_in 
)

Determine next state based on temperature measurements and previous events.

Determine next state, temperature measurements

Parameters
stout- state machine descriptor
event_in- previous event
Returns
event that took place
Here is the caller graph for this function:

◆ stop_charging()

void stop_charging ( void  )

Signal that EV stops charging.

Signal that EV stops charging

Returns
none
Here is the caller graph for this function: