Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
PRU State Machine

Data Structures

struct  pru_sm_state_vars_t
 State machine state variables. More...
 

Enumerations

enum  pru_sm_state_t {
  PRU_SM_STATE_NULL, PRU_SM_STATE_BOOT, PRU_SM_STATE_PRU_ON, PRU_SM_STATE_SYSTEM_ERROR,
  PRU_SM_STATE_COUNT
}
 PRU states.
 
enum  pru_sm_signal_type_t {
  PRU_SM_SIGNAL_NULL, PRU_SM_SIGNAL_CHARGE_START, PRU_SM_SIGNAL_CHARGE_STOP, PRU_SM_SIGNAL_POWER_APPLIED,
  PRU_SM_SIGNAL_POWER_REMOVED, PRU_SM_SIGNAL_CHARGE_COMPLETE, PRU_SM_SIGNAL_DISCONNECTED, PRU_SM_SIGNAL_SYSTEM_ERROR,
  PRU_SM_SIGNAL_COUNT
}
 PRU state machine signal type. More...
 

PRU state functions.

pru_sm_state_t pru_sm_execute (pru_sm_signal_type_t sig, pru_sm_state_vars_t *p_state)
 Execute state machine. More...
 

Detailed Description

Enumeration Type Documentation

PRU state machine signal type.

Enumerator
PRU_SM_SIGNAL_NULL 

Null signal, used when changing states.

PRU_SM_SIGNAL_CHARGE_START 

Charge command received

PRU_SM_SIGNAL_CHARGE_STOP 

Stop charging command received

PRU_SM_SIGNAL_POWER_APPLIED 

Sensor measurement: V_RECT >= V_RECT_BOOT.

PRU_SM_SIGNAL_POWER_REMOVED 

Sensor measurement: V_RECT <= V_RECT_UVLO.

PRU_SM_SIGNAL_CHARGE_COMPLETE 

Sensor measurement: V_OUTT >= V_OUT_CHARGED.

PRU_SM_SIGNAL_DISCONNECTED 

PRU has been disconnected. Not shown in state diagram, see 5.3.7.3 in BSS 1.3.

PRU_SM_SIGNAL_SYSTEM_ERROR 

Over-current, over_voltage or over_temperature trigger.

PRU_SM_SIGNAL_COUNT 

How many SM signals are defined?

Definition at line 36 of file pru_sm.h.

Function Documentation

pru_sm_state_t pru_sm_execute ( pru_sm_signal_type_t  sig,
pru_sm_state_vars_t p_state 
)

Execute state machine.

Parameters
[in]sigSignal to handle
[out]p_statePointer to PRU state variable
Returns
The current state after executing the event.

Definition at line 71 of file pru_sm.c.

72 {
73  static pru_sm_state_t current_state = PRU_SM_STATE_NULL;
74 
75  if(signal != PRU_SM_SIGNAL_NULL && p_state != NULL)
76  {
77  p_state->next_state = m_get_next_state(signal, p_state);
78  p_state->prev_state = p_state->current_state;
79  p_state->current_state = p_state->next_state;
80  current_state = p_state->current_state;
81  }
82 
83  return current_state;
84 }
pru_sm_state_t
PRU states.
Definition: pru_sm.h:26
pru_sm_state_t prev_state
Definition: pru_sm.h:57
pru_sm_state_t current_state
Definition: pru_sm.h:58
static pru_sm_state_t m_get_next_state(pru_sm_signal_type_t signal, pru_sm_state_vars_t *p_state)
Find the next state given the current state and the state machine event.
Definition: pru_sm.c:30
pru_sm_state_t next_state
Definition: pru_sm.h:59