Go to the documentation of this file.
33 #ifndef __STATE_MACHINE_H__
34 #define __STATE_MACHINE_H__
45 #define FIRMWARE_VERSION ("v30923")
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.
Definition: state_machine.c:923
int rms_adc_values_read(struct stout *stout, struct rms_adc_values *rms)
saves the current and voltage values in rms_adc structure
Definition: supply.c:351
@ S_M_STOP_CHARGING
Definition: state_machine.h:150
void set_relay_status(void)
Set relay status to CLOSED - 1.
Definition: relay.c:122
void set_action_flag(void)
Set take action flag.
Definition: state_machine.c:1349
@ S_M_CP_ERROR
Definition: state_machine.h:118
@ INTF_RELAY_ERR
Definition: state_machine.h:75
int32_t v2_rms_adc
Definition: state_machine.h:237
@ S_M_VENTILATION_REQ
Definition: state_machine.h:126
int relay_close(struct no_os_gpio_desc *relay)
Close relay command.
Definition: relay.c:91
state_machine_events_e
State machine event.
Definition: state_machine.h:106
struct ade9113_dev * ade9113
Definition: state_machine.h:187
int get_pwm_low_flag_state(void)
Get PWM low flag value.
Definition: pilot.c:126
int pilot_init(struct stout *stout)
Initialize pilot phase.
Definition: pilot.c:166
@ S_M_DIODE_ERR
Definition: state_machine.h:116
@ S_M_CHECK_RELAY_PASSED
Definition: state_machine.h:156
void inc_action_flag(void)
Increment take action flag.
Definition: state_machine.c:1369
int adt75_reg_read(struct adt75_desc *desc, uint32_t addr, uint16_t *val)
Read the raw value of a register.
Definition: adt75.c:56
uint8_t car_is_charging(void)
Get charging state.
Definition: state_machine.c:1399
struct no_os_gpio_desc * gpio_led[LED_NO]
Definition: state_machine.h:191
void reset_rcd_flag_state(void)
Reset RCD flag value.
Definition: rcd.c:79
int32_t temperature
Definition: state_machine.h:207
int32_t no_os_gpio_get_value(struct no_os_gpio_desc *desc, uint8_t *value)
Get the value of the specified GPIO.
Definition: no_os_gpio.c:221
int get_zero_cross_flag_state(void)
Get zero crossing flag value.
Definition: supply.c:71
@ STATE_RCD_SELF_TEST
Definition: state_machine.h:57
void reset_pwm_low_flag_state(void)
Reset PWM low flag value.
Definition: pilot.c:156
@ STATE_POWER_ON
Definition: state_machine.h:56
int adt75_remove(struct adt75_desc *desc)
Free the device descriptor.
Definition: adt75.c:160
uint16_t i_limit_not_ch
Definition: state_machine.h:215
Header file of Delay functions.
int32_t i_val
Definition: state_machine.h:205
int relay_open(struct no_os_gpio_desc *relay)
Open relay command.
Definition: relay.c:81
void reset_relay_status(void)
Set relay status to OPENED - 0.
Definition: relay.c:132
int32_t v2_val
Definition: state_machine.h:201
#define MILLIDEGREE_PER_DEGREE
Definition: no_os_units.h:71
Structure for Stout machine.
Definition: state_machine.h:185
@ S_M_CHARGING_D
Definition: state_machine.h:140
@ INTF_OVERCURRENT_ERR
Definition: state_machine.h:91
@ S_M_DIODE_CHECK_DONE
Definition: state_machine.h:162
@ S_M_WAIT
Definition: state_machine.h:134
uint8_t grid
Definition: state_machine.h:211
@ S_M_EV_CONNECTED
Definition: state_machine.h:136
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
uint16_t i_limit
Definition: state_machine.h:213
@ S_M_INITIAL_CHECK_DONE
Definition: state_machine.h:132
Structure holding time data (seconds, microseconds).
Definition: no_os_delay.h:47
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
#define ADT75_SIGN_BIT
Definition: adt75.h:54
@ S_M_OVERCURRENT_WAIT
Definition: state_machine.h:128
Power supply phase interface file.
@ S_M_CHARGING
Definition: state_machine.h:138
@ S_M_OVER_TEMPERATURE_1
Definition: state_machine.h:168
int pilot_write_new_values(struct stout *stout)
Update PWM values in the state machine structure.
Definition: pilot.c:374
struct no_os_gpio_desc * gpio_rcdac
Definition: state_machine.h:219
int rcd_init(struct no_os_irq_ctrl_desc *irq_desc, struct no_os_gpio_desc **rcm_test, struct no_os_gpio_desc **rcddc, struct no_os_gpio_desc **rcdac)
Initialize pilot phase.
Definition: rcd.c:92
@ INTF_INPUT_V_ERR_O
Definition: state_machine.h:81
@ S_M_CHARGING_REQ
Definition: state_machine.h:146
void reset_action_flag(void)
Reset take action flag.
Definition: state_machine.c:1359
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.
Definition: state_machine.c:1259
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
@ INTF_TEMPERATURE_ERR
Definition: state_machine.h:93
#define pr_debug(fmt, args...)
Definition: no_os_print_log.h:129
@ S_M_EVSE_READY
Definition: state_machine.h:144
int adt75_init(struct adt75_desc **desc, struct adt75_init_param *init_param)
Initialize the device structure.
Definition: adt75.c:132
int32_t v2_rms
Definition: state_machine.h:231
int self_test_rcd_running(struct stout *stout, uint16_t step, enum state_machine_events_e *event)
Running test for RCD.
Definition: self_test.c:286
@ S_M_CHARGING_STOPPED
Definition: state_machine.h:142
void set_action_flag(void)
Set take action flag.
Definition: state_machine.c:1349
uint32_t get_count_ms(void)
Definition: pilot.c:402
GPIO interrupt phase interface file.
@ S_M_DIODE_ERR_CHECK
Definition: state_machine.h:160
uint32_t pwm_high_val
Definition: state_machine.h:199
enum interface_err_status_e err_status
Definition: state_machine.h:221
@ S_M_WAIT_B
Definition: state_machine.h:158
uint16_t zcross_cnt
Definition: state_machine.c:56
enum charger_state_e previous_state
Definition: state_machine.h:195
@ INTF_RCD_ERROR
Definition: state_machine.h:83
struct no_os_gpio_desc * gpio_rcm_test
Definition: state_machine.h:217
@ STATE_FAULT
Definition: state_machine.h:64
Definition: state_machine.h:224
@ S_M_RCD_TEST_TRIGGERED
Definition: state_machine.h:120
User interface interface file.
Header file of ADE9113 Driver.
@ STATE_B
Definition: state_machine.h:59
@ INTF_NO_ERR
Definition: state_machine.h:73
@ S_M_PE_ERROR
Definition: state_machine.h:174
enum charger_state_e current_state
Definition: state_machine.h:193
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.
Definition: state_machine.c:1214
int state_machine()
State machine main execution.
Definition: state_machine.c:69
@ INTF_PE_ERROR
Definition: state_machine.h:99
@ S_M_RCD_TEST_FAIL
Definition: state_machine.h:124
int self_test_relay_stuck(struct stout *stout)
Relay test.
Definition: self_test.c:504
@ S_M_UNDERVOLTAGE
Definition: state_machine.h:108
interface_err_status_e
State machine fault condition.
Definition: state_machine.h:71
struct no_os_irq_ctrl_desc * irq_ctrl
Definition: ade9113.h:366
#define ADT75_TEMP_DIV
Definition: adt75.h:67
void reset_action_flag(void)
Reset take action flag.
Definition: state_machine.c:1359
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
@ S_M_OVERVOLTAGE
Definition: state_machine.h:172
uint16_t get_action(void)
Get take action flag.
Definition: state_machine.c:1339
int supply_init(struct ade9113_dev **device)
Initialize supply component.
Definition: supply.c:156
@ INTF_INPUT_V_ERR_U
Definition: state_machine.h:79
struct no_os_gpio_desc * relay
Definition: state_machine.h:189
void start_charging(void)
Signal that EV starts charging.
Definition: state_machine.c:1379
@ INTF_INIT_RCD_ERROR
Definition: state_machine.h:85
@ S_M_UNDERVOLTAGE_WAIT
Definition: state_machine.h:166
STOUT state machine header file.
int ade9113_drdy_int_enable(struct ade9113_dev *dev)
DRDY inerrupt enable.
Definition: ade9113.c:2523
uint32_t pwm_low_val
Definition: state_machine.h:197
#define ADT75_TEMP_MASK
Definition: adt75.h:53
void reset_count_ms(void)
Definition: pilot.c:408
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
@ S_M_RCD
Definition: state_machine.h:110
uint8_t is_charging
Definition: state_machine.c:58
@ S_M_OVER_TEMPERATURE_2
Definition: state_machine.h:170
void stop_charging(void)
Signal that EV stops charging.
Definition: state_machine.c:1389
@ S_M_NO_EVENT
Definition: state_machine.h:130
#define VIN_LOW_LIMIT
Definition: common_data.h:81
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
#define FIRMWARE_VERSION
Definition: state_machine.h:45
unsigned int us
Definition: no_os_delay.h:48
Self-tests interface file.
int interface_disp(struct stout *stout)
Display error code.
Definition: interface.c:124
void pilot_pwm_timer_set_duty_cycle(struct stout *stout, unsigned int duty_cycle)
Set PMW duty cycle.
Definition: pilot.c:271
uint8_t car_is_charging(void)
Get charging state.
Definition: state_machine.c:1399
@ STATE_CHECK_RELAY
Definition: state_machine.h:63
int get_gpio_flag_state(void)
Get GPIO flag value.
Definition: inter.c:104
charger_state_e
ADE9113 waveorm data.
Definition: state_machine.h:55
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.
Definition: state_machine.c:1214
@ STATE_C
Definition: state_machine.h:60
void pilot_update_vals(void)
Update PWM values.
Definition: pilot.c:388
int state_machine()
State machine main execution.
Definition: state_machine.c:69
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.
Definition: state_machine.c:923
int self_test_startup(struct stout *stout, struct rms_adc_values *rms_adc_values)
Startup test.
Definition: self_test.c:465
int32_t i_rms_adc
Definition: state_machine.h:233
Pilot phase interface file.
@ S_M_OVERCURRENT
Definition: state_machine.h:112
int32_t v1_rms
Definition: state_machine.h:229
unsigned int s
Definition: no_os_delay.h:48
int inter_init(struct stout *stout)
Initialize inter phase.
Definition: inter.c:164
@ STATE_D
Definition: state_machine.h:61
struct no_os_time no_os_get_time(void)
Get current time.
Definition: chibios_delay.c:51
uint16_t get_action(void)
Get take action flag.
Definition: state_machine.c:1339
@ S_M_STOP_CHARGING_2
Definition: state_machine.h:152
#define VIN_LOW_LIMIT_2
Definition: common_data.h:85
int interface_init(struct no_os_gpio_desc **gpio_led_desc)
Interface initialization routines.
Definition: interface.c:52
int relay_init(struct no_os_gpio_desc **relay)
Initialize relay component.
Definition: relay.c:59
int32_t v1_val
Definition: state_machine.h:203
@ INTF_INPUT_V_ERR
Definition: state_machine.h:77
#define LED_NO
Definition: state_machine.h:46
void start_charging(void)
Signal that EV starts charging.
Definition: state_machine.c:1379
@ S_M_CHARGING_START
Definition: state_machine.h:148
int32_t v1_rms_adc
Definition: state_machine.h:235
void inc_action_flag(void)
Increment take action flag.
Definition: state_machine.c:1369
@ S_M_VIN_RECOVER
Definition: state_machine.h:164
@ INTF_DIODE_ERR
Definition: state_machine.h:89
@ S_M_DISCONNECTED
Definition: state_machine.h:114
@ STATE_RELAY_OPEN
Definition: state_machine.h:62
@ STATE_A
Definition: state_machine.h:58
@ S_M_CHECK_STUCK_RELAY
Definition: state_machine.h:154
int32_t no_os_sign_extend32(uint32_t value, int index)
ADE9113 Device structure.
Definition: ade9113.h:348
int32_t no_os_irq_disable(struct no_os_irq_ctrl_desc *desc, uint32_t irq_id)
Disable specific interrupt.
Definition: no_os_irq.c:198
uint8_t ac_dc
Definition: state_machine.h:209
void stop_charging(void)
Signal that EV stops charging.
Definition: state_machine.c:1389
ADT75 device descriptor.
Definition: adt75.h:79
struct adt75_init_param adt75_ip
Definition: common_data.c:176
int32_t i_rms
Definition: state_machine.h:227
int self_test_supply(struct stout *stout, struct rms_adc_values *rms_adc_values)
Startup test for power supply.
Definition: self_test.c:68
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.
Definition: state_machine.c:1259
int get_rcd_flag_state(void)
Get RCD flag value.
Definition: rcd.c:69
@ INTF_PILOT_ERROR
Definition: state_machine.h:87
void reset_zero_cross_flag_state(void)
Reset zero crossing flag value.
Definition: supply.c:81
@ S_M_RCD_TEST_COMPLETED
Definition: state_machine.h:122
struct no_os_gpio_desc * gpio_rcddc
Definition: state_machine.h:218