00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00118
00119
00120 #ifndef __ECRT_H__
00121 #define __ECRT_H__
00122
00123 #ifdef __KERNEL__
00124 #include <asm/byteorder.h>
00125 #include <linux/types.h>
00126 #include <linux/time.h>
00127 #else
00128 #include <stdlib.h>
00129 #include <stdint.h>
00130 #include <sys/time.h>
00131 #endif
00132
00133
00134
00135
00136
00139 #define ECRT_VER_MAJOR 1
00140
00143 #define ECRT_VER_MINOR 5
00144
00147 #define ECRT_VERSION(a, b) (((a) << 8) + (b))
00148
00151 #define ECRT_VERSION_MAGIC ECRT_VERSION(ECRT_VER_MAJOR, ECRT_VER_MINOR)
00152
00153
00154
00155
00156
00162 #define EC_HAVE_REDUNDANCY
00163
00168 #define EC_HAVE_EMERGENCY
00169
00176 #define EC_HAVE_REG_ACCESS
00177
00180 #define EC_HAVE_SELECT_REF_CLOCK
00181
00184 #define EC_HAVE_REF_CLOCK_TIME
00185
00188 #define EC_HAVE_REG_BY_POS
00189
00190
00191
00196 #define EC_END ~0U
00197
00200 #define EC_MAX_SYNC_MANAGERS 16
00201
00206 #define EC_MAX_STRING_LENGTH 64
00207
00209 #define EC_MAX_PORTS 4
00210
00219 #define EC_TIMEVAL2NANO(TV) \
00220 (((TV).tv_sec - 946684800ULL) * 1000000000ULL + (TV).tv_usec * 1000ULL)
00221
00226 #define EC_COE_EMERGENCY_MSG_SIZE 8
00227
00228
00229
00230
00231
00232 struct ec_master;
00233 typedef struct ec_master ec_master_t;
00235 struct ec_slave_config;
00236 typedef struct ec_slave_config ec_slave_config_t;
00238 struct ec_domain;
00239 typedef struct ec_domain ec_domain_t;
00241 struct ec_sdo_request;
00242 typedef struct ec_sdo_request ec_sdo_request_t;
00244 struct ec_voe_handler;
00245 typedef struct ec_voe_handler ec_voe_handler_t;
00247 struct ec_reg_request;
00248 typedef struct ec_reg_request ec_reg_request_t;
00250
00251
00258 typedef struct {
00259 unsigned int slaves_responding;
00261 unsigned int al_states : 4;
00270 unsigned int link_up : 1;
00272 } ec_master_state_t;
00273
00274
00275
00282 typedef struct {
00283 unsigned int slaves_responding;
00285 unsigned int al_states : 4;
00294 unsigned int link_up : 1;
00296 } ec_master_link_state_t;
00297
00298
00299
00306 typedef struct {
00307 unsigned int online : 1;
00308 unsigned int operational : 1;
00310 unsigned int al_state : 4;
00318 } ec_slave_config_state_t;
00319
00320
00321
00328 typedef struct {
00329 unsigned int slave_count;
00330 unsigned int link_up : 1;
00331 uint8_t scan_busy;
00332 uint64_t app_time;
00333 } ec_master_info_t;
00334
00335
00336
00339 typedef enum {
00340 EC_PORT_NOT_IMPLEMENTED,
00341 EC_PORT_NOT_CONFIGURED,
00342 EC_PORT_EBUS,
00343 EC_PORT_MII
00344 } ec_slave_port_desc_t;
00345
00346
00347
00350 typedef struct {
00351 uint8_t link_up;
00352 uint8_t loop_closed;
00353 uint8_t signal_detected;
00354 } ec_slave_port_link_t;
00355
00356
00357
00364 typedef struct {
00365 uint16_t position;
00366 uint32_t vendor_id;
00367 uint32_t product_code;
00368 uint32_t revision_number;
00369 uint32_t serial_number;
00370 uint16_t alias;
00371 int16_t current_on_ebus;
00372 struct {
00373 ec_slave_port_desc_t desc;
00374 ec_slave_port_link_t link;
00375 uint32_t receive_time;
00377 uint16_t next_slave;
00379 uint32_t delay_to_next_dc;
00380 } ports[EC_MAX_PORTS];
00381 uint8_t al_state;
00382 uint8_t error_flag;
00383 uint8_t sync_count;
00384 uint16_t sdo_count;
00385 char name[EC_MAX_STRING_LENGTH];
00386 } ec_slave_info_t;
00387
00388
00389
00394 typedef enum {
00395 EC_WC_ZERO = 0,
00396 EC_WC_INCOMPLETE,
00398 EC_WC_COMPLETE
00399 } ec_wc_state_t;
00400
00401
00402
00407 typedef struct {
00408 unsigned int working_counter;
00409 ec_wc_state_t wc_state;
00410 unsigned int redundancy_active;
00411 } ec_domain_state_t;
00412
00413
00414
00417 typedef enum {
00418 EC_DIR_INVALID,
00419 EC_DIR_OUTPUT,
00420 EC_DIR_INPUT,
00421 EC_DIR_COUNT
00422 } ec_direction_t;
00423
00424
00425
00430 typedef enum {
00431 EC_WD_DEFAULT,
00432 EC_WD_ENABLE,
00433 EC_WD_DISABLE,
00434 } ec_watchdog_mode_t;
00435
00436
00437
00444 typedef struct {
00445 uint16_t index;
00446 uint8_t subindex;
00447 uint8_t bit_length;
00448 } ec_pdo_entry_info_t;
00449
00450
00451
00458 typedef struct {
00459 uint16_t index;
00460 unsigned int n_entries;
00464 ec_pdo_entry_info_t *entries;
00467 } ec_pdo_info_t;
00468
00469
00470
00477 typedef struct {
00478 uint8_t index;
00481 ec_direction_t dir;
00482 unsigned int n_pdos;
00483 ec_pdo_info_t *pdos;
00485 ec_watchdog_mode_t watchdog_mode;
00486 } ec_sync_info_t;
00487
00488
00489
00495 typedef struct {
00496 uint16_t alias;
00497 uint16_t position;
00498 uint32_t vendor_id;
00499 uint32_t product_code;
00500 uint16_t index;
00501 uint8_t subindex;
00502 unsigned int *offset;
00504 unsigned int *bit_position;
00508 } ec_pdo_entry_reg_t;
00509
00510
00511
00517 typedef enum {
00518 EC_REQUEST_UNUSED,
00519 EC_REQUEST_BUSY,
00520 EC_REQUEST_SUCCESS,
00521 EC_REQUEST_ERROR,
00522 } ec_request_state_t;
00523
00524
00525
00528 typedef enum {
00529 EC_AL_STATE_INIT = 1,
00530 EC_AL_STATE_PREOP = 2,
00531 EC_AL_STATE_SAFEOP = 4,
00532 EC_AL_STATE_OP = 8,
00533 } ec_al_state_t;
00534
00535
00536
00537
00538
00539 #ifdef __cplusplus
00540 extern "C" {
00541 #endif
00542
00547 unsigned int ecrt_version_magic(void);
00548
00564 ec_master_t *ecrt_request_master(
00565 unsigned int master_index
00566 );
00567
00568 #ifndef __KERNEL__
00569
00581 ec_master_t *ecrt_open_master(
00582 unsigned int master_index
00583 );
00584
00585 #endif // #ifndef __KERNEL__
00586
00597 void ecrt_release_master(
00598 ec_master_t *master
00599 );
00600
00601
00602
00603
00604
00605 #ifndef __KERNEL__
00606
00614 int ecrt_master_reserve(
00615 ec_master_t *master
00616 );
00617
00618 #endif // #ifndef __KERNEL__
00619
00620 #ifdef __KERNEL__
00621
00639 void ecrt_master_callbacks(
00640 ec_master_t *master,
00641 void (*send_cb)(void *),
00642 void (*receive_cb)(void *),
00643 void *cb_data
00645 );
00646
00647 #endif
00648
00661 ec_domain_t *ecrt_master_create_domain(
00662 ec_master_t *master
00663 );
00664
00695 ec_slave_config_t *ecrt_master_slave_config(
00696 ec_master_t *master,
00697 uint16_t alias,
00698 uint16_t position,
00699 uint32_t vendor_id,
00700 uint32_t product_code
00701 );
00702
00711 int ecrt_master_select_reference_clock(
00712 ec_master_t *master,
00713 ec_slave_config_t *sc
00715 );
00716
00726 int ecrt_master(
00727 ec_master_t *master,
00728 ec_master_info_t *master_info
00730 );
00731
00742 int ecrt_master_get_slave(
00743 ec_master_t *master,
00744 uint16_t slave_position,
00745 ec_slave_info_t *slave_info
00747 );
00748
00749 #ifndef __KERNEL__
00750
00759 int ecrt_master_get_sync_manager(
00760 ec_master_t *master,
00761 uint16_t slave_position,
00762 uint8_t sync_index,
00764 ec_sync_info_t *sync
00765 );
00766
00776 int ecrt_master_get_pdo(
00777 ec_master_t *master,
00778 uint16_t slave_position,
00779 uint8_t sync_index,
00781 uint16_t pos,
00782 ec_pdo_info_t *pdo
00783 );
00784
00792 int ecrt_master_get_pdo_entry(
00793 ec_master_t *master,
00794 uint16_t slave_position,
00795 uint8_t sync_index,
00797 uint16_t pdo_pos,
00798 uint16_t entry_pos,
00799 ec_pdo_entry_info_t *entry
00800 );
00801
00802 #endif
00803
00813 int ecrt_master_sdo_download(
00814 ec_master_t *master,
00815 uint16_t slave_position,
00816 uint16_t index,
00817 uint8_t subindex,
00818 uint8_t *data,
00819 size_t data_size,
00820 uint32_t *abort_code
00821 );
00822
00833 int ecrt_master_sdo_download_complete(
00834 ec_master_t *master,
00835 uint16_t slave_position,
00836 uint16_t index,
00837 uint8_t *data,
00838 size_t data_size,
00839 uint32_t *abort_code
00840 );
00841
00851 int ecrt_master_sdo_upload(
00852 ec_master_t *master,
00853 uint16_t slave_position,
00854 uint16_t index,
00855 uint8_t subindex,
00856 uint8_t *target,
00857 size_t target_size,
00858 size_t *result_size,
00859 uint32_t *abort_code
00860 );
00861
00870 int ecrt_master_write_idn(
00871 ec_master_t *master,
00872 uint16_t slave_position,
00873 uint8_t drive_no,
00874 uint16_t idn,
00875 uint8_t *data,
00876 size_t data_size,
00877 uint16_t *error_code
00879 );
00880
00889 int ecrt_master_read_idn(
00890 ec_master_t *master,
00891 uint16_t slave_position,
00892 uint8_t drive_no,
00893 uint16_t idn,
00894 uint8_t *target,
00896 size_t target_size,
00897 size_t *result_size,
00898 uint16_t *error_code
00900 );
00901
00919 int ecrt_master_activate(
00920 ec_master_t *master
00921 );
00922
00933 void ecrt_master_deactivate(
00934 ec_master_t *master
00935 );
00936
00947 int ecrt_master_set_send_interval(
00948 ec_master_t *master,
00949 size_t send_interval
00950 );
00951
00960 void ecrt_master_send(
00961 ec_master_t *master
00962 );
00963
00974 void ecrt_master_receive(
00975 ec_master_t *master
00976 );
00977
00983 void ecrt_master_send_ext(
00984 ec_master_t *master
00985 );
00986
00994 void ecrt_master_state(
00995 const ec_master_t *master,
00996 ec_master_state_t *state
00997 );
00998
01005 int ecrt_master_link_state(
01006 const ec_master_t *master,
01007 unsigned int dev_idx,
01009 ec_master_link_state_t *state
01011 );
01012
01033 void ecrt_master_application_time(
01034 ec_master_t *master,
01035 uint64_t app_time
01036 );
01037
01043 void ecrt_master_sync_reference_clock(
01044 ec_master_t *master
01045 );
01046
01051 void ecrt_master_sync_slave_clocks(
01052 ec_master_t *master
01053 );
01054
01071 int ecrt_master_reference_clock_time(
01072 ec_master_t *master,
01073 uint32_t *time
01074 );
01075
01082 void ecrt_master_sync_monitor_queue(
01083 ec_master_t *master
01084 );
01085
01094 uint32_t ecrt_master_sync_monitor_process(
01095 ec_master_t *master
01096 );
01097
01105 void ecrt_master_reset(
01106 ec_master_t *master
01107 );
01108
01109
01110
01111
01112
01123 int ecrt_slave_config_sync_manager(
01124 ec_slave_config_t *sc,
01125 uint8_t sync_index,
01127 ec_direction_t direction,
01128 ec_watchdog_mode_t watchdog_mode
01129 );
01130
01136 void ecrt_slave_config_watchdog(
01137 ec_slave_config_t *sc,
01138 uint16_t watchdog_divider,
01142 uint16_t watchdog_intervals
01146 );
01147
01156 int ecrt_slave_config_pdo_assign_add(
01157 ec_slave_config_t *sc,
01158 uint8_t sync_index,
01160 uint16_t index
01161 );
01162
01174 void ecrt_slave_config_pdo_assign_clear(
01175 ec_slave_config_t *sc,
01176 uint8_t sync_index
01178 );
01179
01188 int ecrt_slave_config_pdo_mapping_add(
01189 ec_slave_config_t *sc,
01190 uint16_t pdo_index,
01191 uint16_t entry_index,
01193 uint8_t entry_subindex,
01195 uint8_t entry_bit_length
01196 );
01197
01208 void ecrt_slave_config_pdo_mapping_clear(
01209 ec_slave_config_t *sc,
01210 uint16_t pdo_index
01211 );
01212
01284 int ecrt_slave_config_pdos(
01285 ec_slave_config_t *sc,
01286 unsigned int n_syncs,
01288 const ec_sync_info_t syncs[]
01290 );
01291
01310 int ecrt_slave_config_reg_pdo_entry(
01311 ec_slave_config_t *sc,
01312 uint16_t entry_index,
01313 uint8_t entry_subindex,
01314 ec_domain_t *domain,
01315 unsigned int *bit_position
01317 );
01318
01332 int ecrt_slave_config_reg_pdo_entry_pos(
01333 ec_slave_config_t *sc,
01334 uint8_t sync_index,
01335 unsigned int pdo_pos,
01336 unsigned int entry_pos,
01337 ec_domain_t *domain,
01338 unsigned int *bit_position
01340 );
01341
01356 void ecrt_slave_config_dc(
01357 ec_slave_config_t *sc,
01358 uint16_t assign_activate,
01359 uint32_t sync0_cycle,
01360 int32_t sync0_shift,
01361 uint32_t sync1_cycle,
01362 int32_t sync1_shift
01363 );
01364
01390 int ecrt_slave_config_sdo(
01391 ec_slave_config_t *sc,
01392 uint16_t index,
01393 uint8_t subindex,
01394 const uint8_t *data,
01395 size_t size
01396 );
01397
01408 int ecrt_slave_config_sdo8(
01409 ec_slave_config_t *sc,
01410 uint16_t sdo_index,
01411 uint8_t sdo_subindex,
01412 uint8_t value
01413 );
01414
01425 int ecrt_slave_config_sdo16(
01426 ec_slave_config_t *sc,
01427 uint16_t sdo_index,
01428 uint8_t sdo_subindex,
01429 uint16_t value
01430 );
01431
01442 int ecrt_slave_config_sdo32(
01443 ec_slave_config_t *sc,
01444 uint16_t sdo_index,
01445 uint8_t sdo_subindex,
01446 uint32_t value
01447 );
01448
01462 int ecrt_slave_config_complete_sdo(
01463 ec_slave_config_t *sc,
01464 uint16_t index,
01465 const uint8_t *data,
01466 size_t size
01467 );
01468
01479 int ecrt_slave_config_emerg_size(
01480 ec_slave_config_t *sc,
01481 size_t elements
01482 );
01483
01495 int ecrt_slave_config_emerg_pop(
01496 ec_slave_config_t *sc,
01497 uint8_t *target
01499 );
01500
01505 int ecrt_slave_config_emerg_clear(
01506 ec_slave_config_t *sc
01507 );
01508
01517 int ecrt_slave_config_emerg_overruns(
01518 ec_slave_config_t *sc
01519 );
01520
01531 ec_sdo_request_t *ecrt_slave_config_create_sdo_request(
01532 ec_slave_config_t *sc,
01533 uint16_t index,
01534 uint8_t subindex,
01535 size_t size
01536 );
01537
01553 ec_voe_handler_t *ecrt_slave_config_create_voe_handler(
01554 ec_slave_config_t *sc,
01555 size_t size
01556 );
01557
01572 ec_reg_request_t *ecrt_slave_config_create_reg_request(
01573 ec_slave_config_t *sc,
01574 size_t size
01575 );
01576
01586 void ecrt_slave_config_state(
01587 const ec_slave_config_t *sc,
01588 ec_slave_config_state_t *state
01589 );
01590
01613 int ecrt_slave_config_idn(
01614 ec_slave_config_t *sc,
01615 uint8_t drive_no,
01616 uint16_t idn,
01617 ec_al_state_t state,
01619 const uint8_t *data,
01620 size_t size
01621 );
01622
01623
01624
01625
01626
01638 int ecrt_domain_reg_pdo_entry_list(
01639 ec_domain_t *domain,
01640 const ec_pdo_entry_reg_t *pdo_entry_regs
01642 );
01643
01648 size_t ecrt_domain_size(
01649 const ec_domain_t *domain
01650 );
01651
01652 #ifdef __KERNEL__
01653
01666 void ecrt_domain_external_memory(
01667 ec_domain_t *domain,
01668 uint8_t *memory
01670 );
01671
01672 #endif
01673
01687 uint8_t *ecrt_domain_data(
01688 ec_domain_t *domain
01689 );
01690
01698 void ecrt_domain_process(
01699 ec_domain_t *domain
01700 );
01701
01707 void ecrt_domain_queue(
01708 ec_domain_t *domain
01709 );
01710
01717 void ecrt_domain_state(
01718 const ec_domain_t *domain,
01719 ec_domain_state_t *state
01721 );
01722
01723
01724
01725
01726
01733 void ecrt_sdo_request_index(
01734 ec_sdo_request_t *req,
01735 uint16_t index,
01736 uint8_t subindex
01737 );
01738
01747 void ecrt_sdo_request_timeout(
01748 ec_sdo_request_t *req,
01749 uint32_t timeout
01751 );
01752
01776 uint8_t *ecrt_sdo_request_data(
01777 ec_sdo_request_t *req
01778 );
01779
01788 size_t ecrt_sdo_request_data_size(
01789 const ec_sdo_request_t *req
01790 );
01791
01796 #ifdef __KERNEL__
01797 ec_request_state_t ecrt_sdo_request_state(
01798 const ec_sdo_request_t *req
01799 );
01800 #else
01801 ec_request_state_t ecrt_sdo_request_state(
01802 ec_sdo_request_t *req
01803 );
01804 #endif
01805
01811 void ecrt_sdo_request_write(
01812 ec_sdo_request_t *req
01813 );
01814
01824 void ecrt_sdo_request_read(
01825 ec_sdo_request_t *req
01826 );
01827
01828
01829
01830
01831
01839 void ecrt_voe_handler_send_header(
01840 ec_voe_handler_t *voe,
01841 uint32_t vendor_id,
01842 uint16_t vendor_type
01843 );
01844
01853 void ecrt_voe_handler_received_header(
01854 const ec_voe_handler_t *voe,
01855 uint32_t *vendor_id,
01856 uint16_t *vendor_type
01857 );
01858
01879 uint8_t *ecrt_voe_handler_data(
01880 ec_voe_handler_t *voe
01881 );
01882
01895 size_t ecrt_voe_handler_data_size(
01896 const ec_voe_handler_t *voe
01897 );
01898
01905 void ecrt_voe_handler_write(
01906 ec_voe_handler_t *voe,
01907 size_t size
01908 );
01909
01924 void ecrt_voe_handler_read(
01925 ec_voe_handler_t *voe
01926 );
01927
01943 void ecrt_voe_handler_read_nosync(
01944 ec_voe_handler_t *voe
01945 );
01946
01954 ec_request_state_t ecrt_voe_handler_execute(
01955 ec_voe_handler_t *voe
01956 );
01957
01958
01959
01960
01961
01981 uint8_t *ecrt_reg_request_data(
01982 ec_reg_request_t *req
01983 );
01984
01989 #ifdef __KERNEL__
01990 ec_request_state_t ecrt_reg_request_state(
01991 const ec_reg_request_t *req
01992 );
01993 #else
01994 ec_request_state_t ecrt_reg_request_state(
01995 ec_reg_request_t *req
01996 );
01997 #endif
01998
02007 void ecrt_reg_request_write(
02008 ec_reg_request_t *req,
02009 uint16_t address,
02010 size_t size
02011 );
02012
02021 void ecrt_reg_request_read(
02022 ec_reg_request_t *req,
02023 uint16_t address,
02024 size_t size
02025 );
02026
02027
02028
02029 #ifdef __cplusplus
02030 }
02031 #endif
02032
02033
02034
02035
02036
02042 #define EC_READ_BIT(DATA, POS) ((*((uint8_t *) (DATA)) >> (POS)) & 0x01)
02043
02050 #define EC_WRITE_BIT(DATA, POS, VAL) \
02051 do { \
02052 if (VAL) *((uint8_t *) (DATA)) |= (1 << (POS)); \
02053 else *((uint8_t *) (DATA)) &= ~(1 << (POS)); \
02054 } while (0)
02055
02056
02057
02058
02059
02060 #ifndef __KERNEL__
02061
02062 #if __BYTE_ORDER == __LITTLE_ENDIAN
02063
02064 #define le16_to_cpu(x) x
02065 #define le32_to_cpu(x) x
02066 #define le64_to_cpu(x) x
02067
02068 #define cpu_to_le16(x) x
02069 #define cpu_to_le32(x) x
02070 #define cpu_to_le64(x) x
02071
02072 #elif __BYTE_ORDER == __BIG_ENDIAN
02073
02074 #define swap16(x) \
02075 ((uint16_t)( \
02076 (((uint16_t)(x) & 0x00ffU) << 8) | \
02077 (((uint16_t)(x) & 0xff00U) >> 8) ))
02078 #define swap32(x) \
02079 ((uint32_t)( \
02080 (((uint32_t)(x) & 0x000000ffUL) << 24) | \
02081 (((uint32_t)(x) & 0x0000ff00UL) << 8) | \
02082 (((uint32_t)(x) & 0x00ff0000UL) >> 8) | \
02083 (((uint32_t)(x) & 0xff000000UL) >> 24) ))
02084 #define swap64(x) \
02085 ((uint64_t)( \
02086 (((uint64_t)(x) & 0x00000000000000ffULL) << 56) | \
02087 (((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
02088 (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
02089 (((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
02090 (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
02091 (((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
02092 (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
02093 (((uint64_t)(x) & 0xff00000000000000ULL) >> 56) ))
02094
02095 #define le16_to_cpu(x) swap16(x)
02096 #define le32_to_cpu(x) swap32(x)
02097 #define le64_to_cpu(x) swap64(x)
02098
02099 #define cpu_to_le16(x) swap16(x)
02100 #define cpu_to_le32(x) swap32(x)
02101 #define cpu_to_le64(x) swap64(x)
02102
02103 #endif
02104
02105 #define le16_to_cpup(x) le16_to_cpu(*((uint16_t *)(x)))
02106 #define le32_to_cpup(x) le32_to_cpu(*((uint32_t *)(x)))
02107 #define le64_to_cpup(x) le64_to_cpu(*((uint64_t *)(x)))
02108
02109 #endif
02110
02111
02112
02113
02114
02119 #define EC_READ_U8(DATA) \
02120 ((uint8_t) *((uint8_t *) (DATA)))
02121
02127 #define EC_READ_S8(DATA) \
02128 ((int8_t) *((uint8_t *) (DATA)))
02129
02135 #define EC_READ_U16(DATA) \
02136 ((uint16_t) le16_to_cpup((void *) (DATA)))
02137
02143 #define EC_READ_S16(DATA) \
02144 ((int16_t) le16_to_cpup((void *) (DATA)))
02145
02151 #define EC_READ_U32(DATA) \
02152 ((uint32_t) le32_to_cpup((void *) (DATA)))
02153
02159 #define EC_READ_S32(DATA) \
02160 ((int32_t) le32_to_cpup((void *) (DATA)))
02161
02167 #define EC_READ_U64(DATA) \
02168 ((uint64_t) le64_to_cpup((void *) (DATA)))
02169
02175 #define EC_READ_S64(DATA) \
02176 ((int64_t) le64_to_cpup((void *) (DATA)))
02177
02178
02179
02180
02181
02187 #define EC_WRITE_U8(DATA, VAL) \
02188 do { \
02189 *((uint8_t *)(DATA)) = ((uint8_t) (VAL)); \
02190 } while (0)
02191
02197 #define EC_WRITE_S8(DATA, VAL) EC_WRITE_U8(DATA, VAL)
02198
02204 #define EC_WRITE_U16(DATA, VAL) \
02205 do { \
02206 *((uint16_t *) (DATA)) = cpu_to_le16((uint16_t) (VAL)); \
02207 } while (0)
02208
02214 #define EC_WRITE_S16(DATA, VAL) EC_WRITE_U16(DATA, VAL)
02215
02221 #define EC_WRITE_U32(DATA, VAL) \
02222 do { \
02223 *((uint32_t *) (DATA)) = cpu_to_le32((uint32_t) (VAL)); \
02224 } while (0)
02225
02231 #define EC_WRITE_S32(DATA, VAL) EC_WRITE_U32(DATA, VAL)
02232
02238 #define EC_WRITE_U64(DATA, VAL) \
02239 do { \
02240 *((uint64_t *) (DATA)) = cpu_to_le64((uint64_t) (VAL)); \
02241 } while (0)
02242
02248 #define EC_WRITE_S64(DATA, VAL) EC_WRITE_U64(DATA, VAL)
02249
02250
02251
02254 #endif