| /*============================================================================*/ |
| /* eCall ANSI C fixed-point reference source code */ |
| /* */ |
| /* File: ecall_control.h */ |
| /* Version: 8.6.0 (Rel8) / 9.4.0 (Rel9) */ |
| /* Date: 2011-02-08 */ |
| /* Description: control message functions (header file) */ |
| /*----------------------------------------------------------------------------*/ |
| |
| #ifndef ECALL_CONTROL_H_ |
| #define ECALL_CONTROL_H_ |
| |
| #include "ecall_defines.h" |
| #include "ecall_sync.h" |
| |
| |
| typedef enum { |
| DlMsgNoop = -2, |
| DlMsgReset, |
| DlMsgStart, // 0 |
| DlMsgNack, // 1 |
| DlMsgAck, // 2 |
| DlMsgSend, // 3 |
| DlMsgUndef04, |
| DlMsgUndef05, |
| DlMsgUndef06, |
| DlMsgUndef07, |
| DlMsgUndef08, |
| DlMsgUndef09, |
| DlMsgUndef10, |
| DlMsgUndef11, |
| DlMsgUndef12, |
| DlMsgUndef13, |
| DlMsgUndef14, |
| DlMsgUndef15, |
| DlMsgUndef16, |
| DlMsgUndef17, |
| DlMsgUndef18, |
| DlMsgUndef19, |
| DlMsgUndef20, |
| DlMsgUndef21, |
| DlMsgUndef22, |
| DlMsgUndef23, |
| DlMsgUndef24, |
| DlMsgUndef25, |
| DlMsgUndef26, |
| DlMsgUndef27, |
| DlMsgUndef28, |
| DlMsgUndef29, |
| DlMsgUndef30, |
| DlMsgUndef31, |
| DlMsgHlack = SET_LLMSG + SET_HLMSG |
| } DlData; |
| |
| #ifdef ECALL_ENUM2STR |
| #define DLMSG_PAD (-DlMsgNoop) |
| #define NUM_DLMSGS (DlMsgHlack - DlMsgNoop + 1) |
| extern const char* const __DLMSG2STR[NUM_DLMSGS]; |
| #define DLDATA2STR(DLDATA) __DLMSG2STR[DLMSG_PAD + DLDATA] |
| #endif |
| |
| typedef enum { |
| CtrlRxIdle, |
| CtrlRxSync, |
| CtrlRxLock, |
| CtrlTxIdle, |
| CtrlTxSend, |
| NUM_PORTSTATES |
| } PortState; |
| |
| #ifdef ECALL_ENUM2STR |
| extern const char* const __PORTSTATE2STR[NUM_PORTSTATES]; |
| #define PORTSTATE2STR(PORTSTATE) __PORTSTATE2STR[PORTSTATE] |
| #endif |
| |
| typedef enum { |
| PortUndef, |
| PortIvs, |
| PortPsap, |
| NUM_PORTOWNERS |
| } PortOwner; |
| |
| #ifdef ECALL_ENUM2STR |
| extern const char* const __PORTOWNER2STR[NUM_PORTOWNERS]; |
| #define PORTOWNER2STR(PORTOWNER) __PORTOWNER2STR[PORTOWNER] |
| #endif |
| |
| /*============================================================================*/ |
| /* Control structures */ |
| /*----------------------------------------------------------------------------*/ |
| |
| typedef struct { |
| Int16 dlData; /* message symbol */ |
| Int16 dlIndex; /* message frame counter */ |
| } CtrlTxPort; |
| |
| typedef struct { |
| Int16 dlData; /* detected message symbol */ |
| Int16 dlMetric; /* receiver metric */ |
| } CtrlRxPort; |
| |
| typedef struct { |
| union { |
| CtrlTxPort tx; /* port control transmitter */ |
| CtrlRxPort rx; /* port control receiver */ |
| } u; |
| PortState state; /* port state */ |
| PortOwner owner; /* port owner identification */ |
| Bool invert; /* port inversion flag */ |
| } CtrlPort; |
| |
| typedef struct { |
| CtrlPort port; /* port struct */ |
| } CtrlTxData; |
| |
| typedef struct { |
| CtrlPort port; /* port struct */ |
| |
| SyncState *sync; /* pointer to sync struct */ |
| Int16 *buffer; /* pointer to control receiver buffer */ |
| |
| Tern dlRead; /* sync indication (ternary variable) */ |
| Int16 dlIndex; /* internal frame counter */ |
| Int16 dlSyncLock; /* number of sync events required */ |
| } CtrlRxData; |
| |
| |
| /*============================================================================*/ |
| /* Control functions */ |
| /*----------------------------------------------------------------------------*/ |
| |
| const char* CtrlPortName(PortOwner); |
| void CtrlSync(CtrlRxData*, const Int16*); |
| |
| void CtrlTxReset(CtrlTxData*, PortOwner); |
| void CtrlTxProcess(CtrlTxData*, Int16*); |
| void CtrlTxMod(Int16*, Int16, Int16); |
| |
| void CtrlRxReset(CtrlRxData*, PortOwner, SyncState*, Int16*, Int16); |
| void CtrlRxProcess(CtrlRxData*, const Int16*); |
| Int16 CtrlRxDemod(const Int16*, Int16*); |
| |
| #endif |