/*
 * statemachine.h
 *
 * Created: 05/04/2021 13:23:24
 *  Author: Nick-XMG
 */ 


#ifndef STATEMACHINE_H_
#define STATEMACHINE_H_


typedef enum
{
	SYSTEM_INIT = 0,
	SYSTEM_IDLE = 1,
	MOTOR_IDLE = 2,
	MOTOR_I_CTRL_STATE = 3,
	MOTOR_V_CTRL_STATE = 4,
	MOTOR_P_CTRL_STATE = 5,
	MOTOR_VI_CTRL_STATE = 6,
	MOTOR_PVI_CTRL_STATE = 7,
	MOTOR_STOP = 8,
	FAULT = 9,
} CONTROLLER_FSM;

typedef enum
{
	NOFAULT = 0,
	VOLTAGE = 1,
	OVERCURRENT = 2,
	OVERTEMPERATURE = 3,
	MOTOR_STALL = 4,
	HALLSENSORINVALID = 5,
	GATE_DRIVER = 6,
	UNKNOWN = 7
} FAULTS;

typedef struct APPLICATION_STATUS
{
	CONTROLLER_FSM currentstate;
	CONTROLLER_FSM previousstate;
	FAULTS fault;
} APPLICATION_STATUS;

APPLICATION_STATUS applicationStatus;

#endif /* STATEMACHINE_H_ */