fp@59: /****************************************************************************** fp@59: * fp@59: * E t h e r C A T _ s i . h fp@59: * fp@59: * EtherCAT Slave-Interface. fp@59: * fp@59: * $Id$ fp@59: * fp@59: *****************************************************************************/ fp@59: fp@59: /*****************************************************************************/ fp@59: fp@74: // Bitwise read/write macros fp@59: fp@74: #define EC_READ_BIT(PD, CH) (*((uint8_t *) (PD)) >> (CH)) & 0x01) fp@59: fp@74: #define EC_WRITE_BIT(PD, CH, VAL) \ fp@59: do { \ fp@74: if (VAL) *((uint8_t *) (PD)) |= (1 << (CH)); \ fp@74: else *((uint8_t *) (PD)) &= ~(1 << (CH)); \ fp@59: } while (0) fp@59: fp@59: /*****************************************************************************/ fp@59: fp@74: // Read macros fp@71: fp@74: #define EC_READ_U8(PD) \ fp@74: (*((uint8_t *) (PD))) fp@74: fp@74: #define EC_READ_S8(PD) \ fp@74: ((int8_t) *((uint8_t *) (PD))) fp@74: fp@74: #define EC_READ_U16(PD) \ fp@74: ((uint16_t) (*((uint8_t *) (PD) + 0) << 0 | \ fp@74: *((uint8_t *) (PD) + 1) << 8)) fp@74: fp@74: #define EC_READ_S16(PD) \ fp@74: ((int16_t) (*((uint8_t *) (PD) + 0) << 0 | \ fp@74: *((uint8_t *) (PD) + 1) << 8)) fp@74: fp@74: #define EC_READ_U32(PD) \ fp@74: ((uint32_t) (*((uint8_t *) (PD) + 0) << 0 | \ fp@74: *((uint8_t *) (PD) + 1) << 8 | \ fp@74: *((uint8_t *) (PD) + 2) << 16 | \ fp@74: *((uint8_t *) (PD) + 3) << 24)) fp@74: fp@74: #define EC_READ_S32(PD) \ fp@74: ((int32_t) (*((uint8_t *) (PD) + 0) << 0 | \ fp@74: *((uint8_t *) (PD) + 1) << 8 | \ fp@74: *((uint8_t *) (PD) + 2) << 16 | \ fp@74: *((uint8_t *) (PD) + 3) << 24)) fp@67: fp@67: /*****************************************************************************/ fp@67: fp@74: // Write macros fp@74: fp@74: #define EC_WRITE_U8(PD, VAL) \ fp@59: do { \ fp@74: *((uint8_t *)(PD)) = ((uint8_t) (VAL)); \ fp@59: } while (0) fp@59: fp@74: #define EC_WRITE_S8(PD, VAL) EC_WRITE_U8(PD, VAL) fp@59: fp@74: #define EC_WRITE_U16(PD, VAL) \ fp@74: do { \ fp@74: *((uint8_t *) (PD) + 0) = ((uint16_t) (VAL) >> 0) & 0xFF; \ fp@74: *((uint8_t *) (PD) + 1) = ((uint16_t) (VAL) >> 8) & 0xFF; \ fp@74: } while (0) fp@67: fp@74: #define EC_WRITE_S16(PD, VAL) EC_WRITE_U16(PD, VAL) fp@67: fp@74: #define EC_WRITE_U32(PD, VAL) \ fp@74: do { \ fp@74: *((uint8_t *) (PD) + 0) = ((uint32_t) (VAL) >> 0) & 0xFF; \ fp@74: *((uint8_t *) (PD) + 1) = ((uint32_t) (VAL) >> 8) & 0xFF; \ fp@74: *((uint8_t *) (PD) + 2) = ((uint32_t) (VAL) >> 16) & 0xFF; \ fp@74: *((uint8_t *) (PD) + 3) = ((uint32_t) (VAL) >> 24) & 0xFF; \ fp@74: } while (0) fp@66: fp@74: #define EC_WRITE_S32(PD, VAL) EC_WRITE_U32(PD, VAL) fp@67: fp@66: /*****************************************************************************/ fp@66: fp@59: /* Emacs-Konfiguration fp@59: ;;; Local Variables: *** fp@59: ;;; c-basic-offset:4 *** fp@59: ;;; End: *** fp@59: */