Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
ptu.c File Reference
#include <stdint.h>
#include <string.h>
#include "ptu.h"
#include "nrf_assert.h"
#include "ptu_test_mux.h"
#include "ptu_sensors.h"
#include "ptu_conn_man.h"
#include "ptu_power_ctl.h"
#include "ptu_power_sharing.h"
#include "ptu_beacons.h"
#include "ptu_latching_fault.h"
#include "ptu_distant_list_handler.h"

Go to the source code of this file.

Functions

API implementation
void ptu_on_ble_evt (ble_evt_t *p_ble_evt)
 Dispatches a BLE stack event to PTU. More...
 
void ptu_init (app_sm_evt_handler_t sm_evt_handler)
 Initialize PTU. This function must be called before any other PTU function can be called. More...
 
void ptu_start (void)
 Start ptu profile. Here "start" means that profile can start generating events through ptu_evt_handler().
 
void terminate (void)
 Needs to be implemented by application. Perform all requried actions before jump to DFU application can be done.
 
bool dfu_check (void)
 Needs to be implemented by application. Check if it is OK to jump to the DFU application. More...
 

Static functions and variables

static ptu_sm_state_vars_t m_state
 
static app_sm_evt_handler_t m_app_sm_evt_handler = NULL
 
 APP_TIMER_DEF (m_pru_dyn_read_timer_id)
 
 APP_TIMER_DEF (m_ptu_sensor_timer_id)
 
static void m_ptu_sm_execute (ptu_sm_signal_type_t signal)
 Used when executing state machine events.
 
static void m_ptu_pru_dyn_read_timer_handler (void *p_context)
 
static void m_ptu_sensor_timer_handler (void *p_context)
 Handler of sensor timer. More...
 
static void m_alert_handler (ble_wpts_c_t *p_wpts_c, ble_wpts_c_evt_t *const p_wpts_c_evt)
 Handle PRU alert.
 
static void m_wpts_evt_handler (ble_wpts_c_t *p_wpts_c, ble_wpts_c_evt_t *const p_wpts_c_evt)
 Handle WPT client service event.
 
static void m_services_init (void)
 Initialize Client Service.
 
static void m_timers_init (void)
 Initialize timers.
 

Function Documentation

APP_TIMER_DEF ( m_pru_dyn_read_timer_id  )

PRU dynamic parameter read timer ID.

APP_TIMER_DEF ( m_ptu_sensor_timer_id  )

Sensor timer

static void m_ptu_pru_dyn_read_timer_handler ( void *  p_context)
static

PRU dynamic read timer handler. ¨*

Parameters
p_contextcontext data.

Definition at line 114 of file ptu.c.

115 {
116  uint32_t err_code;
117 
120  {
122 
123  #if(PTU_CCA_ROGUE_DETECT_ENABLE == true)
124  const ptu_sensor_data_t * sensors_data;
125  err_code = ptu_sensors_data_get(&sensors_data);
126  APP_ERROR_CHECK(err_code);
127 
128  if(sensors_data->rogue_obj_detected)
129  {
130  m_ptu_sm_execute(PTU_SM_SIGNAL_ROGUE_OBJECT_DETECTED);
131  }
132  #endif
133 
134  if(ptu_reg_n_entries_get() == 0)
135  {
136  m_ptu_sm_execute(PTU_SM_SIGNAL_ALL_DEVICES_DISCONNECTED);
137  }
138  }
139 }
void ptu_power_ctrl_adjust(void)
Perform power control adjustments.
uint8_t ptu_reg_n_entries_get(void)
Get the number of devices currently in registry. This will include all connected devices, as well as all devices which is currently being registered.
Definition: ptu_registry.c:268
void ptu_cm_dynamic_read_all(void)
Issue read request for the PRU dynamic characteristic to all registerred PRUs.
uint32_t ptu_sensors_data_get(const ptu_sensor_data_t **sensors_data)
Get the latest data read from the PTU sensors.
Definition: ptu_sensors.c:404
static void m_ptu_sm_execute(ptu_sm_signal_type_t signal)
Used when executing state machine events.
Definition: ptu.c:42
bool ptu_cm_mode_trans_in_progress(void)
Get mode transition status.
Definition: ptu_conn_man.c:855
Definition of PTU sensor data.
Definition: ptu_hw_config.h:99
static void m_ptu_sensor_timer_handler ( void *  p_context)
static

Handler of sensor timer.

Parameters
[in]p_contextGeneric context to sent to handler.

Definition at line 146 of file ptu.c.

147 {
148  const ptu_sensor_data_t * sensors_data;
149 
150  uint32_t err_code;
151  err_code = ptu_sensors_read();
152  APP_ERROR_CHECK(err_code);
153  err_code = ptu_sensors_data_get(&sensors_data);
154  APP_ERROR_CHECK(err_code);
156 }
uint32_t ptu_sensors_read(void)
Read sensors. This function should typically be called regularly by a timer and can generate events b...
Definition: ptu_sensors.c:303
void ptu_power_sharing_temperature_warning_set(bool warning)
Inform power control module that PTU is having a high temperature warning. When this occurs the power...
uint32_t ptu_sensors_data_get(const ptu_sensor_data_t **sensors_data)
Get the latest data read from the PTU sensors.
Definition: ptu_sensors.c:404
Definition of PTU sensor data.
Definition: ptu_hw_config.h:99

Variable Documentation

ptu_sm_state_vars_t m_state
static

State variables.

Definition at line 36 of file ptu.c.

app_sm_evt_handler_t m_app_sm_evt_handler = NULL
static

Application state machine event handler.

Definition at line 37 of file ptu.c.