| #ifndef __DXS_HSM_H__ |
| #define __DXS_HSM_H__ |
| /****************************************************************************** |
| |
| Copyright (c) 2014-2015 Lantiq Deutschland GmbH |
| Copyright (c) 2015-2016 Lantiq Beteiligungs-GmbH & Co.KG |
| Copyright 2016, Intel Corporation. |
| |
| For licensing information, see the file 'LICENSE' in the root folder of |
| this software module. |
| |
| ******************************************************************************/ |
| |
| /** |
| \file dxs_hsm.h |
| |
| */ |
| |
| /* ========================================================================== */ |
| /* Includes */ |
| /* ========================================================================== */ |
| |
| #include "dxs.h" |
| #include "dxs_timer.h" |
| |
| /* ========================================================================== */ |
| /* Macro definitions */ |
| /* ========================================================================== */ |
| |
| /* Used as parameter to DXS_Dial_OffhookTime_Override(). */ |
| #define DXS_DIAL_TIME_NORMAL 0 |
| |
| /* ========================================================================== */ |
| /* Type definitions */ |
| /* ========================================================================== */ |
| |
| struct DXS_DIAL_DATA; |
| typedef struct DXS_DIAL_DATA DXS_DIAL_DATA_t; |
| |
| /** states of the hook-state detection finite state machine */ |
| enum HOOK_STATE |
| { |
| /** phone is on-hook */ |
| HOOK_STATE_ONHOOK, |
| /** make detected - wait for off-hook timeout */ |
| HOOK_STATE_VALIDATE_OFFHOOK, |
| /** phone is off-hook */ |
| HOOK_STATE_OFFHOOK, |
| /** break detected - wait for on-hook timeout */ |
| HOOK_STATE_VALIDATE_ONHOOK |
| }; |
| |
| /** states of the pulse dialing detection finite state machine */ |
| enum DIGIT_STATE |
| { |
| /** phone is on-hook */ |
| DIGIT_STATE_ONHOOK, |
| /** phone is off-hook */ |
| DIGIT_STATE_OFFHOOK, |
| /** wait for make to validate the digit break time */ |
| DIGIT_STATE_VALIDATE_DIGIT_BREAK, |
| /** wait for break to validate the digit make time or inter-digit timeout */ |
| DIGIT_STATE_VALIDATE_DIGIT_MAKE |
| }; |
| |
| /** states of the flash hook detection finite state machine */ |
| enum FLASH_STATE |
| { |
| /** phone is on-hook */ |
| FLASH_STATE_ONHOOK, |
| /** phone is off-hook */ |
| FLASH_STATE_OFFHOOK, |
| /** wait for make to validate the flash break time */ |
| FLASH_STATE_VALIDATE_FLASH_BREAK, |
| /** wait for flash holdoff timeout before reporting the flash event */ |
| FLASH_STATE_VALIDATE_FLASH_HOLDOFF |
| }; |
| |
| /** actions to all state machines */ |
| enum ACTION |
| { |
| /** make reported from analog line */ |
| ACTION_MAKE, |
| /** break reported from analog line */ |
| ACTION_BREAK, |
| /** timer expired */ |
| ACTION_TIMEOUT_HOOK, |
| /** timer expired */ |
| ACTION_TIMEOUT_INTERDIGIT, |
| /** timer expired */ |
| ACTION_TIMEOUT_FLASHHOLDOFF |
| }; |
| |
| /** Data of the hook state machine. */ |
| struct DXS_DIAL_DATA |
| { |
| /** state of the hook-state detection finite state machine */ |
| enum HOOK_STATE nHookState; |
| /** state of the pulse dialing detection finite state machine */ |
| enum DIGIT_STATE nDigitState; |
| /** state of the flash hook detection finite state machine */ |
| enum FLASH_STATE nFlashState; |
| /** timer for hook state machine timeouts */ |
| Timer_ID HookTimerID; |
| /** timer for the inter-digit timeout */ |
| Timer_ID InterdigitTimerID; |
| /** timer for the flash holdoff timeout */ |
| Timer_ID FlashHoldoffTimerID; |
| /** counter for the pulses of the pulse digit */ |
| uint8_t nPulseDigit; |
| /* indicates that pulse start event was sent, reset by on-hook or |
| * flash-hook */ |
| uint8_t bPulseStartSent; |
| /* validation times for all state machines */ |
| uint32_t nTimeOnhook, |
| nTimeOffhook, |
| nTimeOffhookBackup, |
| nTimeInterdigit, |
| nTimeFlashHoldoff, |
| nTimeDigitMakeMin, |
| nTimeDigitMakeMax, |
| nTimeDigitBreakMin, |
| nTimeDigitBreakMax, |
| nTimeFlashBreakMin, |
| nTimeFlashBreakMax; |
| /* elapsed time since last hook event */ |
| uint16_t nLastHookEvtTimestamp; |
| /* timer for hook event timestamp wraparound */ |
| Timer_ID HookWindowTimerId; |
| volatile uint8_t bHookWindow; |
| }; |
| |
| /* ========================================================================== */ |
| /* Function prototypes */ |
| /* ========================================================================== */ |
| extern int32_t DXS_Dial_Initialise_Unprot(DXS_CHANNEL_t *pChannel); |
| extern void DXS_Dial_Cleanup(DXS_CHANNEL_t *pChannel); |
| extern void DXS_Dial_HookEvent(DXS_CHANNEL_t* pChannel, uint32_t bHookState, |
| uint16_t nTime); |
| extern void DXS_Dial_OffhookTime_Override(DXS_CHANNEL_t *pChannel, |
| uint32_t const nTime); |
| extern uint16_t DXS_Dial_ElapsedTimeSinceLastHook(DXS_CHANNEL_t *pChannel, |
| uint16_t nCurrentTimestamp); |
| extern int32_t DXS_Dial_HookValTimeSet(DXS_CHANNEL_t *pChannel, |
| DXS_HookValTime_t *pTime); |
| extern void DXS_Dial_HookStateSetOnhook(DXS_CHANNEL_t *pChannel); |
| #endif /* __DXS_HSM_H__ */ |