|
|
@ -16,20 +16,17 @@ void USIPO_loadBinary(Unit *unit, PayloadParser *pp) |
|
|
|
uint8_t version = pp_u8(pp); |
|
|
|
uint8_t version = pp_u8(pp); |
|
|
|
(void)version; |
|
|
|
(void)version; |
|
|
|
|
|
|
|
|
|
|
|
priv->store_pname = pp_char(pp); |
|
|
|
priv->cfg.pin_store = (Resource) pp_u8(pp); |
|
|
|
priv->store_pnum = pp_u8(pp); |
|
|
|
priv->cfg.store_pol = pp_bool(pp); |
|
|
|
priv->store_pol = pp_bool(pp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
priv->shift_pname = pp_char(pp); |
|
|
|
priv->cfg.pin_shift = (Resource) pp_u8(pp); |
|
|
|
priv->shift_pnum = pp_u8(pp); |
|
|
|
priv->cfg.shift_pol = pp_bool(pp); |
|
|
|
priv->shift_pol = pp_bool(pp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
priv->clear_pname = pp_char(pp); |
|
|
|
priv->cfg.pin_clear = (Resource) pp_u8(pp); |
|
|
|
priv->clear_pnum = pp_u8(pp); |
|
|
|
priv->cfg.clear_pol = pp_bool(pp); |
|
|
|
priv->clear_pol = pp_bool(pp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
priv->data_pname = pp_char(pp); |
|
|
|
priv->cfg.data_pname = pp_char(pp); |
|
|
|
priv->data_pins = pp_u16(pp); |
|
|
|
priv->cfg.data_pins = pp_u16(pp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Write to a binary buffer for storing in Flash */ |
|
|
|
/** Write to a binary buffer for storing in Flash */ |
|
|
@ -39,20 +36,17 @@ void USIPO_writeBinary(Unit *unit, PayloadBuilder *pb) |
|
|
|
|
|
|
|
|
|
|
|
pb_u8(pb, 0); // version
|
|
|
|
pb_u8(pb, 0); // version
|
|
|
|
|
|
|
|
|
|
|
|
pb_char(pb, priv->store_pname); |
|
|
|
pb_u8(pb, priv->cfg.pin_store); |
|
|
|
pb_u8(pb, priv->store_pnum); |
|
|
|
pb_bool(pb, priv->cfg.store_pol); |
|
|
|
pb_bool(pb, priv->store_pol); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pb_char(pb, priv->shift_pname); |
|
|
|
pb_u8(pb, priv->cfg.pin_shift); |
|
|
|
pb_u8(pb, priv->shift_pnum); |
|
|
|
pb_bool(pb, priv->cfg.shift_pol); |
|
|
|
pb_bool(pb, priv->shift_pol); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pb_char(pb, priv->clear_pname); |
|
|
|
pb_u8(pb, priv->cfg.pin_clear); |
|
|
|
pb_u8(pb, priv->clear_pnum); |
|
|
|
pb_bool(pb, priv->cfg.clear_pol); |
|
|
|
pb_bool(pb, priv->clear_pol); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pb_char(pb, priv->data_pname); |
|
|
|
pb_char(pb, priv->cfg.data_pname); |
|
|
|
pb_u16(pb, priv->data_pins); |
|
|
|
pb_u16(pb, priv->cfg.data_pins); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
@ -64,30 +58,30 @@ error_t USIPO_loadIni(Unit *unit, const char *key, const char *value) |
|
|
|
struct priv *priv = unit->data; |
|
|
|
struct priv *priv = unit->data; |
|
|
|
|
|
|
|
|
|
|
|
if (streq(key, "store-pin")) { |
|
|
|
if (streq(key, "store-pin")) { |
|
|
|
suc = cfg_portpin_parse(value, &priv->store_pname, &priv->store_pnum); |
|
|
|
priv->cfg.pin_store = cfg_pinrsc_parse(value, &suc); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (streq(key, "shift-pin")) { |
|
|
|
else if (streq(key, "shift-pin")) { |
|
|
|
suc = cfg_portpin_parse(value, &priv->shift_pname, &priv->shift_pnum); |
|
|
|
priv->cfg.pin_shift = cfg_pinrsc_parse(value, &suc); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (streq(key, "clear-pin")) { |
|
|
|
else if (streq(key, "clear-pin")) { |
|
|
|
suc = cfg_portpin_parse(value, &priv->clear_pname, &priv->clear_pnum); |
|
|
|
priv->cfg.pin_clear = cfg_pinrsc_parse(value, &suc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if (streq(key, "store-pol")) { |
|
|
|
else if (streq(key, "store-pol")) { |
|
|
|
priv->store_pol = cfg_bool_parse(value, &suc); |
|
|
|
priv->cfg.store_pol = cfg_bool_parse(value, &suc); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (streq(key, "shift-pol")) { |
|
|
|
else if (streq(key, "shift-pol")) { |
|
|
|
priv->shift_pol = cfg_bool_parse(value, &suc); |
|
|
|
priv->cfg.shift_pol = cfg_bool_parse(value, &suc); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (streq(key, "clear-pol")) { |
|
|
|
else if (streq(key, "clear-pol")) { |
|
|
|
priv->clear_pol = cfg_bool_parse(value, &suc); |
|
|
|
priv->cfg.clear_pol = cfg_bool_parse(value, &suc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if (streq(key, "data-port")) { |
|
|
|
else if (streq(key, "data-port")) { |
|
|
|
suc = cfg_port_parse(value, &priv->data_pname); |
|
|
|
suc = cfg_port_parse(value, &priv->cfg.data_pname); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (streq(key, "data-pins")) { |
|
|
|
else if (streq(key, "data-pins")) { |
|
|
|
priv->data_pins = cfg_pinmask_parse(value, &suc); |
|
|
|
priv->cfg.data_pins = cfg_pinmask_parse(value, &suc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else { |
|
|
|
else { |
|
|
@ -104,19 +98,19 @@ void USIPO_writeIni(Unit *unit, IniWriter *iw) |
|
|
|
struct priv *priv = unit->data; |
|
|
|
struct priv *priv = unit->data; |
|
|
|
|
|
|
|
|
|
|
|
iw_comment(iw, "Shift pin & its active edge (1-rising,0-falling)"); |
|
|
|
iw_comment(iw, "Shift pin & its active edge (1-rising,0-falling)"); |
|
|
|
iw_entry(iw, "shift-pin", "%c%d", priv->shift_pname, priv->shift_pnum); |
|
|
|
iw_entry(iw, "shift-pin", cfg_pinrsc_encode(priv->cfg.pin_shift)); |
|
|
|
iw_entry(iw, "shift-pol", "%d", priv->shift_pol); |
|
|
|
iw_entry(iw, "shift-pol", "%d", priv->cfg.shift_pol); |
|
|
|
|
|
|
|
|
|
|
|
iw_comment(iw, "Store pin & its active edge"); |
|
|
|
iw_comment(iw, "Store pin & its active edge"); |
|
|
|
iw_entry(iw, "store-pin", "%c%d", priv->store_pname, priv->store_pnum); |
|
|
|
iw_entry(iw, "store-pin", cfg_pinrsc_encode(priv->cfg.pin_store)); |
|
|
|
iw_entry(iw, "store-pol", "%d", priv->store_pol); |
|
|
|
iw_entry(iw, "store-pol", "%d", priv->cfg.store_pol); |
|
|
|
|
|
|
|
|
|
|
|
iw_comment(iw, "Clear pin & its active level"); |
|
|
|
iw_comment(iw, "Clear pin & its active level"); |
|
|
|
iw_entry(iw, "clear-pin", "%c%d", priv->clear_pname, priv->clear_pnum); |
|
|
|
iw_entry(iw, "clear-pin", cfg_pinrsc_encode(priv->cfg.pin_clear)); |
|
|
|
iw_entry(iw, "clear-pol", "%d", priv->clear_pol); |
|
|
|
iw_entry(iw, "clear-pol", "%d", priv->cfg.clear_pol); |
|
|
|
|
|
|
|
|
|
|
|
iw_comment(iw, "Data port and pins"); |
|
|
|
iw_comment(iw, "Data port and pins"); |
|
|
|
iw_entry(iw, "data-port", "%c", priv->data_pname); |
|
|
|
iw_entry(iw, "data-port", "%c", priv->cfg.data_pname); |
|
|
|
iw_entry(iw, "data-pins", "%s", cfg_pinmask_encode(priv->data_pins, unit_tmp512, true)); |
|
|
|
iw_entry(iw, "data-pins", cfg_pinmask_encode(priv->cfg.data_pins, unit_tmp512, true)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|