Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
PTU / PRU common profile API

Data Structures

struct  pru_control_t
 PRU Control structure. More...
 
struct  pru_static_t
 PRU Static Parameter structure. More...
 
struct  ptu_static_t
 PTU Static Parameter structure. More...
 
struct  pru_alert_bits_t
 Alert field used in both Alert Characteristic and Dynamic Parameters Characteristic. More...
 
struct  pru_alert_t
 PRU Alert Parameter structure. More...
 
struct  pru_dynamic_t
 PRU Dynamic Parameter structure. More...
 

Macros

#define SDK_VERSION   "2.1.0"
 
#define TIMER_START(timer_id, ms, p_ctx)   app_timer_start( timer_id, APP_TIMER_TICKS(ms, APP_TIMER_PRESCALER), p_ctx);
 

WPT Service characteristics structs.

enum  ctl_adj_power_t { CTL_ADJ_POWER_MAX_VAL = BLE_WPTS_ENABLE_PRU_ADJ_POWER_MAX_VAL, CTL_ADJ_POWER_66_PCT_VAL = BLE_WPTS_ENABLE_PRU_ADJ_POWER_66_PCT_VAL, CTL_ADJ_POWER_33_PCT_VAL = BLE_WPTS_ENABLE_PRU_ADJ_POWER_33_PCT_VAL, CTL_ADJ_POWER_2_5_W_VAL = BLE_WPTS_ENABLE_PRU_ADJ_POWER_2_5_W_VAL }
 Power adjust settings in control packet. More...
 
enum  ctl_perm_t {
  CTL_PERMISSION_PERMITTED = BLE_WPTS_PERMISSION_PERMITTED, CTL_PERMISSION_PERMITTED_WAITING = BLE_WPTS_PERMISSION_PERMITTED_WAITING, CTL_PERMISSION_DENIED_CROSS_CONNECTION = BLE_WPTS_PERMISSION_DENIED_CC, CTL_PERMISSION_DENIED_POWER = BLE_WPTS_PERMISSION_DENIED_POWER,
  CTL_PERMISSION_DENIED_DEVICES = BLE_WPTS_PERMISSION_DENIED_DEVICES, CTL_PERMISSION_DENIED_CLASS = BLE_WPTS_PERMISSION_DENIED_CLASS, CTL_PERMISSION_DENIED_HIGH_TEMP = BLE_WPTS_PERMISSION_DENIED_HIGH_TEMP
}
 Permissions fields in control packet. More...
 
enum  ctl_time_set_t {
  CTL_TIME_SET_DENIED = BLE_WPTS_TIME_SET_DENIED, CTL_TIME_SET_10MS = BLE_WPTS_TIME_SET_10MS, CTL_TIME_SET_20MS = BLE_WPTS_TIME_SET_20MS, CTL_TIME_SET_30MS = BLE_WPTS_TIME_SET_30MS,
  CTL_TIME_SET_40MS = BLE_WPTS_TIME_SET_40MS, CTL_TIME_SET_50MS = BLE_WPTS_TIME_SET_50MS, CTL_TIME_SET_60MS = BLE_WPTS_TIME_SET_60MS, CTL_TIME_SET_70MS = BLE_WPTS_TIME_SET_70MS,
  CTL_TIME_SET_80MS = BLE_WPTS_TIME_SET_80MS
}
 Time set field in control packet. More...
 
enum  pru_alert_type_t { ALERT_TYPE_NOTIFICATION = 0, ALERT_TYPE_INDICATION = 1 }
 Definition of PRU alert type. More...
 
enum  ptu_tester_command_t { WPTS_PTU_TEST_CMD_NORMAL_OPERATION_POWER_CTL = 0, WPTS_PTU_TEST_CMD_INCREASE_ITX = 1, WPTS_PTU_TEST_CMD_DECREASE_ITX = 2, WPTS_PTU_TEST_CMD_NO_ADJ_ITX = 3 }
 PTU Tester commands. More...
 

Common functions and macros.

void power_manage (void)
 Power manager.
 
void system_off (void)
 Function to put system in SYSTEMOFF mode.
 
uint32_t ticks_diff (uint32_t ticks_now, uint32_t ticks_old)
 
void dfu_start (void)
 Starts DFU mode. The function writes a special value to retention register to tell bootloader to start DFU mode, disables SoftDevice and performs a reset.
 
bool dfu_check (void)
 Needs to be implemented by application. Check if it is OK to jump to the DFU application. More...
 
void terminate (void)
 Needs to be implemented by application. Perform all requried actions before jump to DFU application can be done.
 
#define APP_ERROR_CHECK_ALLOW_DISCONNECT(ERR_CODE)
 Macro equivalent to APP_ERROR_CHECK, except that error codes returned if connection is lost will be allowed. More...
 

Detailed Description

Macro Definition Documentation

#define SDK_VERSION   "2.1.0"

SDK version.

Definition at line 30 of file wpt.h.

#define TIMER_START (   timer_id,
  ms,
  p_ctx 
)    app_timer_start( timer_id, APP_TIMER_TICKS(ms, APP_TIMER_PRESCALER), p_ctx);

Start app_timer with correct prescaler.

Definition at line 32 of file wpt.h.

#define APP_ERROR_CHECK_ALLOW_DISCONNECT (   ERR_CODE)
Value:
do \
{ \
if ((ERR_CODE != BLE_ERROR_INVALID_CONN_HANDLE) && \
(ERR_CODE != NRF_ERROR_INVALID_STATE) && \
(ERR_CODE != NRF_ERROR_BUSY)) \
{ \
APP_ERROR_CHECK(ERR_CODE); \
} \
} while (0)

