b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /** \file vp886_api.h |
| 2 | * vp886_api.h |
| 3 | * |
| 4 | * Header file that defines all the commands for the Vp886 series devices. |
| 5 | * |
| 6 | * Copyright (c) 2011, Microsemi Corporation |
| 7 | * |
| 8 | * $Revision: 12587 $ |
| 9 | * $LastChangedDate: 2018-06-21 17:22:20 -0500 (Thu, 21 Jun 2018) $ |
| 10 | */ |
| 11 | |
| 12 | #ifndef VP886_API_H |
| 13 | #define VP886_API_H |
| 14 | |
| 15 | #include "vp_api_cfg.h" |
| 16 | #include "vp_hal.h" |
| 17 | #include "vp_CSLAC_types.h" |
| 18 | #include "vp_api_common.h" |
| 19 | #include "vp_timer_queue.h" |
| 20 | #ifdef VP886_INCLUDE_ADAPTIVE_RINGING |
| 21 | #include "vp_adaptive_ringing.h" |
| 22 | #endif |
| 23 | |
| 24 | #define VP886_MAX_NUM_CHANNELS 2 |
| 25 | |
| 26 | #ifdef VP886_INCLUDE_TESTLINE_CODE |
| 27 | #include "vp_api_test.h" |
| 28 | #include "vp886_testline.h" |
| 29 | #endif |
| 30 | |
| 31 | #include "vp886_registers.h" |
| 32 | |
| 33 | |
| 34 | /* Enforce a minimum configurable event queue size */ |
| 35 | #define VP886_EVENT_QUEUE_MIN_SIZE 6 |
| 36 | #if VP886_EVENT_QUEUE_SIZE < VP886_EVENT_QUEUE_MIN_SIZE |
| 37 | #error VP886_EVENT_QUEUE_SIZE configured below the minimum |
| 38 | #endif |
| 39 | /* Define a new event structure to use in the queue to reduce size. VpEventType |
| 40 | * contains several data members that are not necessary internally. */ |
| 41 | typedef struct { |
| 42 | uint8 channelId; |
| 43 | VpEventCategoryType eventCategory; |
| 44 | uint16 eventId; |
| 45 | uint16 eventData; |
| 46 | uint16 parmHandle; |
| 47 | bool hasResults; |
| 48 | } Vp886QueuedEventType; |
| 49 | |
| 50 | typedef struct { |
| 51 | Vp886QueuedEventType events[VP886_EVENT_QUEUE_SIZE]; |
| 52 | uint8 numQueued; |
| 53 | uint8 pushIndex; |
| 54 | uint8 popIndex; |
| 55 | bool overflowed; |
| 56 | } Vp886EventQueueType; |
| 57 | |
| 58 | |
| 59 | typedef struct { |
| 60 | VpOptionPulseType pulse; /* VP_DEVICE_OPTION_ID_PULSE */ |
| 61 | VpOptionPulseType pulse2; /* VP_DEVICE_OPTION_ID_PULSE2 */ |
| 62 | VpOptionCriticalFltType criticalFlt; /* VP_DEVICE_OPTION_ID_CRITICAL_FLT */ |
| 63 | VpOptionDeviceIoType deviceIo; /* VP_DEVICE_OPTION_ID_DEVICE_IO */ |
| 64 | VpOptionEventMaskType eventMask; /* VP_OPTION_ID_EVENT_MASK */ |
| 65 | VpOptionAdaptiveRingingType adaptiveRinging; /* VP_DEVICE_OPTION_ID_ADAPTIVE_RINGING */ |
| 66 | VpOptionRingPhaseSyncType ringPhaseSync; /* VP_DEVICE_OPTION_ID_RING_PHASE_SYNC */ |
| 67 | VpOptionFsyncRateType fsyncRate; /* VP_DEVICE_OPTION_ID_FSYNC_RATE */ |
| 68 | VpOptionAccessCtrlType accessCtrl; /* VP_DEVICE_OPTION_ID_ACCESS_CTRL */ |
| 69 | VpOptionSpiErrorCtrlType spiErrorCtrl; /* VP_DEVICE_OPTION_ID_SPI_ERROR_CTRL */ |
| 70 | } Vp886DevOptionsCacheType; |
| 71 | |
| 72 | typedef struct { |
| 73 | VpOptionPulseModeType pulseMode; /* VP_OPTION_ID_PULSE_MODE */ |
| 74 | VpOptionTimeslotType timeslot; /* VP_OPTION_ID_TIMESLOT */ |
| 75 | VpOptionCodecType codec; /* VP_OPTION_ID_CODEC */ |
| 76 | VpOptionLoopbackType loopback; /* VP_OPTION_ID_LOOPBACK */ |
| 77 | VpOptionLineStateType lineState; /* VP_OPTION_ID_LINE_STATE */ |
| 78 | VpOptionEventMaskType eventMask; /* VP_OPTION_ID_EVENT_MASK */ |
| 79 | VpOptionRingControlType ringControl; /* VP_OPTION_ID_RING_CNTRL */ |
| 80 | VpOptionPcmTxRxCntrlType pcmTxRxCntrl; /* VP_OPTION_ID_PCM_TXRX_CNTRL */ |
| 81 | bool switcherCtrl; /* VP_OPTION_ID_SWITCHER_CTRL */ |
| 82 | VpOptionAbsGainType absGain; /* VP_OPTION_ID_ABS_GAIN */ |
| 83 | VpOptionGndFltProtType gndFltProt; /* VP_OPTION_ID_GND_FLT_PROTECTION */ |
| 84 | VpOptionDtmfModeType dtmfMode; /* VP_OPTION_ID_DTMF_MODE */ |
| 85 | uint16 ringTripConfirm; /* VP_OPTION_ID_RINGTRIP_CONFIRM */ |
| 86 | VpOptionHighPassFilterType highPassFilter; /* VP_OPTION_ID_HIGHPASS_FILTER */ |
| 87 | VpOptionDtmfParamsType dtmfParams; /* VP_OPTION_ID_DTMF_PARAMS */ |
| 88 | } Vp886LineOptionsCacheType; |
| 89 | |
| 90 | |
| 91 | #define VP886_NUM_PROFILE_TYPES 9 |
| 92 | |
| 93 | /* ABS Supply Configurations: Single, Slave, Master */ |
| 94 | typedef enum { |
| 95 | VP886_ABS_SUPP_CFG_SINGLE = 0, |
| 96 | VP886_ABS_SUPP_CFG_SLAVE = 1, |
| 97 | VP886_ABS_SUPP_CFG_MASTER = 2 |
| 98 | } Vp886AbsSuppCfgType; |
| 99 | |
| 100 | /* Charge Pump protection modes */ |
| 101 | typedef enum { |
| 102 | VP886_CP_PROT_UV_SHUTDOWN = 0, |
| 103 | VP886_CP_PROT_CYCLE_SKIP = 1, |
| 104 | VP886_CP_PROT_DISABLED = 2 |
| 105 | } Vp886CPProtectionModeType; |
| 106 | |
| 107 | /* |
| 108 | * Vp886DeviceProfileType -------------------------------- Vp886DeviceProfileType |
| 109 | */ |
| 110 | typedef struct { |
| 111 | uint8 profVersion; |
| 112 | uint16 pcmClkRate; /**< Used to verify valid TX/RX Timeslot setting */ |
| 113 | uint8 devCfg; |
| 114 | uint8 devMode[2]; |
| 115 | uint8 swyv; |
| 116 | uint8 swzv; |
| 117 | uint8 swyLimit; |
| 118 | uint8 swzLimit; |
| 119 | uint8 io2Use; |
| 120 | bool lowVoltOverride; |
| 121 | uint8 dialPulseCorrection; |
| 122 | uint8 swCfg; |
| 123 | uint8 swOCC[2]; |
| 124 | uint8 blanking; |
| 125 | Vp886AbsSuppCfgType absSuppCfg; |
| 126 | uint8 adaptiveRingingMaxPower; |
| 127 | bool cpEnable; |
| 128 | Vp886CPProtectionModeType cpProtection; |
| 129 | uint8 vsw; |
| 130 | int8 vbhOffset; |
| 131 | int8 vbhOverhead; |
| 132 | uint8 swCtrlNormal; |
| 133 | uint8 swCtrlFreeRun; |
| 134 | uint8 swCtrlBattBackup; |
| 135 | uint8 batSelGpio; |
| 136 | bool vblUseMedTiming; |
| 137 | } Vp886DeviceProfileType; |
| 138 | |
| 139 | /* Vp886InitDeviceSM() state variable. Setting constant values so that we don't |
| 140 | need to check debug logs against the exact API version being used. */ |
| 141 | typedef enum { |
| 142 | VP886_INIT_DEVICE_SWITCHER_PREP = 2, |
| 143 | VP886_INIT_DEVICE_CFAIL_CHECK_PREP = 3, |
| 144 | VP886_INIT_DEVICE_CFAIL_CHECK = 4, |
| 145 | VP886_INIT_DEVICE_ZSI_DETECT = 19, |
| 146 | VP886_INIT_DEVICE_ENABLE_VREF = 5, |
| 147 | VP886_INIT_DEVICE_VREF_CHECK = 6, |
| 148 | VP886_INIT_DEVICE_CP_ENABLE = 7, |
| 149 | VP886_INIT_DEVICE_CH1_CH2_DISC = 9, |
| 150 | VP886_INIT_DEVICE_CP_CHECK = 8, |
| 151 | VP886_INIT_DEVICE_CH1_CH2_SW_ENABLE = 10, |
| 152 | VP886_INIT_DEVICE_CAL_CODEC_START = 13, |
| 153 | VP886_INIT_DEVICE_CAL_CODEC = 14, |
| 154 | VP886_INIT_DEVICE_SW_ENABLE = 11, |
| 155 | VP886_INIT_DEVICE_ALARM_CHECK = 12, |
| 156 | VP886_INIT_DEVICE_INIT_LINES = 15, |
| 157 | VP886_INIT_DEVICE_LONG_CAL = 16, |
| 158 | VP886_INIT_DEVICE_GEN_EVENT = 17, |
| 159 | VP886_INIT_DEVICE_COMPLETE = 18 |
| 160 | } Vp886InitDeviceStateType; |
| 161 | |
| 162 | /* Vp886CalCodecSM() state variable */ |
| 163 | typedef enum { |
| 164 | VP886_CAL_CODEC_START = 0, |
| 165 | VP886_CAL_CODEC_PREPARE, |
| 166 | VP886_CAL_CODEC_SADC, |
| 167 | VP886_CAL_CODEC_SWY_SENSE, |
| 168 | VP886_CAL_CODEC_SWZ_SENSE, |
| 169 | VP886_CAL_CODEC_TIP_SENSE, |
| 170 | VP886_CAL_CODEC_RING_SENSE, |
| 171 | VP886_CAL_CODEC_IO2_SENSE, |
| 172 | VP886_CAL_CODEC_VOC_SENSE, |
| 173 | VP886_CAL_CODEC_FLOOR, |
| 174 | VP886_CAL_CODEC_BATTERY, |
| 175 | VP886_CAL_CODEC_BATTERY_SENSE, |
| 176 | VP886_CAL_CODEC_BATTERY_SAT, |
| 177 | VP886_CAL_CODEC_BATTERY_LIMIT, |
| 178 | VP886_CAL_CODEC_DISCONNECT, |
| 179 | VP886_CAL_CODEC_LONGITUDINAL, |
| 180 | VP886_CAL_CODEC_SYNC, |
| 181 | VP886_CAL_CODEC_CONCLUDE, |
| 182 | VP886_CAL_CODEC_GEN_EVENT, |
| 183 | VP886_CAL_CODEC_COMPLETE, |
| 184 | VP886_CAL_CODEC_FAILED |
| 185 | } Vp886CalCodecStateType; |
| 186 | |
| 187 | /* CalCodec state variable */ |
| 188 | typedef enum { |
| 189 | VP886_SADC_INIT = 0, |
| 190 | VP886_SADC_ICAL_L, |
| 191 | VP886_SADC_ICAL_H, |
| 192 | VP886_SENSE_INIT, |
| 193 | VP886_SENSE_ICAL_L, |
| 194 | VP886_SENSE_ICAL_H, |
| 195 | VP886_VOC_S_INIT, |
| 196 | VP886_VOC_S_START, |
| 197 | VP886_VOC_S_ICAL_L, |
| 198 | VP886_VOC_S_ICAL_H, |
| 199 | VP886_FLOOR_INIT, |
| 200 | VP886_FLOOR_START, |
| 201 | VP886_FLOOR_LOW, |
| 202 | VP886_FLOOR_HIGH, |
| 203 | VP886_TRACKER_INIT, |
| 204 | VP886_TRACKER_VAB_START, |
| 205 | VP886_TRACKER_VAB_LOW, |
| 206 | VP886_TRACKER_VAB_HIGH, |
| 207 | VP886_TRACKER_VAS_LOW, |
| 208 | VP886_TRACKER_VAS_HIGH, |
| 209 | VP886_TRACKER_COMPUTE, |
| 210 | VP886_BAT_SENSE_INIT, |
| 211 | VP886_BAT_SENSE_LOW, |
| 212 | VP886_BAT_SENSE_HIGH, |
| 213 | VP886_BAT_SAT_INIT, |
| 214 | VP886_BAT_SAT_MEAS, |
| 215 | VP886_SW_LIM_INIT, |
| 216 | VP886_SW_LIM_LOW, |
| 217 | VP886_SW_LIM_HIGH, |
| 218 | VP886_LONG_INIT, |
| 219 | VP886_LONG_GET_MEAS, |
| 220 | VP886_LONG_GET_MEAS_RINGING |
| 221 | } Vp886CalCodecSubStateType; |
| 222 | |
| 223 | /* CalLine state variable */ |
| 224 | typedef enum { |
| 225 | VP886_SADC_VMODE_INIT = 0, |
| 226 | VP886_SADC_VMODE_VOFF, |
| 227 | VP886_SADC_VMODE_VCAL, |
| 228 | VP886_VADC_INIT, |
| 229 | VP886_VADC_ICAL_L, |
| 230 | VP886_VADC_ICAL_H, |
| 231 | VP886_VAB_INIT, |
| 232 | VP886_VAB_START, |
| 233 | VP886_VAB_ICAL_L, |
| 234 | VP886_VAB_ICAL_H, |
| 235 | VP886_IMT_INIT, |
| 236 | VP886_IMT_START, |
| 237 | VP886_IMT_LOW, |
| 238 | VP886_IMT_HIGH, |
| 239 | VP886_VOC_INIT, |
| 240 | VP886_VOC_START, |
| 241 | VP886_VOC_LOW, |
| 242 | VP886_VOC_HIGH, |
| 243 | VP886_VOC_BUFFER, |
| 244 | VP886_RINGING_INIT, |
| 245 | VP886_RINGING_START, |
| 246 | VP886_RINGING_LOW, |
| 247 | VP886_RINGING_HIGH, |
| 248 | VP886_RINGING_BUFFER, |
| 249 | VP886_HOOK_DET_INIT, |
| 250 | VP886_HOOK_DET_METALIC, |
| 251 | VP886_HOOK_DET_COMPARATOR, |
| 252 | VP886_HOOK_DET_COMPUTE, |
| 253 | VP886_GND_KEY_INIT, |
| 254 | VP886_GND_KEY_LONG, |
| 255 | VP886_GND_KEY_COMPARATOR, |
| 256 | VP886_GND_KEY_COMPUTE, |
| 257 | VP886_ABS_INIT, |
| 258 | VP886_ABS_SWY_START, |
| 259 | VP886_ABS_CHECK_ICAL, |
| 260 | VP886_ABS_SWY, |
| 261 | VP886_ABS_BSW_START, |
| 262 | VP886_ABS_BSW_LOW, |
| 263 | VP886_ABS_BSW_HIGH |
| 264 | } Vp886CalLineSubStateType; |
| 265 | |
| 266 | /* States for sense recalibration (Vp886QuickCalHandler()) */ |
| 267 | typedef enum { |
| 268 | VP886_QUICKCAL_INACTIVE = 0, |
| 269 | VP886_QUICKCAL_INIT, |
| 270 | VP886_QUICKCAL_SETUP_VA_VB_VAB, |
| 271 | VP886_QUICKCAL_READ_VA_VB_VAB, |
| 272 | VP886_QUICKCAL_SETUP_VABREV, |
| 273 | VP886_QUICKCAL_READ_VABREV, |
| 274 | VP886_QUICKCAL_SETUP_VABRING, |
| 275 | VP886_QUICKCAL_READ_VABRING, |
| 276 | VP886_QUICKCAL_FINISHED |
| 277 | } Vp886QuickCalStateType; |
| 278 | |
| 279 | typedef struct Vp886QuickCalDataType { |
| 280 | Vp886QuickCalStateType state; |
| 281 | uint16 timerId; |
| 282 | uint32 timerHandle; |
| 283 | uint16 sadcFlag; |
| 284 | bool externalCall; |
| 285 | } Vp886QuickCalDataType; |
| 286 | |
| 287 | /* Calibration registers scratch-pad */ |
| 288 | typedef struct { |
| 289 | uint8 dcFeed[VP886_R_DCFEED_LEN]; |
| 290 | uint8 sysConfig[VP886_R_SSCFG_LEN]; |
| 291 | uint8 ringGen[VP886_R_RINGGEN_LEN]; |
| 292 | uint8 icr1[VP886_R_ICR1_LEN]; |
| 293 | uint8 icr2[VP886_R_ICR2_LEN]; |
| 294 | uint8 icr3[VP886_R_ICR3_LEN]; |
| 295 | uint8 icr4[VP886_R_ICR4_LEN]; |
| 296 | uint8 icr5[VP886_R_ICR5_LEN]; |
| 297 | uint8 icr6[VP886_R_ICR6_LEN]; |
| 298 | uint8 srp[VP886_R_SWPARAM_LEN]; |
| 299 | uint8 devMode[VP886_R_DEVMODE_LEN]; |
| 300 | uint8 normCal[VP886_R_NORMCAL_LEN]; |
| 301 | uint8 revCal[VP886_R_REVCAL_LEN]; |
| 302 | uint8 indCal[VP886_R_INDCAL_LEN]; |
| 303 | uint8 opCond[VP886_R_OPCOND_LEN]; |
| 304 | uint8 opFunc[VP886_R_OPFUNC_LEN]; |
| 305 | uint8 loopSup[VP886_R_LOOPSUP_LEN]; |
| 306 | uint8 slacState[VP886_R_STATE_LEN]; |
| 307 | uint8 ioDir[VP886_R_IODIR_LEN]; |
| 308 | } Vp886RegPadType; |
| 309 | |
| 310 | /* Vp886CalLinecSM() state variable */ |
| 311 | typedef enum { |
| 312 | VP886_CAL_LINE_START, |
| 313 | VP886_CAL_LINE_VADC_ACTIVE_CAL, |
| 314 | VP886_CAL_LINE_SADC_VMODE_CAL, |
| 315 | VP886_CAL_LINE_VAB_SENSE_CAL, |
| 316 | VP886_CAL_LINE_IMT_CAL, |
| 317 | VP886_CAL_LINE_VOC_CAL, |
| 318 | VP886_CAL_LINE_RINGING_CAL, |
| 319 | VP886_CAL_LINE_HOOK_DETECTOR_CAL, |
| 320 | VP886_CAL_LINE_GROUND_KEY_CAL, |
| 321 | VP886_CAL_LINE_ABS_CAL, |
| 322 | VP886_CAL_LINE_RESTORE, |
| 323 | VP886_CAL_LINE_GEN_EVENT, |
| 324 | VP886_CAL_LINE_COMPLETE, |
| 325 | VP886_CAL_LINE_FAILED |
| 326 | } Vp886CalLineStateType; |
| 327 | |
| 328 | /* IMPORTANT: Make sure to update the "stateInt" member of the device object if |
| 329 | the size of this type changes. There is no instance of this type itself. */ |
| 330 | typedef enum { |
| 331 | VP886_SYS_CAL_COMPLETE = 0x0001, /**< Set when the system calibration structure has been initialied */ |
| 332 | /* This value is set when either Device Calibration (VpInitDevice()/VpCalCodec() |
| 333 | completes successfully, or when loaded values by Apply System Coeff. After |
| 334 | VpInitDevice() this should only be NOT SET if device calibration failed or |
| 335 | if null was passed to Apply System Coeff. */ |
| 336 | VP886_DEVICE_CAL_COMPLETE = 0x0002, |
| 337 | |
| 338 | VP886_DEVICE_ICAL_L_IN_USE = 0x0004, /* Low calibration current in use */ |
| 339 | VP886_DEVICE_ICAL_H_IN_USE = 0x0008, /* High calibration current in use */ |
| 340 | |
| 341 | VP886_FORCE_FREE_RUN = 0x0010, /**< Set when app calls VpFreeRun() (start), cleared when called with stop. |
| 342 | * This prevents the VP-API-II from automatically exiting free run mode |
| 343 | * upon PCLK recovery. |
| 344 | */ |
| 345 | VP886_ZSI_DETECTED = 0x0020, |
| 346 | VP886_SHARED_SUPPLY = 0x0040, |
| 347 | VP886_CONVERT_DEVICE_TYPE = 0x0080, |
| 348 | VP886_FREE_RUN = 0x0100, |
| 349 | VP886_BATTERY_BACKUP = 0x0200 |
| 350 | } Vp886DeviceStateIntType; |
| 351 | |
| 352 | /* Union of basic results types for Vp886. Does not include linetest, |
| 353 | * low level cmd, or result types not supported by Vp886. */ |
| 354 | typedef union { |
| 355 | VpLoopCondResultsType getLoopCond; /* VP_LINE_EVID_RD_LOOP */ |
| 356 | VpDeviceIoAccessDataType deviceIoAccess; /* VP_DEV_EVID_IO_ACCESS_CMP */ |
| 357 | VpLineIoAccessType lineIoAccess; /* VP_LINE_EVID_LINE_IO_RD_CMP */ |
| 358 | } Vp886BasicResultsType; |
| 359 | |
| 360 | #define VP886_MAX_BRANCH_DEPTH 5 |
| 361 | typedef struct Vp886SeqDataType { |
| 362 | VpProfilePtrType pActiveCadence; /* Currently Active Cadence */ |
| 363 | VpProfilePtrType pCurrentPos; /* Current position in profile */ |
| 364 | |
| 365 | VpCadenceStatusType status; |
| 366 | |
| 367 | uint8 index; /* Index in the the cadence table */ |
| 368 | uint8 length; /* Length of executable cadence instructions */ |
| 369 | |
| 370 | uint8 branchCount[VP886_MAX_BRANCH_DEPTH]; |
| 371 | uint8 branchIdx[VP886_MAX_BRANCH_DEPTH]; |
| 372 | uint8 branchDepth; |
| 373 | |
| 374 | uint8 toneType; |
| 375 | |
| 376 | VpLineStateType lineState; /* Current line state set by the cadence */ |
| 377 | |
| 378 | /* Howler data */ |
| 379 | uint8 regData[VP886_R_SIGAB_LEN]; |
| 380 | uint16 startLevel; |
| 381 | uint16 stopLevel; |
| 382 | uint16 levelStep; |
| 383 | } Vp886SeqDataType; |
| 384 | |
| 385 | /* Contains the information needed to process SendSignal sequences */ |
| 386 | typedef struct { |
| 387 | VpSendSignalType type; |
| 388 | bool active; |
| 389 | struct { |
| 390 | int8 voltage; |
| 391 | uint16 onTime; |
| 392 | uint16 offTime; |
| 393 | uint8 cycles; |
| 394 | bool on; |
| 395 | } msgWait; |
| 396 | } Vp886SendSignalDataType; |
| 397 | |
| 398 | /* Contains the information needed to process metering sequences */ |
| 399 | typedef struct { |
| 400 | bool active; |
| 401 | bool on; |
| 402 | uint16 onTime; /* 10ms units */ |
| 403 | uint16 offTime; /* 10ms units */ |
| 404 | uint16 remaining; |
| 405 | uint16 completed; |
| 406 | bool abort; |
| 407 | } Vp886MeteringDataType; |
| 408 | |
| 409 | typedef enum { |
| 410 | VP886_CID_ST_NEW_INSTR = 0, |
| 411 | VP886_CID_ST_ALERT_TONE = 100, |
| 412 | VP886_CID_ST_SILENT_INTERVAL = 200, |
| 413 | VP886_CID_ST_SILENT_HOOK_MASK_INTERVAL = 300, |
| 414 | VP886_CID_ST_DETECT_INTERVAL = 400, |
| 415 | VP886_CID_ST_MARK_OR_SEIZURE = 500, |
| 416 | VP886_CID_ST_MARK_OR_SEIZURE_ENDING = 501, |
| 417 | VP886_CID_ST_MESSAGE_FSK = 600, |
| 418 | VP886_CID_ST_MESSAGE_FSK_MARKOUT = 601, |
| 419 | VP886_CID_ST_MESSAGE_FSK_ENDING = 602, |
| 420 | VP886_CID_ST_MESSAGE_DTMF = 700 |
| 421 | } Vp886CidStateType; |
| 422 | |
| 423 | #define VP886_CID_BUFFER_SIZE 32 |
| 424 | typedef struct { |
| 425 | bool active; |
| 426 | VpProfilePtrType pProf; |
| 427 | uint8 profIdx; |
| 428 | Vp886CidStateType state; |
| 429 | uint8 msgBuf[VP886_CID_BUFFER_SIZE]; /* Circular message data buffer */ |
| 430 | uint8 msgLen; /* Number of bytes currently valid in buffer */ |
| 431 | uint8 msgIdx; /* Index of oldest valid byte in buffer */ |
| 432 | uint8 checksum; |
| 433 | uint16 markOrSeizureBytes; |
| 434 | VpDigitType detectDigit1; |
| 435 | VpDigitType detectDigit2; |
| 436 | bool digitDetected; |
| 437 | bool fskEnabled; |
| 438 | bool dtmfEnabled; |
| 439 | bool mute; |
| 440 | bool needData; |
| 441 | } Vp886CidDataType; |
| 442 | |
| 443 | typedef struct { |
| 444 | int16 gain; |
| 445 | int16 offset; |
| 446 | } Vp886CalGainOffsetType; |
| 447 | |
| 448 | /* Common calibration structure */ |
| 449 | typedef struct { |
| 450 | /* Senses calibration -> accurate ADC readings */ |
| 451 | Vp886CalGainOffsetType sadc; |
| 452 | Vp886CalGainOffsetType sadcVMode; |
| 453 | Vp886CalGainOffsetType vadcActive; |
| 454 | Vp886CalGainOffsetType swySense; |
| 455 | Vp886CalGainOffsetType swzSense; |
| 456 | Vp886CalGainOffsetType tipSense; |
| 457 | Vp886CalGainOffsetType ringSense; |
| 458 | Vp886CalGainOffsetType io2Sense; |
| 459 | Vp886CalGainOffsetType vabSenseNormal; |
| 460 | Vp886CalGainOffsetType vabSenseReverse; |
| 461 | Vp886CalGainOffsetType vabSenseRinging; |
| 462 | |
| 463 | /* Features calibration -> the device generates accurate signals */ |
| 464 | /* ILA */ |
| 465 | Vp886CalGainOffsetType ilaNormal; |
| 466 | Vp886CalGainOffsetType ilaReverse; |
| 467 | /* VOC */ |
| 468 | Vp886CalGainOffsetType vocNormal; |
| 469 | Vp886CalGainOffsetType vocReverse; |
| 470 | Vp886CalGainOffsetType vocBuffer; |
| 471 | /* Ringing */ |
| 472 | Vp886CalGainOffsetType ringingGenerator; |
| 473 | Vp886CalGainOffsetType ringingBuffer; |
| 474 | /* VOC, Ringing shared */ |
| 475 | Vp886CalGainOffsetType vocSenseNormal; |
| 476 | /* Fixed Battery voltage */ |
| 477 | Vp886CalGainOffsetType fixedBat; |
| 478 | Vp886CalGainOffsetType batterySense; |
| 479 | /* Longitudinal point */ |
| 480 | Vp886CalGainOffsetType longActive; |
| 481 | Vp886CalGainOffsetType longRinging; |
| 482 | Vp886CalGainOffsetType reserved_1; |
| 483 | Vp886CalGainOffsetType reserved_2; |
| 484 | /* Hook Detector (1 offset, 4 gains) */ |
| 485 | Vp886CalGainOffsetType hookLPM; |
| 486 | Vp886CalGainOffsetType hookReverse; |
| 487 | Vp886CalGainOffsetType hookNormal; |
| 488 | /* Battery saturation (offset only) */ |
| 489 | Vp886CalGainOffsetType batSat; |
| 490 | /* Switcher limit */ |
| 491 | Vp886CalGainOffsetType swLimit50V; |
| 492 | Vp886CalGainOffsetType swLimit100V; |
| 493 | /* Ground Key detector */ |
| 494 | Vp886CalGainOffsetType gndKeyLong; |
| 495 | /* Capacitance test tip/ring offsets (pF) */ |
| 496 | int32 tipCapCal; |
| 497 | int32 ringCapCal; |
| 498 | } Vp886CmnCalDeviceDataType; |
| 499 | |
| 500 | /* Tracker calibration structure */ |
| 501 | typedef struct { |
| 502 | /* Tracking battery */ |
| 503 | Vp886CalGainOffsetType trackerVabNormal; |
| 504 | Vp886CalGainOffsetType trackerVabReverse; |
| 505 | Vp886CalGainOffsetType trackerVasNormal; |
| 506 | Vp886CalGainOffsetType trackerVasReverse; |
| 507 | Vp886CalGainOffsetType reserved_5; |
| 508 | Vp886CalGainOffsetType reserved_6; |
| 509 | Vp886CalGainOffsetType trackerBatSense; |
| 510 | } Vp886TrkCalDeviceDataType; |
| 511 | |
| 512 | /* ABS calibration structure */ |
| 513 | typedef struct { |
| 514 | Vp886CalGainOffsetType absVabNormal; |
| 515 | Vp886CalGainOffsetType absVabReverse; |
| 516 | Vp886CalGainOffsetType reserved_7; |
| 517 | Vp886CalGainOffsetType reserved_8; |
| 518 | Vp886CalGainOffsetType reserved_5; |
| 519 | Vp886CalGainOffsetType reserved_6; |
| 520 | Vp886CalGainOffsetType absBatSense; |
| 521 | } Vp886AbsCalDeviceDataType; |
| 522 | |
| 523 | typedef struct { |
| 524 | bool valid; |
| 525 | Vp886CmnCalDeviceDataType cmn; |
| 526 | union { |
| 527 | Vp886TrkCalDeviceDataType trk; |
| 528 | Vp886AbsCalDeviceDataType abs; |
| 529 | } spe; |
| 530 | } Vp886CalDeviceDataType; |
| 531 | |
| 532 | typedef enum { |
| 533 | VP886_HOWLER_ST_ALIGNMENT = 0, |
| 534 | VP886_HOWLER_ST_AMP_STEPPING_UK_AUS = 100, |
| 535 | VP886_HOWLER_ST_AMP_STEPPING_NTT = 200 |
| 536 | } Vp886HowlerStateType; |
| 537 | |
| 538 | typedef enum { |
| 539 | VP886_GNDFLTPROT_ST_INACTIVE = 0, |
| 540 | VP886_GNDFLTPROT_ST_GKEY_DETECTED = 1, |
| 541 | VP886_GNDFLTPROT_ST_DISCONNECT = 2, |
| 542 | VP886_GNDFLTPROT_ST_TIP_OPEN = 3, |
| 543 | VP886_GNDFLTPROT_ST_RING_OPEN = 4 |
| 544 | } Vp886GroundFaultProtStateType; |
| 545 | |
| 546 | typedef enum { |
| 547 | VP886_GNDFLTPROT_INP_TIMER = 0, |
| 548 | VP886_GNDFLTPROT_INP_GKEY_DET = 1, |
| 549 | VP886_GNDFLTPROT_INP_GKEY_REL = 2, |
| 550 | VP886_GNDFLTPROT_INP_LINESTATE = 3, |
| 551 | VP886_GNDFLTPROT_INP_STOP = 4 |
| 552 | } Vp886GroundFaultProtInputType; |
| 553 | |
| 554 | typedef struct { |
| 555 | Vp886GroundFaultProtStateType state; |
| 556 | bool faultDeclared; |
| 557 | bool settingDisconnect; |
| 558 | uint16 iterations; |
| 559 | } Vp886GroundFaultProtDataType; |
| 560 | |
| 561 | typedef enum { |
| 562 | VP886_ABS_POWER_REQ_LOW = 0, |
| 563 | VP886_ABS_POWER_REQ_MED = 1, |
| 564 | VP886_ABS_POWER_REQ_HIGH = 2, |
| 565 | VP886_ABS_POWER_REQ_OFF = 3 |
| 566 | } Vp886AbsPowerReqType; |
| 567 | |
| 568 | typedef struct { |
| 569 | bool sampling; |
| 570 | VpDigitType currentDigit; |
| 571 | VpDtmfDetectDataType detectData; |
| 572 | uint8 sadcCtrl[VP886_R_SADC_LEN]; |
| 573 | bool useVadc; |
| 574 | bool initialSample; |
| 575 | } Vp886DtmfType; |
| 576 | |
| 577 | typedef enum { |
| 578 | VP886_RINGSYNC_STATE_IDLE = 0, |
| 579 | VP886_RINGSYNC_STATE_PAUSING = 1, /* Line which is pausing its ringing */ |
| 580 | VP886_RINGSYNC_STATE_DELAYING = 2, /* Line which is delaying its ringing */ |
| 581 | VP886_RINGSYNC_STATE_FINISHING_PAUSE = 3, |
| 582 | VP886_RINGSYNC_STATE_FINISHING_DELAY = 4 |
| 583 | } Vp886RingSyncStateType; |
| 584 | |
| 585 | typedef enum { |
| 586 | VP886_IO_CAPABILITY_TWO_PER_CH = 0, /* 2 IOs per channel */ |
| 587 | VP886_IO_CAPABILITY_NONE = 1, /* No IOs */ |
| 588 | VP886_IO_CAPABILITY_CH0_IO2 = 2 /* IO2 on channel 0 only */ |
| 589 | } Vp886IoCapabilityType; |
| 590 | |
| 591 | /* |
| 592 | * Vp886LineObjectType -------------------------------------------------------- Vp886LineObjectType |
| 593 | */ |
| 594 | typedef struct { |
| 595 | uint8 channelId; |
| 596 | VpLineIdType lineId; |
| 597 | VpTermType termType; |
| 598 | uint8 ecVal; |
| 599 | |
| 600 | bool isFxs; |
| 601 | |
| 602 | /* These flags are used by Vp886ReadyStatus() to decide whether a line can be |
| 603 | accessed (i.e. is not "busy"). This is a bitmask of |
| 604 | Vp886LineBusyFlagsType values. */ |
| 605 | uint16 busyFlags; |
| 606 | |
| 607 | VpApiIntLineStateType lineState; |
| 608 | |
| 609 | /* Cache for all line option settings */ |
| 610 | Vp886LineOptionsCacheType options; |
| 611 | |
| 612 | /* Set of VP_CSLAC_____ values defining which line conditions we are |
| 613 | currently ignoring (such as VP_CSLAC_HOOK | VP_CSLAC_GKEY) */ |
| 614 | uint16 detectMasks; |
| 615 | |
| 616 | /* State variable for the Vp886CalLine state machine. This is used |
| 617 | inside the Vp886CalLineSM function to keep track of the state |
| 618 | and specify which state (case) of the switch statement to enter. */ |
| 619 | Vp886CalLineStateType calLineState; |
| 620 | Vp886CalLineSubStateType calLineSubState; |
| 621 | |
| 622 | /* Info for the quick recalibration routine. */ |
| 623 | Vp886QuickCalDataType quickCal; |
| 624 | |
| 625 | /* Remember if the calibration registers have been programmed. They need to |
| 626 | be cleared before re-running VpCalLine(). */ |
| 627 | bool calRegsProgrammed; |
| 628 | |
| 629 | /* Vp886GetLoopCond() backups */ |
| 630 | uint16 getLoopCondHandle; |
| 631 | bool getLoopCondRegsCached; |
| 632 | uint8 vadcConvConf[VP886_R_VADC_LEN]; |
| 633 | uint8 getLoopIcr2[VP886_R_ICR2_LEN]; |
| 634 | uint8 getLoopIcr3[VP886_R_ICR3_LEN]; |
| 635 | uint8 getLoopIcr4[VP886_R_ICR4_LEN]; |
| 636 | |
| 637 | /* Pulse decoding state data */ |
| 638 | VpPulseDecodeDataType pulseDecodeData; |
| 639 | |
| 640 | /* Line Topology Info */ |
| 641 | VpLineTopologyType lineTopology; |
| 642 | |
| 643 | #ifdef VP_CSLAC_SEQ_EN |
| 644 | /* Sequencer state information */ |
| 645 | Vp886SeqDataType cadence; |
| 646 | Vp886HowlerStateType howlerState; |
| 647 | uint16 howlerLevel; |
| 648 | |
| 649 | /* Ringing cadence set by VpInitRing() */ |
| 650 | VpProfilePtrType pRingingCadence; |
| 651 | |
| 652 | /* Caller ID state information */ |
| 653 | Vp886CidDataType cid; |
| 654 | |
| 655 | /* SendSignal state information */ |
| 656 | Vp886SendSignalDataType sendSignal; |
| 657 | |
| 658 | /* Metering state information */ |
| 659 | Vp886MeteringDataType metering; |
| 660 | #endif /* VP_CSLAC_SEQ_EN */ |
| 661 | |
| 662 | /* Keeps track of whether the internal test termination is applied */ |
| 663 | bool intTestTermApplied; |
| 664 | |
| 665 | bool ringExitInProgress; |
| 666 | |
| 667 | /* State to end up in after the ring exit polrev workaround */ |
| 668 | VpLineStateType ringExitCleanupState; |
| 669 | |
| 670 | Vp886RingSyncStateType ringSyncState; |
| 671 | |
| 672 | /* Stores the ringing state that was requested but delayed for the channel |
| 673 | that wants to start ringing. */ |
| 674 | VpLineStateType ringSyncLineState; |
| 675 | |
| 676 | /* Used for VP_OPTION_ID_RINGTRIP_CONFIRM */ |
| 677 | struct { |
| 678 | bool confirming; |
| 679 | bool glitchCheck; |
| 680 | uint16 lastHookTimestamp; |
| 681 | } ringTripConfirm; |
| 682 | |
| 683 | #if (VP886_USER_TIMERS > 0) |
| 684 | /* Number of currently running user timers. Used to implement a limit |
| 685 | of VP886_USER_TIMERS */ |
| 686 | int16 userTimers; |
| 687 | #endif |
| 688 | |
| 689 | #ifdef VP886_INCLUDE_TESTLINE_CODE |
| 690 | VpRelayControlType relayState; |
| 691 | #endif |
| 692 | |
| 693 | /* Ringing parameters from the ringing profile, in register format. */ |
| 694 | int16 ringBias; |
| 695 | int16 ringAmplitude; |
| 696 | int16 ringAmplitudeCal; |
| 697 | int16 ringFrequency; |
| 698 | bool ringSine; |
| 699 | int16 fixedRingBat; |
| 700 | |
| 701 | /* Ringing mode: balanced (FALSE) or unbalanced (TRUE) */ |
| 702 | bool unbalancedRinging; |
| 703 | |
| 704 | /* Ring trip detection algorithm. Saved from the ringing profile |
| 705 | so that we can restore it after a msg waiting pulse signal or |
| 706 | any other potential operation that changes it on the fly */ |
| 707 | uint8 ringTripAlg; |
| 708 | |
| 709 | /* Number of cycles for ring trip (1 or 2), saved so that we can subtract |
| 710 | it from the ring trip confirm timer */ |
| 711 | uint8 ringTripCycles; |
| 712 | |
| 713 | /* Bit mask of the tones programmed by the most recent tone profile. |
| 714 | This is used to restrict which tones are enabled in VpSetLineTone() and |
| 715 | by cadence commands. */ |
| 716 | uint8 toneGens; |
| 717 | |
| 718 | /* Set based on the DC profile, this will determine whether |
| 719 | groundkey interrupts are interpreted as groundkey events (for |
| 720 | ground start applications) or DC fault events (loop start). */ |
| 721 | bool reportDcFaults; |
| 722 | |
| 723 | Vp886GroundFaultProtDataType gndFltProt; |
| 724 | |
| 725 | /* Floor voltage in 1V steps */ |
| 726 | uint8 floorVoltage; |
| 727 | |
| 728 | /* Target VOC in 1V steps */ |
| 729 | uint8 targetVoc; |
| 730 | |
| 731 | uint16 gxBase; /**< Cached GX register, in 2.14 int format */ |
| 732 | uint16 gxUserLevel; /**< User specified relative GX level (2.14) */ |
| 733 | uint16 grBase; /**< Cached GR register, in 2.14 int format */ |
| 734 | uint16 grUserLevel; /**< User specified relative GR level (2.14) */ |
| 735 | |
| 736 | /* Most recent non-QUIET settings for the ABS_GAIN option to support |
| 737 | VP_OPTION_ABS_GAIN_RESTORE. */ |
| 738 | int16 absGxRestoreOption; |
| 739 | int16 absGrRestoreOption; |
| 740 | uint8 absGxRestoreReg[VP886_R_GX_LEN]; |
| 741 | uint8 absGrRestoreReg[VP886_R_GR_LEN]; |
| 742 | |
| 743 | /* Event results for VpSetRelGain() */ |
| 744 | VpRelGainResultsType setRelGainResults; |
| 745 | |
| 746 | /* Keep track of IO2 status when it's configured as an interrupt */ |
| 747 | bool io2State; |
| 748 | |
| 749 | /* Set to TRUE if we're using the ila_fdrng bit of ICR2 to enable |
| 750 | ringing current limits below 50mA. This changes the way we have to |
| 751 | read the ringing current limit value for VP_OPTION_ID_RINGING_PARAMS. |
| 752 | It also changes how the VADC reads current, so ringing power management |
| 753 | and line test need to be aware of it. */ |
| 754 | bool lowIlr; |
| 755 | |
| 756 | /* Saved base value of RTTH. The low ILR workaround will double |
| 757 | the base value, but will be capped at the max register value, so we |
| 758 | need to remember the original to be able to restore it. */ |
| 759 | uint8 rtth; |
| 760 | |
| 761 | /* Data for VP_QUERY_ID_SW_DUTY_CYCLE */ |
| 762 | struct { |
| 763 | /* Prevent it from being run again if it is already in progress */ |
| 764 | bool inProgress; |
| 765 | |
| 766 | /* Keep track of initial switcher mode, line state, and line conditions |
| 767 | (hook, gkey, etc) so that we can set the 'stateChanged' flag in the |
| 768 | results if anything changes */ |
| 769 | uint8 switcherMode; |
| 770 | VpLineStateType lineState; |
| 771 | uint16 lineCondition; |
| 772 | |
| 773 | /* A place to store the results so that we can read the switcher on-time |
| 774 | register in VpGetEvent() rather than waiting for VpGetResults() */ |
| 775 | VpSwDutyCycleType result; |
| 776 | } swDutyCycle; |
| 777 | |
| 778 | /* Handle for VP_QUERY_ID_TEMPERATURE */ |
| 779 | uint16 queryTempHandle; |
| 780 | |
| 781 | /* Result for VP_QUERY_ID_TEMPERATURE */ |
| 782 | int16 queryTempResult; |
| 783 | |
| 784 | /* Flag and value for mid battery compensation, to set the 60V clamp |
| 785 | calibration to help with onhook detection when using a mid battery below |
| 786 | 60V (such as 48V) */ |
| 787 | bool midBatCompEnable; |
| 788 | uint8 midBatCompValue; |
| 789 | |
| 790 | #ifdef VP886_INCLUDE_DTMF_DETECT |
| 791 | /* Flags and data for DTMF detection */ |
| 792 | Vp886DtmfType dtmf; |
| 793 | #endif /* VP886_INCLUDE_DTMF_DETECT */ |
| 794 | |
| 795 | #ifdef VP_HIGH_GAIN_MODE_SUPPORTED |
| 796 | bool inHighGainMode; |
| 797 | struct { |
| 798 | uint8 icr1[VP886_R_ICR1_LEN]; |
| 799 | uint8 icr2[VP886_R_ICR2_LEN]; |
| 800 | uint8 icr3[VP886_R_ICR3_LEN]; |
| 801 | uint8 icr4[VP886_R_ICR4_LEN]; |
| 802 | uint8 dcFeed[VP886_R_DCFEED_LEN]; |
| 803 | uint8 vpGain[VP886_R_VPGAIN_LEN]; |
| 804 | uint8 grValue[VP886_R_GR_LEN]; |
| 805 | uint8 rValue[VP886_R_R_FILT_LEN]; |
| 806 | uint8 disn[VP886_R_DISN_LEN]; |
| 807 | uint8 opFunc[VP886_R_OPFUNC_LEN]; |
| 808 | uint8 swParam[VP886_R_SWPARAM_LEN]; |
| 809 | } highGainCache; |
| 810 | #endif /* VP_HIGH_GAIN_MODE_SUPPORTED */ |
| 811 | |
| 812 | /* Cache for line-specific registers */ |
| 813 | struct { |
| 814 | uint8 sysState[VP886_R_STATE_LEN]; |
| 815 | uint8 loopSup[VP886_R_LOOPSUP_LEN]; |
| 816 | uint8 opCond[VP886_R_OPCOND_LEN]; |
| 817 | uint8 opFunc[VP886_R_OPFUNC_LEN]; |
| 818 | uint8 swParam[VP886_R_SWPARAM_LEN]; |
| 819 | uint8 calCtrl[VP886_R_CALCTRL_LEN]; |
| 820 | uint8 icr1[VP886_R_ICR1_LEN]; |
| 821 | uint8 icr2[VP886_R_ICR2_LEN]; |
| 822 | uint8 icr3[VP886_R_ICR3_LEN]; |
| 823 | uint8 icr4[VP886_R_ICR4_LEN]; |
| 824 | uint8 dcFeed[VP886_R_DCFEED_LEN]; |
| 825 | uint8 ssCfg[VP886_R_SSCFG_LEN]; |
| 826 | uint8 indCal[VP886_R_INDCAL_LEN]; |
| 827 | uint8 normCal[VP886_R_NORMCAL_LEN]; |
| 828 | uint8 revCal[VP886_R_REVCAL_LEN]; |
| 829 | uint8 ringCal[VP886_R_RINGCAL_LEN]; |
| 830 | uint8 batCal[VP886_R_BATCAL_LEN]; |
| 831 | uint8 ringDelay[VP886_R_RINGDELAY_LEN]; |
| 832 | } registers; |
| 833 | |
| 834 | |
| 835 | #ifdef VP886_INCLUDE_TESTLINE_CODE |
| 836 | /* Testing structure */ |
| 837 | Vp886TestInfoType testInfo; |
| 838 | |
| 839 | /* Test results structure */ |
| 840 | VpTestResultType testResults; |
| 841 | #endif |
| 842 | |
| 843 | /* Setting this flag to TRUE will disable all automatic line state changes |
| 844 | performed by the API for this line. */ |
| 845 | bool inLineTest; |
| 846 | |
| 847 | #ifdef VP886_INCLUDE_ADAPTIVE_RINGING |
| 848 | |
| 849 | /* Data structure for ringing thermal management algorithms */ |
| 850 | RingPowerAdaptModuleType ringPowerAdapt; |
| 851 | |
| 852 | /* Running Thermal Adaptive Ringing mode: */ |
| 853 | bool thermalRinging; |
| 854 | |
| 855 | /* Ringing cadence started */ |
| 856 | bool startRingingCadence; |
| 857 | |
| 858 | /* To detect customer cadenced ringing "standby => ringing -> oht -> ringing..." */ |
| 859 | bool wasStandby; |
| 860 | #endif |
| 861 | |
| 862 | #ifdef VP_DEBUG |
| 863 | /* For runtime enabling of debug output: */ |
| 864 | uint32 debugSelectMask; |
| 865 | #endif /* VP_DEBUG */ |
| 866 | |
| 867 | /* Reference ringing battery voltage value requested via ringing profile |
| 868 | or the VP_OPTION_ID_RINGING_PARAMS option applies to tracking devices only */ |
| 869 | uint8 refRingingBatV; |
| 870 | |
| 871 | } Vp886LineObjectType; |
| 872 | |
| 873 | |
| 874 | typedef enum { |
| 875 | VP_NORMAL, |
| 876 | VP_POLREV, |
| 877 | VP_RINGING |
| 878 | } VpPolarityType; |
| 879 | /* |
| 880 | * Vp886DeviceObjectType ------------------------------------------------------ Vp886DeviceObjectType |
| 881 | */ |
| 882 | typedef struct { |
| 883 | /* Device identifier set by the application -- passed to the HAL */ |
| 884 | VpDeviceIdType deviceId; |
| 885 | |
| 886 | /* Silicon RCN/PCN and number of channels supported */ |
| 887 | VpDeviceStaticInfoType staticInfo; |
| 888 | |
| 889 | /* IO capabilities of this device */ |
| 890 | Vp886IoCapabilityType ioCapability; |
| 891 | |
| 892 | /* Weak attempt to put everything that changes during run-time into a |
| 893 | single structure. Good idea in principle, but in practice the devices |
| 894 | are too dis-similar to share many common structures. |
| 895 | This holds the "last channel checked" event information, clock fault, |
| 896 | and battery fault. */ |
| 897 | VpDeviceDynamicInfoType dynamicInfo; |
| 898 | |
| 899 | /* Variety of common device level status such as init/not init, init in |
| 900 | progress, test buffer read y/n?, etc.. Internally used by the VP-API-II |
| 901 | to communicate device state. |
| 902 | This is a bit-mask of VpDeviceBusyFlagsType values */ |
| 903 | uint16 busyFlags; |
| 904 | |
| 905 | /* Indicates whether an interrupt has been reported by the system service |
| 906 | layer. Used for backward compatibility with VpApiTick/VpVirtualISR */ |
| 907 | bool pendingInterrupt; |
| 908 | |
| 909 | /* Similar to common device level status, this is for 886 specific type of |
| 910 | device level information. |
| 911 | This is a bit-mask of Vp886DeviceStateIntType values */ |
| 912 | uint16 stateInt; |
| 913 | |
| 914 | /* EC value to be used when a device context is passed to Vp886SlacRegWrite, |
| 915 | Vp886SlacRegRead, or Vp886SlacBufSend. During normal operation, this |
| 916 | should be set to VP886_EC_GLOBAL. The exception is when a routine |
| 917 | within VpInitDevice() needs to write or read a channel register. Since |
| 918 | there is no requirement to have line contexts/objects defined at the time |
| 919 | of InitDevice, we can't pass a line context to our register write/read |
| 920 | functions. To access channel registers, set this value to VP886_EC_1 or |
| 921 | VP886_EC_2, do the command using the device context, and then set this |
| 922 | back to VP886_EC_GLOBAL. */ |
| 923 | uint8 ecVal; |
| 924 | |
| 925 | /* Flag indicates that a function which generates results has been called, |
| 926 | but VpGetResults() has not been called. The results are not necessarily |
| 927 | ready, but no more result-generating functions can run. This does not |
| 928 | apply to linetest results, which are handled per-line. */ |
| 929 | bool getResultsRequired; |
| 930 | |
| 931 | /* Union storage for a single basic (non-linetest) result */ |
| 932 | Vp886BasicResultsType basicResults; |
| 933 | |
| 934 | /* Device event queue */ |
| 935 | Vp886EventQueueType eventQueue; |
| 936 | |
| 937 | /* We cache the device timestamp so that we do not end up reading it |
| 938 | multiple times in quick succession. We use the flag |
| 939 | timestampValid so that Vp886GetTimestamp can decide whether to read |
| 940 | from the device or the cached value. This flag is set FALSE at the |
| 941 | beginning/end of each critical section, and TRUE when Vp886GetTimestamp |
| 942 | reads the register. */ |
| 943 | uint16 timestamp; |
| 944 | bool timestampValid; |
| 945 | |
| 946 | /* Count of timestamp rollovers that can be used to support long-duration |
| 947 | timers. These two variables are used together to keep the timestamp |
| 948 | and rollover count in sync. See Vp886GetTimestamp() for details */ |
| 949 | uint16 rolloverCount; |
| 950 | int32 rolloverBuffer; |
| 951 | |
| 952 | /* When pushing an event into the event, we may need to force an interrupt |
| 953 | to prompt the application to call VpGetEvent. If we are already in |
| 954 | a VpGetEvent call when pushing the event, there is no need to force the |
| 955 | interrupt. This flag is set at the beginning of Vp886GetEvent, and |
| 956 | cleared at the end. */ |
| 957 | bool inGetEvent; |
| 958 | |
| 959 | /* Indicates whether we still have a signaling register read remaining to |
| 960 | be processed in VpGetEvent(). This is useful for determining if we need |
| 961 | to force an interrupt to update status information when a detector mask |
| 962 | ends */ |
| 963 | bool sigregReadPending; |
| 964 | |
| 965 | struct { |
| 966 | /* Count of SPI errors for VP_DEVICE_OPTION_ID_SPI_ERROR_CTRL. */ |
| 967 | uint16 count; |
| 968 | /* If the SPI error mode is BLOCK and the count exceeds the specified |
| 969 | threshold, this flag will be set to TRUE and will block most API |
| 970 | calls */ |
| 971 | bool block; |
| 972 | /* This flag is set when a SPI error is detected to indicate that we |
| 973 | should send NOOPs to clear the MPI buffer before the next transaction */ |
| 974 | bool clearMpi; |
| 975 | /* When VpGetEvent() returns a SPI error event, we want to break out of |
| 976 | the application-side "while(VpGetEvent==TRUE)" loop. This flag will |
| 977 | be set to cause the next VpGetEvent to return FALSE without reading |
| 978 | the sigreg. */ |
| 979 | bool skipGetEvent; |
| 980 | } spiError; |
| 981 | |
| 982 | /* Keep track of critical section depth. This is currently only used to |
| 983 | generate warnings if it goes above 1 (indicating nested critical |
| 984 | sections) or below 0. */ |
| 985 | uint8 criticalDepth; |
| 986 | |
| 987 | #define VP886_TIMER_QUEUE_API_SIZE 8 |
| 988 | #if defined(VP886_USER_TIMERS) |
| 989 | #define VP886_TIMER_QUEUE_SIZE (VP886_TIMER_QUEUE_API_SIZE + VP886_USER_TIMERS) |
| 990 | #else |
| 991 | #define VP886_TIMER_QUEUE_SIZE (VP886_TIMER_QUEUE_API_SIZE) |
| 992 | #endif |
| 993 | /* Software timer queue, see vp_timer_queue.c/h */ |
| 994 | VpTimerQueueInfoType timerQueueInfo; |
| 995 | VpTimerQueueNodeType timerQueueNodes[VP886_TIMER_QUEUE_SIZE]; |
| 996 | |
| 997 | #if (VP886_USER_TIMERS > 0) |
| 998 | /* Number of currently running user timers. Used to implement a limit |
| 999 | of VP886_USER_TIMERS */ |
| 1000 | int16 userTimers; |
| 1001 | #endif |
| 1002 | |
| 1003 | /* Cache for all device option settings */ |
| 1004 | Vp886DevOptionsCacheType options; |
| 1005 | |
| 1006 | /* Soft values from the device profile that are used throughout the VP-API-II |
| 1007 | (not only in Init). Note that other values may be provided by the device |
| 1008 | profile, but are stored in other ways generally because they also may NOT |
| 1009 | be provided in the device profile (i.e., API has default values). */ |
| 1010 | Vp886DeviceProfileType devProfileData; |
| 1011 | |
| 1012 | /* This is the profile pointer table per the VP-API-II User's Guide. */ |
| 1013 | VpCSLACDeviceProfileTableType devProfileTable; |
| 1014 | |
| 1015 | /* This is the structure indicating which profile table entries have been |
| 1016 | initialized. If profile tables are disabled, this and the device profile |
| 1017 | table (devProfileTable) can be removed. */ |
| 1018 | uint16 profTableEntryValid[VP886_NUM_PROFILE_TYPES]; |
| 1019 | |
| 1020 | /* Structure to support buffered writes */ |
| 1021 | VpSlacBufDataType slacBufData; |
| 1022 | |
| 1023 | /* Flag to temporarily disable flushing the write buffer before performing |
| 1024 | a read. By default, Vp886SlacRegRead() will send the contents of the |
| 1025 | write buffer before performing the read to prevent issues with assumed |
| 1026 | write->read operations. This flag can be set when it is known that the |
| 1027 | read does not depend on any actions in the write buffer. The flag is set |
| 1028 | back to FALSE on each read. */ |
| 1029 | bool dontFlushSlacBufOnRead; |
| 1030 | |
| 1031 | /* Number of bytes sent/received to/from the device since the last |
| 1032 | VP_QUERY_ID_DEV_TRAFFIC query */ |
| 1033 | uint32 trafficBytes; |
| 1034 | |
| 1035 | /* These switcher parameters are from the user setting in the |
| 1036 | device profile. They should never be changed except in Init (in case |
| 1037 | the values provided are illegal). */ |
| 1038 | uint8 swParams[VP886_R_SWPARAM_LEN]; |
| 1039 | |
| 1040 | /* Switching Regulator Timings for normal, Free Run, and battery backup |
| 1041 | modes */ |
| 1042 | uint8 swTimingParams[VP886_R_SWTIMING_LEN]; |
| 1043 | uint8 swTimingParamsFR[VP886_R_SWTIMING_LEN]; |
| 1044 | uint8 swTimingParamsBattBackup[VP886_R_SWTIMING_LEN]; |
| 1045 | |
| 1046 | /* The device profile contains switcher timing parameters for low power |
| 1047 | mode (the first two bytes) that should only be applied if all lines are |
| 1048 | low power termination type. The flag useLowPowerTiming begins TRUE, |
| 1049 | but is set to FALSE if any non-lowpower line is initialized. As each |
| 1050 | line is initialized, the switcher timing params are set based on this. */ |
| 1051 | bool useLowPowerTiming; |
| 1052 | uint8 swTimingParamsLP[2]; |
| 1053 | |
| 1054 | /* Optionally use different low power params during the initial power supply |
| 1055 | bringup to protect components. If softStartDuration is 0 this is |
| 1056 | disabled, and we will use the normal params and the normal delay. */ |
| 1057 | uint8 softStartDuration; /* 5ms stepsize */ |
| 1058 | uint8 swTimingParamsSoftStart[VP886_R_SWTIMING_LEN]; |
| 1059 | |
| 1060 | /* State variable for the Vp886InitDevice state machine. This is used |
| 1061 | inside the Vp886InitDeviceSM function to keep track of the state |
| 1062 | and specify which state (case) of the switch statement to enter. */ |
| 1063 | Vp886InitDeviceStateType initDeviceState; |
| 1064 | |
| 1065 | /* Current ABS power mode requirement for each channel. This is needed for |
| 1066 | some cases where an operation on one line needs to know the current state |
| 1067 | of the other line. For example, if one line is exiting ringing, we need |
| 1068 | to know the state of the other line to know whether we can lower the |
| 1069 | switcher power mode. */ |
| 1070 | Vp886AbsPowerReqType absPowerReq[VP886_MAX_NUM_CHANNELS]; |
| 1071 | |
| 1072 | /* When TRUE for a channel, indicates that the channel requires ringing |
| 1073 | battery levels. This will be set by Vp886SetABSRingingBattFlag() each |
| 1074 | time the line state changes. */ |
| 1075 | bool absRingingBattRequired[VP886_MAX_NUM_CHANNELS]; |
| 1076 | |
| 1077 | /* Peak ringing voltage (amplitude+bias) for each channel that must be |
| 1078 | supported by the battery voltage */ |
| 1079 | uint8 absRingingPeak[VP886_MAX_NUM_CHANNELS]; |
| 1080 | |
| 1081 | /* Used by Adaptive Ringing to see if the other line is power limited */ |
| 1082 | bool isPowerLimited[2]; |
| 1083 | |
| 1084 | /* Current switcher voltage settings, which can change on the fly to support |
| 1085 | different ringing voltages for ABS */ |
| 1086 | uint8 swyv; |
| 1087 | uint8 swzv; |
| 1088 | |
| 1089 | /* Indicates which channels are using the sampling timer (ch2 timer) so that |
| 1090 | a line-specific function can know whether it is in use by the other line. |
| 1091 | The value is the required timer setting in 0.5ms steps. */ |
| 1092 | uint8 samplingTimerReq[VP886_MAX_NUM_CHANNELS]; |
| 1093 | |
| 1094 | /* The current sampling timer period */ |
| 1095 | uint8 samplingTimerCurrent; |
| 1096 | |
| 1097 | /* Current battery fault status, bitmask of VpBatFltEventDataType values */ |
| 1098 | uint16 battFltStatus; |
| 1099 | |
| 1100 | /* Interval in ms that we are polling to check for battery fault changes */ |
| 1101 | uint16 battFltPollTime; |
| 1102 | |
| 1103 | /* Indicates whether we think there's currently a switcher cycle skip |
| 1104 | condition based on filtered processing of the interrupt */ |
| 1105 | bool swSkipPresent; |
| 1106 | |
| 1107 | /* Timestamps of the most recent overcurrent interrupts, per channel. |
| 1108 | We need to see two interrupts within a defined period to declare an |
| 1109 | actual overcurrent event. */ |
| 1110 | uint32 overCurrentTimestamp[VP886_MAX_NUM_CHANNELS]; |
| 1111 | |
| 1112 | struct { |
| 1113 | uint8 vsw; |
| 1114 | uint8 swy; |
| 1115 | int8 vbhOverhead; |
| 1116 | } battBackup; |
| 1117 | |
| 1118 | /* Keep track of the battery select GPIO state so we only need to write |
| 1119 | it when it changes */ |
| 1120 | uint8 batSelGpioState; |
| 1121 | |
| 1122 | /* State variable for the Vp886CalCodec state machine. This is used |
| 1123 | inside the Vp886CalCodecSM function to keep track of the state |
| 1124 | and specify which state (case) of the switch statement to enter. */ |
| 1125 | Vp886CalCodecStateType calCodecState[VP886_MAX_NUM_CHANNELS]; |
| 1126 | |
| 1127 | /* ChannelId of the line under test, 0->line1, 1->line2 */ |
| 1128 | bool channelCalBack[VP886_MAX_NUM_CHANNELS]; |
| 1129 | bool channelLocked[VP886_MAX_NUM_CHANNELS]; |
| 1130 | |
| 1131 | /* Calibration data */ |
| 1132 | int16 icalH; |
| 1133 | int16 icalL; |
| 1134 | |
| 1135 | VpPolarityType polarity[VP886_MAX_NUM_CHANNELS]; |
| 1136 | |
| 1137 | /* Calibration registers scratch-pad */ |
| 1138 | Vp886RegPadType regPad[VP886_MAX_NUM_CHANNELS]; |
| 1139 | |
| 1140 | /* Calibration profile structure */ |
| 1141 | Vp886CalDeviceDataType calData[VP886_MAX_NUM_CHANNELS]; |
| 1142 | |
| 1143 | /* CalCodec sub state machine variable */ |
| 1144 | Vp886CalCodecSubStateType calCodecSubState[VP886_MAX_NUM_CHANNELS]; |
| 1145 | |
| 1146 | /* Temporary SADC measurements */ |
| 1147 | /* Should be channel dependent for concurrent calibration (tmpResultX[VP886_MAX_NUM_CHANNELS]) */ |
| 1148 | int16 sadcSetting[VP886_MAX_NUM_CHANNELS]; |
| 1149 | int16 sadcSettingGp[VP886_MAX_NUM_CHANNELS][5]; |
| 1150 | int16 tmpResultA[VP886_MAX_NUM_CHANNELS]; |
| 1151 | int16 tmpResultB[VP886_MAX_NUM_CHANNELS]; |
| 1152 | int16 tmpResultC[VP886_MAX_NUM_CHANNELS]; |
| 1153 | int16 tmpResultD[VP886_MAX_NUM_CHANNELS]; |
| 1154 | int16 tmpResultE[VP886_MAX_NUM_CHANNELS]; |
| 1155 | |
| 1156 | /* Save pointers to the Device, AC, DC, and Ringing profiles. |
| 1157 | These will be used for Vp886InitDevice() only and will only |
| 1158 | be guaranteed valid until the end of the first state of the |
| 1159 | Vp886InitDeviceSM() state machine. They will be used to send down |
| 1160 | the profiles via Vp886ConfigLineInt() before the device bringup |
| 1161 | sequence. */ |
| 1162 | VpProfilePtrType pDevProfile; |
| 1163 | VpProfilePtrType pAcProfile; |
| 1164 | VpProfilePtrType pDcProfile; |
| 1165 | VpProfilePtrType pRingProfile; |
| 1166 | |
| 1167 | /* Switcher mode during InitDevice. Transient value. */ |
| 1168 | uint8 initDevSwitcherMode; |
| 1169 | |
| 1170 | /* Cache for global registers */ |
| 1171 | struct { |
| 1172 | uint8 sigreg[VP886_R_SIGREG_LEN]; |
| 1173 | uint8 swCtrl[VP886_R_SWCTRL_LEN]; |
| 1174 | uint8 swTiming[VP886_R_SWTIMING_LEN]; |
| 1175 | uint8 intMask[VP886_R_INTMASK_LEN]; |
| 1176 | uint8 devCfg[VP886_R_DEVCFG_LEN]; |
| 1177 | uint8 fuse8[VP886_R_FUSE_REG_8_LEN]; |
| 1178 | } registers; |
| 1179 | |
| 1180 | #ifdef VP_DEBUG |
| 1181 | /* For runtime enabling of debug output: */ |
| 1182 | uint32 debugSelectMask; |
| 1183 | |
| 1184 | #if (VP_CC_DEBUG_SELECT & VP_DBG_WARNING) |
| 1185 | /* Array of function names to help debug nested critical section issues */ |
| 1186 | #define VP886_CRITSEC_STRING_NUM 3 |
| 1187 | #define VP886_CRITSEC_STRING_LENGTH 20 |
| 1188 | char critSecFuncs[VP886_CRITSEC_STRING_NUM][VP886_CRITSEC_STRING_LENGTH+1]; |
| 1189 | #endif /* (VP_CC_DEBUG_SELECT & VP_DBG_WARNING) */ |
| 1190 | |
| 1191 | #endif /* VP_DEBUG */ |
| 1192 | |
| 1193 | bool timerOverride; |
| 1194 | } Vp886DeviceObjectType; |
| 1195 | |
| 1196 | #endif /* VP886_API_H */ |