![]() |
ECAT_Slave_in_ПЧ2П_c402
0.8
Реализация EtherCAT Slave для CM TMS320F28388D
|
Файлы | |
| файл | mailbox.c |
| Implementation. | |
| файл | mailbox.h |
Структуры данных | |
| struct | MBX_STRUCT_PACKED_START |
| CoE Mailbox header. Подробнее... | |
| struct | TMBXQUEUE |
| Mailbox queue. Подробнее... | |
Макросы | |
| #define | _MAILBOX_ 1 |
| #define | MBX_TYPE_AOE 1 |
| Mailbox type AoE. Подробнее... | |
| #define | MBX_TYPE_EOE 2 |
| Mailbox type EoE. Подробнее... | |
| #define | MBX_TYPE_COE 3 |
| Mailbox type CoE. Подробнее... | |
| #define | MBX_TYPE_FOE 4 |
| Mailbox type FoE. Подробнее... | |
| #define | MBX_TYPE_SOE 5 |
| Mailbox type SoE. Подробнее... | |
| #define | MBX_TYPE_VOE 15 |
| Mailbox type VoE. Подробнее... | |
| #define | EMCY_SERVICE ((UINT8) 0x0001) |
| Emergency service. Подробнее... | |
| #define | COE_SERVICE ((UINT8) 0x0002) |
| CoE service. Подробнее... | |
| #define | SOE_SERVICE ((UINT8) 0x0004) |
| SoE service. Подробнее... | |
| #define | EOE_SERVICE ((UINT8) 0x0008) |
| EoE service. Подробнее... | |
| #define | AOE_SERVICE ((UINT8) 0x0010) |
| AoE service. Подробнее... | |
| #define | VOE_SERVICE ((UINT8) 0x0020) |
| VoE service. Подробнее... | |
| #define | FOE_SERVICE ((UINT8) 0x0040) |
| FoE service. Подробнее... | |
| #define | FRAGMENTS_FOLLOW ((UINT8) 0x0080) |
| Fragments follow service. Подробнее... | |
| #define | MAX_MBX_QUEUE_SIZE 10 |
| Mailbox queue size. Подробнее... | |
| #define | MBXSERVICE_MBXERRORCMD 0x01 |
| Mailbox error command. Подробнее... | |
| #define | MBXERR_SYNTAX 0x01 |
| Mailbox error "syntax". Подробнее... | |
| #define | MBXERR_UNSUPPORTEDPROTOCOL 0x02 |
| Mailbox error "unsupported protocol". Подробнее... | |
| #define | MBXERR_INVALIDCHANNEL 0x03 |
| Mailbox error "invalid channel". Подробнее... | |
| #define | MBXERR_SERVICENOTSUPPORTED 0x04 |
| Mailbox error "service not supported". Подробнее... | |
| #define | MBXERR_INVALIDHEADER 0x05 |
| Mailbox error "invalid header". Подробнее... | |
| #define | MBXERR_SIZETOOSHORT 0x06 |
| Mailbox error "Size too short". Подробнее... | |
| #define | MBXERR_NOMOREMEMORY 0x07 |
| Mailbox error "No memory". Подробнее... | |
| #define | MBXERR_INVALIDSIZE 0x08 |
| Mailbox error "Invalid size". Подробнее... | |
| #define | MBXERR_SERVICEINWORK 0x09 |
| Mailbox error "Service in work". Подробнее... | |
| #define | MBX_HEADER_SIZE 6 |
| Mailbox header size. Подробнее... | |
| #define | MAX_MBX_DATA_SIZE (MAX_MBX_SIZE - MBX_HEADER_SIZE) |
| Mailbox data size. Подробнее... | |
| #define | PROTO extern |
Определения типов | |
| typedef struct MBX_STRUCT_PACKED_START | TMBXHEADER |
| Mailbox header. Подробнее... | |
| typedef struct MBX_STRUCT_PACKED_START | TMBX |
| Mailbox datagram. Подробнее... | |
Функции | |
| UINT8 | PutInMbxQueue (TMBX MBXMEM *pMbx, TMBXQUEUE MBXMEM *pQueue) |
| TMBX MBXMEM * | GetOutOfMbxQueue (TMBXQUEUE MBXMEM *pQueue) |
| void | MBX_Init (void) |
| This function intialize the Mailbox Interface. Подробнее... | |
| UINT16 | MBX_StartMailboxHandler (void) |
| This function includes the state transition from INIT to. Подробнее... | |
| void | MBX_StopMailboxHandler (void) |
| This function includes the state transition from. Подробнее... | |
| UINT8 | MailboxServiceInd (TMBX MBXMEM *pMbx) |
| The function checks the mailbox header for the requested service and calls the. Подробнее... | |
| void | MBX_MailboxWriteInd (TMBX MBXMEM *pMbx) |
| This function is called when the Master has written the Receive-Mailbox. Подробнее... | |
| void | MBX_MailboxReadInd (void) |
| This function is called when the Master has read the Send-Mailbox. Подробнее... | |
| void | MBX_MailboxRepeatReq (void) |
| This function is called if the Master has requested a resending of the last. Подробнее... | |
| UINT8 | MBX_MailboxSendReq (TMBX MBXMEM *pMbx, UINT8 flags) |
| This function puts a new Mailbox service in the Send Mailbox. Подробнее... | |
| void | MBX_CheckAndCopyMailbox (void) |
| This function is used to check if the received mailbox command can be processed. Подробнее... | |
| UINT8 | MBX_CopyToSendMailbox (TMBX MBXMEM *pMbx) |
| This function copies data to the Send Mailbox. Подробнее... | |
| void | MBX_Main (void) |
| This function is called cyclically to check if a received Mailbox service was stored. Подробнее... | |
Переменные | |
| VARVOLATILE UINT8 | u8dummy |
| BOOL | bNoMbxMemoryAvailable |
| Indicates if enough dynamic memory is available to handle at least one mailbox datagram. Подробнее... | |
| PROTO BOOL | bReceiveMbxIsLocked |
| Receive mailbox is locked (MBoxOut, default SM0) Подробнее... | |
| PROTO BOOL | bSendMbxIsFull |
| Send mailbox is full (MBoxIn, default SM1) Подробнее... | |
| PROTO BOOL | bMbxRunning |
| Mailbox running (At least PreOP state) Подробнее... | |
| PROTO BOOL | bMbxRepeatToggle |
| Mailbox repeat toggle. Подробнее... | |
| PROTO UINT16 | u16SendMbxSize |
| Send mailbox size (default SM1) Подробнее... | |
| PROTO UINT16 | u16ReceiveMbxSize |
| Receive mailbox size (default SM0) Подробнее... | |
| PROTO UINT16 | u16EscAddrReceiveMbx |
| Receive mailbox address (default SM0) Подробнее... | |
| PROTO UINT16 | u16EscAddrSendMbx |
| Send mailbox address (default SM1) Подробнее... | |
| PROTO UINT8 | u8MbxWriteCounter |
| Write mailbox counter. Подробнее... | |
| PROTO UINT8 | u8MbxReadCounter |
| Read mailbox counter. Подробнее... | |
| PROTO UINT8 | u8MailboxSendReqStored |
| Mailbox send request stored. Подробнее... | |
| PROTO TMBX MBXMEM * | psWriteMbx |
| Pointer to write mailbox buffer. Подробнее... | |
| PROTO TMBX MBXMEM * | psReadMbx |
| Pointer to read mailbox buffer. Подробнее... | |
| PROTO TMBX MBXMEM * | psRepeatMbx |
| Pointer to repeat mailbox buffer. Подробнее... | |
| PROTO TMBX MBXMEM * | psStoreMbx |
| Pointer to store mailbox buffer. Подробнее... | |
| PROTO TMBXQUEUE MBXMEM | sMbxSendQueue |
| Send mailbox queue. Подробнее... | |
| PROTO TMBXQUEUE MBXMEM | sMbxReceiveQueue |
| Receive mailbox queue. Подробнее... | |
| #define EMCY_SERVICE ((UINT8) 0x0001) |
| #define FRAGMENTS_FOLLOW ((UINT8) 0x0080) |
| #define MAX_MBX_DATA_SIZE (MAX_MBX_SIZE - MBX_HEADER_SIZE) |
| #define MBXERR_INVALIDCHANNEL 0x03 |
| #define MBXERR_INVALIDHEADER 0x05 |
| #define MBXERR_INVALIDSIZE 0x08 |
| #define MBXERR_NOMOREMEMORY 0x07 |
| #define MBXERR_SERVICEINWORK 0x09 |
| #define MBXERR_SERVICENOTSUPPORTED 0x04 |
| #define MBXERR_SIZETOOSHORT 0x06 |
| #define MBXERR_UNSUPPORTEDPROTOCOL 0x02 |
| #define MBXSERVICE_MBXERRORCMD 0x01 |
| typedef struct MBX_STRUCT_PACKED_START TMBX |
Mailbox datagram.
| typedef struct MBX_STRUCT_PACKED_START TMBXHEADER |
Mailbox header.
| PROTO void MBX_CheckAndCopyMailbox | ( | void | ) |
| PROTO void MBX_Init | ( | void | ) |
| PROTO void MBX_MailboxReadInd | ( | void | ) |
| PROTO void MBX_MailboxRepeatReq | ( | void | ) |
This function puts a new Mailbox service in the Send Mailbox.
| pMbx | Pointer to a Mailbox command to be sent (read by the Master) |
| flags | Bit 0-6: mailbox protocol type: 0x01 - emergency service 0x02 - CoE service 0x04 - SoE service 0x80 - EoE service 0x10 - AoE service 0x20 - VoE service Bit 7: 0 - no more fragments to be sent for the requested mailbox service 1 - additional fragments to be sent for the mailbox service, the corresponding XXXX_ContinueInd-function will be called to get the next fragment |
См. определение в файле mailbox.c строка 725
This function is called when the Master has written the Receive-Mailbox.
| pMbx | Pointer to the received Mailbox command from Master. |
It will only be called if the send mailbox is empty, that a response for the
mailbox service could be stored.
The function checks the mailbox header for the requested service and calls the
corresponding XXXX_ServiceInd-function
См. определение в файле mailbox.c строка 513
| PROTO void MBX_Main | ( | void | ) |
This function includes the state transition from INIT to.
PRE-OPERATIONAL in the EtherCAT Slave corresponding to
local management service Start Mailbox Handler
it is checked if the mailbox areas overlaps each other
and the Sync Manager channels 0 and 1 are enabled.
This function shall only be called if mailbox is supported.
См. определение в файле mailbox.c строка 314
| PROTO void MBX_StopMailboxHandler | ( | void | ) |
| BOOL bNoMbxMemoryAvailable |
|
extern |