implemnted el6900 support and fsoe transport

This commit is contained in:
Sascha Ittner
2018-06-27 11:50:35 +02:00
parent 7d318a66d2
commit 0c9f7caea9
7 changed files with 422 additions and 112 deletions

View File

@@ -28,10 +28,10 @@ typedef struct {
hal_u32_t *fsoe_slave_crc;
hal_u32_t *fsoe_slave_connid;
hal_bit_t *fsoe_input_0;
hal_bit_t *fsoe_input_1;
hal_bit_t *fsoe_input_2;
hal_bit_t *fsoe_input_3;
hal_bit_t *fsoe_in_0;
hal_bit_t *fsoe_in_1;
hal_bit_t *fsoe_in_2;
hal_bit_t *fsoe_in_3;
unsigned int fsoe_master_cmd_os;
unsigned int fsoe_master_crc_os;
@@ -41,14 +41,14 @@ typedef struct {
unsigned int fsoe_slave_crc_os;
unsigned int fsoe_slave_connid_os;
unsigned int fsoe_input_0_os;
unsigned int fsoe_input_0_bp;
unsigned int fsoe_input_1_os;
unsigned int fsoe_input_1_bp;
unsigned int fsoe_input_2_os;
unsigned int fsoe_input_2_bp;
unsigned int fsoe_input_3_os;
unsigned int fsoe_input_3_bp;
unsigned int fsoe_in_0_os;
unsigned int fsoe_in_0_bp;
unsigned int fsoe_in_1_os;
unsigned int fsoe_in_1_bp;
unsigned int fsoe_in_2_os;
unsigned int fsoe_in_2_bp;
unsigned int fsoe_in_3_os;
unsigned int fsoe_in_3_bp;
} lcec_el1904_data_t;
@@ -59,15 +59,14 @@ static const lcec_pindesc_t slave_pins[] = {
{ HAL_U32, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_slave_cmd), "%s.%s.%s.fsoe-slave-cmd" },
{ HAL_U32, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_slave_crc), "%s.%s.%s.fsoe-slave-crc" },
{ HAL_U32, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_slave_connid), "%s.%s.%s.fsoe-slave-connid" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_input_0), "%s.%s.%s.fsoe-input-0" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_input_1), "%s.%s.%s.fsoe-input-1" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_input_2), "%s.%s.%s.fsoe-input-2" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_input_3), "%s.%s.%s.fsoe-input-3" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_in_0), "%s.%s.%s.fsoe-in-0" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_in_1), "%s.%s.%s.fsoe-in-1" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_in_2), "%s.%s.%s.fsoe-in-2" },
{ HAL_BIT, HAL_OUT, offsetof(lcec_el1904_data_t, fsoe_in_3), "%s.%s.%s.fsoe-in-3" },
{ HAL_TYPE_UNSPECIFIED, HAL_DIR_UNSPECIFIED, -1, NULL }
};
void lcec_el1904_read(struct lcec_slave *slave, long period);
void lcec_el1904_write(struct lcec_slave *slave, long period);
int lcec_el1904_init(int comp_id, struct lcec_slave *slave, ec_pdo_entry_reg_t *pdo_entry_regs) {
lcec_master_t *master = slave->master;
@@ -76,7 +75,6 @@ int lcec_el1904_init(int comp_id, struct lcec_slave *slave, ec_pdo_entry_reg_t *
// initialize callbacks
slave->proc_read = lcec_el1904_read;
slave->proc_write = lcec_el1904_write;
// alloc hal memory
if ((hal_data = hal_malloc(sizeof(lcec_el1904_data_t))) == NULL) {
@@ -91,10 +89,10 @@ int lcec_el1904_init(int comp_id, struct lcec_slave *slave, ec_pdo_entry_reg_t *
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x7000, 0x02, &hal_data->fsoe_master_crc_os, NULL);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x7000, 0x03, &hal_data->fsoe_master_connid_os, NULL);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6000, 0x01, &hal_data->fsoe_slave_cmd_os, NULL);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x01, &hal_data->fsoe_input_0_os, &hal_data->fsoe_input_0_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x02, &hal_data->fsoe_input_1_os, &hal_data->fsoe_input_1_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x03, &hal_data->fsoe_input_2_os, &hal_data->fsoe_input_2_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x04, &hal_data->fsoe_input_3_os, &hal_data->fsoe_input_3_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x01, &hal_data->fsoe_in_0_os, &hal_data->fsoe_in_0_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x02, &hal_data->fsoe_in_1_os, &hal_data->fsoe_in_1_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x03, &hal_data->fsoe_in_2_os, &hal_data->fsoe_in_2_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6001, 0x04, &hal_data->fsoe_in_3_os, &hal_data->fsoe_in_3_bp);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6000, 0x03, &hal_data->fsoe_slave_crc_os, NULL);
LCEC_PDO_INIT(pdo_entry_regs, slave->index, slave->vid, slave->pid, 0x6000, 0x04, &hal_data->fsoe_slave_connid_os, NULL);
@@ -111,31 +109,19 @@ void lcec_el1904_read(struct lcec_slave *slave, long period) {
lcec_el1904_data_t *hal_data = (lcec_el1904_data_t *) slave->hal_data;
uint8_t *pd = master->process_data;
if (slave->fsoe_slave_offset >= 0) {
memcpy(&pd[slave->fsoe_slave_offset], &pd[hal_data->fsoe_slave_cmd_os], LCEC_FSOE_MSG_LEN);
}
copy_fsoe_data(slave, hal_data->fsoe_slave_cmd_os, hal_data->fsoe_master_cmd_os);
*(hal_data->fsoe_slave_cmd) = EC_READ_U16(&pd[hal_data->fsoe_slave_cmd_os]);
*(hal_data->fsoe_slave_crc) = EC_READ_U16(&pd[hal_data->fsoe_slave_crc_os]);
*(hal_data->fsoe_slave_connid) = EC_READ_U16(&pd[hal_data->fsoe_slave_connid_os]);
*(hal_data->fsoe_input_0) = EC_READ_BIT(&pd[hal_data->fsoe_input_0_os], hal_data->fsoe_input_0_bp);
*(hal_data->fsoe_input_1) = EC_READ_BIT(&pd[hal_data->fsoe_input_1_os], hal_data->fsoe_input_1_bp);
*(hal_data->fsoe_input_2) = EC_READ_BIT(&pd[hal_data->fsoe_input_2_os], hal_data->fsoe_input_2_bp);
*(hal_data->fsoe_input_3) = EC_READ_BIT(&pd[hal_data->fsoe_input_3_os], hal_data->fsoe_input_3_bp);
}
void lcec_el1904_write(struct lcec_slave *slave, long period) {
lcec_master_t *master = slave->master;
lcec_el1904_data_t *hal_data = (lcec_el1904_data_t *) slave->hal_data;
uint8_t *pd = master->process_data;
if (slave->fsoe_master_offset >= 0) {
memcpy(&pd[hal_data->fsoe_master_cmd_os], &pd[slave->fsoe_master_offset], LCEC_FSOE_MSG_LEN);
}
*(hal_data->fsoe_master_cmd) = EC_READ_U16(&pd[hal_data->fsoe_master_cmd_os]);
*(hal_data->fsoe_master_crc) = EC_READ_U16(&pd[hal_data->fsoe_master_crc_os]);
*(hal_data->fsoe_master_connid) = EC_READ_U16(&pd[hal_data->fsoe_master_connid_os]);
*(hal_data->fsoe_in_0) = EC_READ_BIT(&pd[hal_data->fsoe_in_0_os], hal_data->fsoe_in_0_bp);
*(hal_data->fsoe_in_1) = EC_READ_BIT(&pd[hal_data->fsoe_in_1_os], hal_data->fsoe_in_1_bp);
*(hal_data->fsoe_in_2) = EC_READ_BIT(&pd[hal_data->fsoe_in_2_os], hal_data->fsoe_in_2_bp);
*(hal_data->fsoe_in_3) = EC_READ_BIT(&pd[hal_data->fsoe_in_3_os], hal_data->fsoe_in_3_bp);
}