123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- #ifndef __LINCP_H
- #define __LINCP_H
- #include "main.h"
- #define LINCPID_SE_VERSION_LIST (0x00)
- #define LINCPID_EV_VERSION_LIST (0x01)
- #define LINCPID_SE_STATUS (0x02)
- #define LINCPID_EV_STATUS (0x03)
- #define LINCPID_EV_PRESENT_CURRENTS (0x04)
- #define LINCPID_SE_NOM_VOLTAGES (0x05)
- #define LINCPID_SE_MAX_CURRENTS (0x06)
- #define LINCPID_EV_MAX_VOLTAGES (0x07)
- #define LINCPID_EV_MIN_VOLTAGES (0x08)
- #define LINCPID_EV_MAX_MIN_CURRENTS (0x09)
- //#define LINCPID_CA_PROPERTIES (0x0A)
- #define LINCPID_SE_INFO_LIST (0x0B)
- #define LINCPID_EV_INFO_LIST (0x0C)
- //#define LINCPID_ST_ERROR_LIST (0x0D)
- //#define LINCPID_EV_ERROR_LIST (0x0E)
- //#define LINCPID_SE_ID (0x0F)
- //#define LINCPID_EV_ID (0x10)
- //Frame: 0
- typedef struct
- {
- u8 SeSelectedVersion; //0
- union
- {
- u8 B1;
- struct
- {
- u8 _Reserved_B1_b7: 1; //1.7 0x01
- u8 SeStatusOp: 2; //1.5-6
- u8 SeStatusInit: 2; //1.3-4
- u8 SeStatusVer: 2; //1.1-2
- u8 _Reserved_B1_b0: 1; //1.0 0x01
- };
- };
- u8 SeVersionPageNumber; //2 0x00 (typically)
- u8 SeSupportedVersion1; //3 0x02 (typically)
- u8 SeSupportedVersion2; //4 0xFF (typically)
- u8 SeSupportedVersion3; //5 0xFF (typically)
- u8 SeSupportedVersion4; //6 0xFF (typically)
- u8 SeSupportedVersion5; //7 0xFF (typically)
- } __attribute__((__packed__)) SeVersionList;
- //Frame: 1
- typedef struct
- {
- u8 EvSelectedVersion; //0 0x02 (typically)
- u8 EvAwake: 1; //1.7
- u8 EvStatusOp: 2; //1.5-6
- u8 EvStatusInit: 2; //1.3-4
- u8 EvStatusVer: 2; //1.1-2
- u8 EvResponseError: 1; //1.0
- u8 EvVersionPageNumber; //2 0x00 (typically)
- u8 EvSupportedVersion1; //3 0x02 (typically)
- u8 EvSupportedVersion2; //4 0xFF (typically)
- u8 EvSupportedVersion3; //5 0xFF (typically)
- u8 EvSupportedVersion4; //6 0xFF (typically)
- u8 EvSupportedVersion5; //7 0xFF (typically)
- } __attribute__((__packed__)) EvVersionList;
- //Frame: 2
- typedef struct
- {
- u8 SeSelectedVersion; //0 0x02 (typically)
- u8 _Reserved_B1_b7: 1; //1.7 0x01
- u8 SeStatusOp: 2; //1.5-6
- u8 SeStatusInit: 2; //1.3-4
- u8 SeStatusVer: 2; //1.1-2
- u8 _Reserved_B1_b0: 1; //1.0 0x01
- u8 SeAvailableCurrentL1; //2
- u8 SeAvailableCurrentL2; //3
- u8 SeAvailableCurrentL3; //4
- u8 SeAvailableCurrentN; //5
- u8 _Reserved_B6; //6 0xFF
- u8 _Reserved_B7; //7 0xFF
- } __attribute__((__packed__)) SeStatus;
- //Frame: 3
- typedef struct
- {
- u8 EvSelectedVersion; //0 0x02 (typically)
- u8 EvAwake: 1; //1.7
- u8 EvStatusOp: 2; //1.5-6
- u8 EvStatusInit: 2; //1.3-4
- u8 EvStatusVer: 2; //1.1-2
- u8 EvResponseError: 1; //1.0
- u8 EvRequestedCurrentL1; //2
- u8 EvRequestedCurrentL2; //3
- u8 EvRequestedCurrentL3; //4
- u8 EvRequestedCurrentN; //5
- u8 _Reserved_B6; //6 0xFF
- u8 _Reserved_B7; //7 0xFF
- } __attribute__((__packed__)) EvStatus;
- //Frame: 4
- typedef struct
- {
- u8 EvSelectedVersion; //0 0x02 (typically)
- u8 EvPresentCurrentL1; //1
- u8 EvPresentCurrentL2; //2
- u8 EvPresentCurrentL3; //3
- u8 EvPresentCurrentN; //4
- u8 _Reserved_B5; //5 0xFF
- u8 _Reserved_B6; //6 0xFF
- u8 _Reserved_B7; //7 0xFF
- } __attribute__((__packed__)) EvPresentCurrents;
- //Frame: 5
- typedef struct
- {
- u8 SeSelectedVersion; //0 0x02 (typically)
- uint16_t SeNomVoltageL1N; //1-2
- uint16_t SeNomVoltageLL; //3-4
- u8 SeFrequency; //5
- u8 _Reserved_B6; //6 0xFF
- u8 _Reserved_B7; //7 0xFF
- } __attribute__((__packed__)) SeNomVoltages;
- //Frame: 6
- typedef struct
- {
- u8 SeSelectedVersion; //0 0x02 (typically)
- u8 SeMaxCurrentL1; //1
- u8 SeMaxCurrentL2; //2
- u8 SeMaxCurrentL3; //3
- u8 SeMaxCurrentN; //4
- u8 _Reserved_B5; //5 0xFF
- u8 _Reserved_B6; //6 0xFF
- u8 _Reserved_B7; //7 0xFF
- } __attribute__((__packed__)) SeMaxCurrents;
- //Frame: 7
- typedef struct
- {
- u8 EvSelectedVersion; //0 0x02 (typically)
- uint16_t EvMaxVoltageL1N; //1-2
- uint16_t EvMaxVoltageLL; //3-4
- u8 EvFrequencies; //5
- u8 _Reserved_B6; //6 0xFF
- u8 _Reserved_B7; //7 0xFF
- } __attribute__((__packed__)) EvMaxVoltages;
- //Frame: 8
- typedef struct
- {
- u8 EvSelectedVersion; //0 0x02 (typically)
- uint16_t EvMinVoltageL1N; //1-2
- uint16_t EvMinVoltageLL; //3-4
- u8 _Reserved_B5; //5 0xFF
- u8 _Reserved_B6; //6 0xFF
- u8 _Reserved_B7; //7 0xFF
- } __attribute__((__packed__)) EvMinVoltages;
- //Frame: 9
- typedef struct
- {
- u8 EvSelectedVersion; //0 0x02 (typically)
- u8 EvMaxCurrentL1; //1
- u8 EvMaxCurrentL2; //2
- u8 EvMaxCurrentL3; //3
- u8 EvMaxCurrentN; //4
- u8 EvMinCurrentL1; //5
- u8 EvMinCurrentL2; //6
- u8 EvMinCurrentL3; //7
- } __attribute__((__packed__)) EvMaxMinCurrents;
- //Frame: 10
- //Not used in this edition of SAE J3068.
- //Reserved for future implementation of cordset nodes
- //typedef struct
- //{
- // u8 CaVersion; //0 0x01 (typically)
- // u8 _Reserved_B1_b1_7: 7; //1.1-7 (all: ones)
- // u8 CaResponseError: 1; //1.0
- // uint16_t CaMaxVoltage; //2-3
- // u8 CaMaxCurrentL1; //4
- // u8 CaMaxCurrentL2; //5
- // u8 CaMaxCurrentL3; //6
- // u8 CaMaxCurrentN; //7
- //} __attribute__((__packed__)) CaProperties;
- //Frame: 11
- typedef struct
- {
- u8 SeSelectedVersion; //0
- u8 SeInfoPageNumber; //1
- u8 SeInfoEntry1; //2
- u8 SeInfoEntry2; //3
- u8 SeInfoEntry3; //4
- u8 SeInfoEntry4; //5
- u8 SeInfoEntry5; //6
- u8 SeInfoEntry6; //7
- } __attribute__((__packed__)) SeInfoList;
- //Frame: 12
- typedef struct
- {
- u8 EvSelectedVersion; //0
- u8 EvInfoPageNumber; //1
- u8 EvInfoEntry1; //2
- u8 EvInfoEntry2; //3
- u8 EvInfoEntry3; //4
- u8 EvInfoEntry4; //5
- u8 EvInfoEntry5; //6
- u8 EvInfoEntry6; //7
- } __attribute__((__packed__)) EvInfoList;
- //Frame: 13
- //Reserved; used in Protocol Version 1
- //typedef struct
- //{
- // u8 SeSelectedVersion;
- // u8 SeErrorPageNumber;
- // u8 SeErrorEntry1;
- // u8 SeErrorEntry2;
- // u8 SeErrorEntry3;
- // u8 SeErrorEntry4;
- // u8 SeErrorEntry5;
- // u8 SeErrorEntry6;
- //} __attribute__((__packed__)) StErrorList;
- //Frame: 14
- //Reserved; used in Protocol Version 1
- //typedef struct
- //{
- // u8 EvSelectedVersion;
- // u8 EvErrorPageNumber;
- // u8 EvErrorEntry1;
- // u8 EvErrorEntry2;
- // u8 EvErrorEntry3;
- // u8 EvErrorEntry4;
- // u8 EvErrorEntry5;
- // u8 EvErrorEntry6;
- //} __attribute__((__packed__)) EvErrorList;
- //--------------------------------------------------------------
- //15 to 49 Reserved
- //50 to 59 Available for application specific frames
- //60 Refer to ISO 17987, used in SAE J3068 for the LIN go-to-sleep command. See 10.1.
- //61 to 63 Refer to ISO 17987, not used in SAE J3068
- ////Frame: 15
- //typedef struct
- //{
- // u8 SeIDPageNumber;
- // u8 SeIDByteA;
- // u8 SeIDByteB;
- // u8 SeIDByteC;
- // u8 SeIDByteD;
- // u8 SeIDByteE;
- // u8 SeIDByteF;
- // u8 SeIDByteG;
- //} __attribute__((__packed__)) SeID;
- //
- ////Frame: 16
- //typedef struct
- //{
- // u8 EvIDPageNumber;
- // u8 EvIDByteA;
- // u8 EvIDByteB;
- // u8 EvIDByteC;
- // u8 EvIDByteD;
- // u8 EvIDByteE;
- // u8 EvIDByteF;
- // u8 EvIDByteG;
- //} __attribute__((__packed__)) EvID;
- //#define LIN_VER_2X
- #define LIN_BUF_MAX (11) //SYNC(1) + ID(1) + DATA(8) + CHECKSUM(1)
- struct _LinCP
- {
- USART_TypeDef* m_USART;
- u8 m_TxBuf[LIN_BUF_MAX];
- int m_TxLen;
- int m_TxIdx;
- u8 m_RxBuf[LIN_BUF_MAX];
- int m_RxLen;
- HTK_BOOL m_bTx;
- HTK_BOOL m_bRx;
- HTK_BOOL m_bTxTimeout;
- HTK_BOOL m_bRxTimeout;
- u32 m_nTxOK;
- u32 m_nRxOK;
- u32 m_nTxNG;
- u32 m_nRxNG;
- };
- void LIN_Init(PLinCP p, USART_TypeDef* usart);
- HTK_BOOL LIN_TxHeader(PLinCP p, u8 id);
- HTK_BOOL LIN_TxHeaderData(PLinCP p, u8 id, void* Data, u8 DataLen);
- void LIN_Display(PLinCP p);
- void LIN_IRQ_Proc(PLinCP p);
- #ifdef FUNC_LIN_MASTER
- void LIN_IRQ_Master_ProcTx(PLinCP p);
- void LIN_IRQ_Master_ProcRx(PLinCP p);
- #else
- //void LIN_IRQ_Slave_ProcTx(PLinCP p);
- //void LIN_IRQ_Slave_ProcRx(PLinCP p);
- #endif
- #endif //__LINCP_H
|