Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
PTU State Machine

Data Structures

struct  ptu_sm_state_vars_t
 State machine state variables. More...
 

Enumerations

enum  sm_latch_fault_reason_t { PTU_SM_LFR_PRU_SYSTEM_ERROR, PTU_SM_LFR_ROGUE_OBJCT_MODE_TRANS_FAILED, PTU_SM_LFR_ROGUE_OBJCT_DETECTED }
 PTU Latch Fault reason type.
 
enum  ptu_sm_state_t {
  PTU_SM_STATE_CONFIGURATION = 0, PTU_SM_STATE_POWER_SAVE, PTU_SM_STATE_LOW_POWER, PTU_SM_STATE_POWER_TRANSFER,
  PTU_SM_STATE_LATCH_FAULT, PTU_SM_STATE_LOCAL_FAULT, PTU_SM_STATE_COUNT
}
 PTU states.
 
enum  ptu_sm_signal_type_t {
  PTU_SM_SIGNAL_NULL, PTU_SM_SIGNAL_CONFIGURATION_COMPLETE, PTU_SM_SIGNAL_LOCAL_FAULT, PTU_SM_SIGNAL_LOCAL_FAULT_CLEARED,
  PTU_SM_SIGNAL_REGISTRATION_TIMEOUT, PTU_SM_SIGNAL_CHARGE_START, PTU_SM_SIGNAL_PRU_ADV_RCVD, PTU_SM_SIGNAL_ALL_DEVICES_DISCONNECTED,
  PTU_SM_SIGNAL_PRU_ALL_CHARGE_COMPLETE, PTU_SM_SIGNAL_ROGUE_OBJECT_DETECTED, PTU_SM_SIGNAL_SYSTEM_ERROR, PTU_SM_SIGNAL_LATCHING_FAULT_CLEARED_BY_USER
}
 PTU signal type.
 

PTU SM functions.

ptu_sm_state_t ptu_sm_execute (ptu_sm_signal_type_t signal, ptu_sm_state_vars_t *p_state)
 State machine input signal handler. More...
 

Detailed Description

Function Documentation

ptu_sm_state_t ptu_sm_execute ( ptu_sm_signal_type_t  signal,
ptu_sm_state_vars_t p_state 
)

State machine input signal handler.

Parameters
[in]signalSignal data
[in]p_stateCurrent state variables
Returns
The current state

Definition at line 94 of file ptu_sm.c.

95 {
96  static ptu_sm_state_t current_state = PTU_SM_STATE_CONFIGURATION;
97 
98  if(signal != PTU_SM_SIGNAL_NULL && p_state != 0) // used for debugging
99  {
100  p_state->next_state = m_get_next_state(signal, p_state);
101  p_state->prev_state = p_state->current_state;
102  p_state->current_state = p_state->next_state;
103  current_state = p_state->current_state;
104  }
105 
106  return current_state;
107 }
static ptu_sm_state_t m_get_next_state(ptu_sm_signal_type_t signal, ptu_sm_state_vars_t *p_state)
Find the next state given the current state and the state machine event.
Definition: ptu_sm.c:29
ptu_sm_state_t prev_state
Definition: ptu_sm.h:69
ptu_sm_state_t current_state
Definition: ptu_sm.h:70
ptu_sm_state_t
PTU states.
Definition: ptu_sm.h:35
ptu_sm_state_t next_state
Definition: ptu_sm.h:71