1 /* 2 * Copyright 2016-2022 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef _FSL_ECAT_H_ 9 #define _FSL_ECAT_H_ 10 11 #include "fsl_common.h" 12 13 /*! @brief Returns the first 16Bit of the AL Event register (0x220).*/ 14 #define ECAT_GetALEventRegister(ecat) (uint16_t)((ecat)->AL_EVENT_REQUEST) 15 16 /*! @brief Generic ESC (register and DPRAM) read access.*/ 17 #define ECAT_EscRead(ecat, pData, Address, Len) \ 18 memcpy((uint8_t *)(pData), &((uint32_t *)(ecat))[(Address) >> 2], (Len)) 19 20 /*! @brief 32Bit specific ESC (register and DPRAM) read access.*/ 21 #define ECAT_EscReadDWord(ecat, DWordValue, Address) \ 22 ((DWordValue) = (uint32_t)(((uint32_t *)(ecat))[(Address >> 2)])) 23 24 /*! @brief Generic ESC (register and DPRAM) write access.*/ 25 #define ECAT_EscWrite(ecat, pData, Address, Len) \ 26 memcpy(&((uint32_t *)(ecat))[(Address) >> 2], (uint8_t *)(pData), (Len)) 27 28 /*! @brief 32Bit specific ESC (register and DPRAM) write access.*/ 29 #define ECAT_EscWriteDWord(ecat, DWordValue, Address) \ 30 ((((uint32_t *)(ecat))[(Address >> 2)]) = (DWordValue)) 31 32 /*! 33 * @brief Read PHY register via ESC MII Management Interface. 34 * 35 * @param ecat base ECAT peripheral address. 36 * @param phy_addr PHY address. 37 * @param reg_addr Register address. 38 * @param data PHY data returned. 39 */ 40 41 status_t ECAT_EscMdioRead(ECAT_Type *ecat, uint8_t phy_addr, uint8_t reg_addr, uint16_t *data); 42 43 /*! 44 * @brief Write PHY register via ESC MII Management Interface. 45 * 46 * @param ecat base ECAT peripheral address. 47 * @param phy_addr PHY address. 48 * @param reg_addr Register address. 49 * @param data Write to PHY register. 50 */ 51 status_t ECAT_EscMdioWrite(ECAT_Type *ecat, uint8_t phy_addr, uint8_t reg_addr, uint16_t data); 52 53 #endif /* _FSL_ECAT_H_ */ 54