master/slave.h
changeset 626 a5e838c30733
parent 625 ec69acbbd156
child 627 4793ca94f082
equal deleted inserted replaced
625:ec69acbbd156 626:a5e838c30733
    70     EC_SLAVE_STATE_ACK_ERR = 0x10
    70     EC_SLAVE_STATE_ACK_ERR = 0x10
    71     /**< Acknowledge/Error bit (no actual state) */
    71     /**< Acknowledge/Error bit (no actual state) */
    72 }
    72 }
    73 ec_slave_state_t;
    73 ec_slave_state_t;
    74 
    74 
       
    75 /*****************************************************************************/
       
    76 
       
    77 /**
       
    78  */
       
    79 
    75 typedef enum {
    80 typedef enum {
    76     EC_SLAVE_OFFLINE,
    81     EC_SLAVE_OFFLINE,
    77     EC_SLAVE_ONLINE
    82     EC_SLAVE_ONLINE
    78 }
    83 }
    79 ec_slave_online_state_t;
    84 ec_slave_online_state_t;
    95 };
   100 };
    96 
   101 
    97 /*****************************************************************************/
   102 /*****************************************************************************/
    98 
   103 
    99 /**
   104 /**
   100    Sync manager configuration (EEPROM).
   105    Sync manager.
   101 */
   106 */
   102 
   107 
   103 typedef struct
   108 typedef struct
   104 {
   109 {
   105     unsigned int index; /**< sync manager index */
   110     unsigned int index; /**< sync manager index */
   106     uint16_t physical_start_address; /**< physical start address */
   111     uint16_t physical_start_address; /**< physical start address */
   107     uint16_t length; /**< data length in bytes */
   112     uint16_t length; /**< data length in bytes */
   108     uint8_t control_register; /**< control register value */
   113     uint8_t control_register; /**< control register value */
   109     uint8_t enable; /**< enable bit */
   114     uint8_t enable; /**< enable bit */
       
   115 
   110     uint16_t est_length; /**< Estimated length. This is no field of the SII,
   116     uint16_t est_length; /**< Estimated length. This is no field of the SII,
   111                             but it is used to calculate the length via
   117                             but it is used to calculate the length via
   112                             PDO ranges */
   118                             PDO ranges */
   113 }
   119 }
   114 ec_sii_sync_t;
   120 ec_sync_t;
   115 
   121 
   116 /*****************************************************************************/
   122 /*****************************************************************************/
   117 
   123 
   118 /**
   124 /**
   119    PDO type.
   125    PDO type.
   167 
   173 
   168 typedef struct
   174 typedef struct
   169 {
   175 {
   170     unsigned int index; /**< FMMU index */
   176     unsigned int index; /**< FMMU index */
   171     const ec_domain_t *domain; /**< domain */
   177     const ec_domain_t *domain; /**< domain */
   172     const ec_sii_sync_t *sync; /**< sync manager */
   178     const ec_sync_t *sync; /**< sync manager */
   173     uint32_t logical_start_address; /**< logical start address */
   179     uint32_t logical_start_address; /**< logical start address */
   174 }
   180 }
   175 ec_fmmu_t;
   181 ec_fmmu_t;
   176 
   182 
   177 /*****************************************************************************/
   183 /*****************************************************************************/
   226     uint16_t sii_tx_mailbox_size; /**< mailbox size (slave to master) */
   232     uint16_t sii_tx_mailbox_size; /**< mailbox size (slave to master) */
   227     uint16_t sii_mailbox_protocols; /**< supported mailbox protocols */
   233     uint16_t sii_mailbox_protocols; /**< supported mailbox protocols */
   228     uint8_t sii_physical_layer[4]; /**< port media */
   234     uint8_t sii_physical_layer[4]; /**< port media */
   229     char **sii_strings; /**< strings in EEPROM categories */
   235     char **sii_strings; /**< strings in EEPROM categories */
   230     unsigned int sii_string_count; /**< number of EEPROM strings */
   236     unsigned int sii_string_count; /**< number of EEPROM strings */
   231     ec_sii_sync_t *sii_syncs; /**< EEPROM SYNC MANAGER categories */
   237     ec_sync_t *sii_syncs; /**< EEPROM SYNC MANAGER categories */
   232     unsigned int sii_sync_count; /**< number of sync managers in EEPROM */
   238     unsigned int sii_sync_count; /**< number of sync managers in EEPROM */
   233     struct list_head sii_pdos; /**< EEPROM [RT]XPDO categories */
   239     struct list_head sii_pdos; /**< EEPROM [RT]XPDO categories */
   234     char *sii_group; /**< slave group acc. to EEPROM */
   240     char *sii_group; /**< slave group acc. to EEPROM */
   235     char *sii_image; /**< slave image name acc. to EEPROM */
   241     char *sii_image; /**< slave image name acc. to EEPROM */
   236     char *sii_order; /**< slave order number acc. to EEPROM */
   242     char *sii_order; /**< slave order number acc. to EEPROM */
   254 void ec_slave_destroy(ec_slave_t *);
   260 void ec_slave_destroy(ec_slave_t *);
   255 
   261 
   256 void ec_slave_reset(ec_slave_t *);
   262 void ec_slave_reset(ec_slave_t *);
   257 
   263 
   258 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *,
   264 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *,
   259                           const ec_sii_sync_t *);
   265         const ec_sync_t *);
   260 
   266 
   261 void ec_slave_request_state(ec_slave_t *, ec_slave_state_t);
   267 void ec_slave_request_state(ec_slave_t *, ec_slave_state_t);
   262 void ec_slave_set_state(ec_slave_t *, ec_slave_state_t);
   268 void ec_slave_set_state(ec_slave_t *, ec_slave_state_t);
   263 void ec_slave_set_online_state(ec_slave_t *, ec_slave_online_state_t);
   269 void ec_slave_set_online_state(ec_slave_t *, ec_slave_online_state_t);
   264 
   270 
   268 int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t);
   274 int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t);
   269 int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t,
   275 int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t,
   270         ec_pdo_type_t);
   276         ec_pdo_type_t);
   271 
   277 
   272 // misc.
   278 // misc.
   273 ec_sii_sync_t *ec_slave_get_pdo_sync(ec_slave_t *, ec_direction_t); 
   279 ec_sync_t *ec_slave_get_pdo_sync(ec_slave_t *, ec_direction_t); 
   274 void ec_slave_sync_config(const ec_slave_t *, const ec_sii_sync_t *,
   280 void ec_slave_sync_config(const ec_slave_t *, const ec_sync_t *, uint8_t *);
   275         uint8_t *);
       
   276 void ec_slave_fmmu_config(const ec_slave_t *, const ec_fmmu_t *, uint8_t *);
   281 void ec_slave_fmmu_config(const ec_slave_t *, const ec_fmmu_t *, uint8_t *);
   277 uint16_t ec_slave_calc_sync_size(const ec_slave_t *, const ec_sii_sync_t *);
   282 uint16_t ec_slave_calc_sync_size(const ec_slave_t *, const ec_sync_t *);
   278 
   283 
   279 int ec_slave_is_coupler(const ec_slave_t *);
   284 int ec_slave_is_coupler(const ec_slave_t *);
   280 
   285 
   281 int ec_slave_validate(const ec_slave_t *, uint32_t, uint32_t);
   286 int ec_slave_validate(const ec_slave_t *, uint32_t, uint32_t);
   282 
   287