Macro equivalent to APP_ERROR_CHECK, except that error codes returned if connection is lost will be allowed.

Parameters
[in]ERR_CODEError code supplied to the error handler.

Definition at line 228 of file wpt.h.

Enumeration Type Documentation

Power adjust settings in control packet.

Enumerator
CTL_ADJ_POWER_MAX_VAL 

Allow maximium PRU power consumption

CTL_ADJ_POWER_66_PCT_VAL 

Allow PRU to consume 66% of Prect_max

CTL_ADJ_POWER_33_PCT_VAL 

Allow PRU to consume 33% of Prect_max

CTL_ADJ_POWER_2_5_W_VAL 

Allow PRU to consume up to 2.5 W

Definition at line 42 of file wpt.h.

enum ctl_perm_t

Permissions fields in control packet.

Enumerator
CTL_PERMISSION_PERMITTED 

Permitted without reason

CTL_PERMISSION_PERMITTED_WAITING 

Permitted with waiting time due to limited available power

CTL_PERMISSION_DENIED_CROSS_CONNECTION 

Denied due to cross connection

CTL_PERMISSION_DENIED_POWER 

Denied due to limited available power

CTL_PERMISSION_DENIED_DEVICES 

Denied due to limited PTU Number of Devices

CTL_PERMISSION_DENIED_CLASS 

Denied due to limited PTU Class support

CTL_PERMISSION_DENIED_HIGH_TEMP 

Denied due to high temperature at PTU

Definition at line 52 of file wpt.h.

52 {
60 } ctl_perm_t;
61 
#define BLE_WPTS_PERMISSION_PERMITTED
PRU Control characteristic Permission field values.
ctl_perm_t
Permissions fields in control packet.
Definition: wpt.h:52
#define BLE_WPTS_PERMISSION_DENIED_HIGH_TEMP
#define BLE_WPTS_PERMISSION_PERMITTED_WAITING
#define BLE_WPTS_PERMISSION_DENIED_DEVICES
#define BLE_WPTS_PERMISSION_DENIED_CC
#define BLE_WPTS_PERMISSION_DENIED_CLASS
#define BLE_WPTS_PERMISSION_DENIED_POWER

Time set field in control packet.

Enumerator
CTL_TIME_SET_DENIED 

Do not perform Time Set

CTL_TIME_SET_10MS 

10ms

CTL_TIME_SET_20MS 

20ms

CTL_TIME_SET_30MS 

30ms

CTL_TIME_SET_40MS 

40ms

CTL_TIME_SET_50MS 

50ms

CTL_TIME_SET_60MS 

60ms

CTL_TIME_SET_70MS 

70ms

CTL_TIME_SET_80MS 

80ms

Definition at line 65 of file wpt.h.

65 {
76 
ctl_time_set_t
Time set field in control packet.
Definition: wpt.h:65
#define BLE_WPTS_TIME_SET_40MS
#define BLE_WPTS_TIME_SET_70MS
#define BLE_WPTS_TIME_SET_DENIED
PRU Control characteristic Time set values.
#define BLE_WPTS_TIME_SET_80MS
#define BLE_WPTS_TIME_SET_10MS
#define BLE_WPTS_TIME_SET_50MS
#define BLE_WPTS_TIME_SET_30MS
#define BLE_WPTS_TIME_SET_60MS
#define BLE_WPTS_TIME_SET_20MS

Definition of PRU alert type.

Enumerator
ALERT_TYPE_NOTIFICATION 

Send alert as notification.

ALERT_TYPE_INDICATION 

Send alert as indication.

Definition at line 125 of file wpt.h.

125 {
129 
pru_alert_type_t
Definition of PRU alert type.
Definition: wpt.h:125

PTU Tester commands.

Enumerator
WPTS_PTU_TEST_CMD_NORMAL_OPERATION_POWER_CTL 

No adjustment requested

WPTS_PTU_TEST_CMD_INCREASE_ITX 

Increase ITX one step size

WPTS_PTU_TEST_CMD_DECREASE_ITX 

Decrease ITX one step size

WPTS_PTU_TEST_CMD_NO_ADJ_ITX 

Disable ITX adjustment by any other way than test commands.

Definition at line 155 of file wpt.h.

Function Documentation

uint32_t ticks_diff ( uint32_t  ticks_now,
uint32_t  ticks_old 
)

Calculate difference between two ticks values. Takes care of overflow.

Parameters
ticks_nowThe most recent number of ticks.
ticks_oldOldest sample number of ticks
Returns
Difference in ticks with respect to overflow.

Definition at line 78 of file common.c.

79 {
80  if(ticks_old>ticks_now) //Overflow occured
81  {
82  return (((MAX_RTC_COUNTER_VAL-ticks_old)+ticks_now) & MAX_RTC_COUNTER_VAL);
83  }
84  else
85  {
86  return ((ticks_now-ticks_old) & MAX_RTC_COUNTER_VAL);
87  }
88 }
#define MAX_RTC_COUNTER_VAL
Definition: common.c:28
bool dfu_check ( void  )

Needs to be implemented by application. Check if it is OK to jump to the DFU application.

Returns
true if it is OK to jump to DFU application. False otherwise.

Definition at line 523 of file pru.c.

524 {
525  const pru_sensor_data_t * sensor_data;
526  sensor_data = pru_sensors_data_get();
527  return sensor_data->vrect == 0;
528 }
const pru_sensor_data_t * pru_sensors_data_get(void)
Get the latest data from the PRU sensors.
Definition: pru_sensors.c:146
Definition of PRU reporting data.
Definition: pru_sensors.h:26