Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
wpt.h
Go to the documentation of this file.
1 /* Copyright (c) Nordic Semiconductor. All Rights Reserved.
2  *
3  * The information contained herein is property of Nordic Semiconductor ASA.
4  * Terms and conditions of usage are described in detail in NORDIC
5  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
6  *
7  * Licensees are granted free, non-transferable use of the information. NO
8  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
9  * the file.
10  *
11  */
12 
20 #ifndef H__
21 #define H__
22 
23 #include <stdint.h>
24 #include <stdbool.h>
25 #include "ble_gap.h"
26 #include "ble_wpts_common.h"
27 
28 // SDK version
29 
30 #define SDK_VERSION "2.1.0"
32 #define TIMER_START(timer_id, ms, p_ctx) \
33  app_timer_start( timer_id, APP_TIMER_TICKS(ms, APP_TIMER_PRESCALER), p_ctx);
34 /******************************************************************************/
35 
37 /******************************************************************************/
38 
41 typedef enum
42 {
48 
51 typedef enum
52 {
61 
64 typedef enum
65 {
76 
78 typedef struct
79 {
80  uint8_t enable_pru_output:1;
81  uint8_t enable_pru_charge_indicator:1;
82  ctl_adj_power_t adj_power;
83  ctl_perm_t permissions;
84  ctl_time_set_t time_set;
86 
88 typedef struct
89 {
90  uint8_t protocol_rev;
91  uint8_t pru_category;
92  uint8_t hw_revision;
93  uint8_t fw_revision;
94  uint8_t prect_max;
95  uint16_t vrect_min_static;
96  uint16_t vrect_high_static;
97  uint16_t vrect_set;
98  uint16_t delta_r1;
99  uint8_t option_fields_r1_valid:1;
100  uint8_t info_nfc_receiver:1;
101  uint8_t info_sep_btle_radio:1;
102  uint8_t info_pc_alg_pref:1;
103  uint8_t info_adj_power_capability:1;
104  uint8_t info_ccp_connected_mode:1;
105  uint8_t info_ptu_test_mode:1;
107 
109 typedef struct
110 {
111  uint8_t option_valid_max_imp:1;
112  uint8_t option_valid_max_res:1;
113  uint8_t ptu_power;
114  uint8_t ptu_max_source_impedance;
115  uint8_t ptu_max_load_resistance;
116  uint8_t ptu_class;
117  uint8_t hardware_rev;
118  uint8_t firmware_rev;
119  uint8_t protocol_rev;
120  uint8_t devices_supported_bitval;
122 
124 typedef enum
125 {
129 
131 typedef struct
132 {
133  uint8_t pru_over_voltage :1;
134  uint8_t pru_over_current :1;
135  uint8_t pru_over_temperature :1;
136  uint8_t pru_self_protection :1;
137  uint8_t charge_complete :1;
138  uint8_t wired_charge_detect :1;
140 
141 
142 
144 typedef struct
145 {
146  pru_alert_bits_t alerts;
147  uint8_t mode_transition :2;
148  uint8_t device_address[BLE_GAP_ADDR_LEN];
150  uint8_t pru_charge_port :1;
152 
154 typedef enum
155 {
161 
163 typedef struct
164 {
165  uint8_t optional_fields;
166  uint16_t vrect;
167  uint16_t irect;
168  uint16_t vout;
169  uint16_t iout;
170  int16_t temperature;
171  uint16_t vrect_min_dyn;
172  uint16_t vrect_set_dyn;
173  uint16_t vrect_high_dyn;
175  uint8_t pru_charge_port:1;
176  uint8_t adjust_power_response :1;
177  uint16_t prect;
178  uint8_t putil;
179  ptu_tester_command_t tester_command;
181 
184 /******************************************************************************/
187 /******************************************************************************/
188 
191 void power_manage(void);
192 
195 void system_off(void);
196 
204 uint32_t ticks_diff(uint32_t ticks_now, uint32_t ticks_old);
205 
206 #ifdef DFU_SUPPORT
207 
210 void dfu_start(void);
211 
215 bool dfu_check(void);
216 
219 void terminate(void);
220 #endif //DFU_SUPPORT
221 
227 #define APP_ERROR_CHECK_ALLOW_DISCONNECT(ERR_CODE) \
228  do \
229  { \
230  if ((ERR_CODE != BLE_ERROR_INVALID_CONN_HANDLE) && \
231  (ERR_CODE != NRF_ERROR_INVALID_STATE) && \
232  (ERR_CODE != NRF_ERROR_BUSY)) \
233  { \
234  APP_ERROR_CHECK(ERR_CODE); \
235  } \
236  } while (0)
237 
240 #endif /* H__ */
241 
ctl_time_set_t
Time set field in control packet.
Definition: wpt.h:65
PTU Static Parameter structure.
Definition: wpt.h:110
#define BLE_WPTS_PERMISSION_PERMITTED
PRU Control characteristic Permission field values.
void power_manage(void)
Power manager.
Definition: common.c:65
#define BLE_WPTS_ENABLE_PRU_ADJ_POWER_MAX_VAL
uint32_t ticks_diff(uint32_t ticks_now, uint32_t ticks_old)
Definition: common.c:78
PRU Control structure.
Definition: wpt.h:79
#define BLE_WPTS_TIME_SET_40MS
pru_alert_type_t
Definition of PRU alert type.
Definition: wpt.h:125
#define BLE_WPTS_ENABLE_PRU_ADJ_POWER_66_PCT_VAL
ctl_perm_t
Permissions fields in control packet.
Definition: wpt.h:52
PRU Alert Parameter structure.
Definition: wpt.h:145
#define BLE_WPTS_TIME_SET_70MS
#define BLE_WPTS_TIME_SET_DENIED
PRU Control characteristic Time set values.
Alert field used in both Alert Characteristic and Dynamic Parameters Characteristic.
Definition: wpt.h:132
#define BLE_WPTS_ENABLE_PRU_ADJ_POWER_33_PCT_VAL
#define BLE_WPTS_PERMISSION_DENIED_HIGH_TEMP
#define BLE_WPTS_PERMISSION_PERMITTED_WAITING
#define BLE_WPTS_TIME_SET_80MS
bool dfu_check(void)
Needs to be implemented by application. Check if it is OK to jump to the DFU application.
Definition: pru.c:523
PRU Static Parameter structure.
Definition: wpt.h:89
#define BLE_WPTS_ENABLE_PRU_ADJ_POWER_2_5_W_VAL
#define BLE_WPTS_PERMISSION_DENIED_DEVICES
#define BLE_WPTS_PERMISSION_DENIED_CC
#define BLE_WPTS_TIME_SET_10MS
#define BLE_WPTS_TIME_SET_50MS
#define BLE_WPTS_TIME_SET_30MS
ctl_adj_power_t
Power adjust settings in control packet.
Definition: wpt.h:42
#define BLE_WPTS_PERMISSION_DENIED_CLASS
#define BLE_WPTS_TIME_SET_60MS
#define BLE_WPTS_PERMISSION_DENIED_POWER
ptu_tester_command_t
PTU Tester commands.
Definition: wpt.h:155
void dfu_start(void)
Starts DFU mode. The function writes a special value to retention register to tell bootloader to star...
Definition: common.c:93
#define BLE_WPTS_TIME_SET_20MS
void system_off(void)
Function to put system in SYSTEMOFF mode.
Definition: common.c:72
PRU Dynamic Parameter structure.
Definition: wpt.h:164
void terminate(void)
Needs to be implemented by application. Perform all requried actions before jump to DFU application c...
Definition: pru.c:518