- config.stopbits = stopbits;
- config.rts = flowcontrol == 1 ? SP_RTS_FLOW_CONTROL : rts;
- config.cts = flowcontrol == 1 ? SP_CTS_FLOW_CONTROL : SP_CTS_IGNORE;
- config.dtr = dtr;
- config.dsr = SP_DSR_IGNORE;
- config.xon_xoff = flowcontrol == 2 ? SP_XONXOFF_INOUT : SP_XONXOFF_DISABLED;
-
- ret = sp_set_config(serial->data, &config);
+ sp_set_config_stopbits(config, stopbits);
+ sp_set_config_rts(config, flowcontrol == 1 ? SP_RTS_FLOW_CONTROL : rts);
+ sp_set_config_cts(config, flowcontrol == 1 ? SP_CTS_FLOW_CONTROL : SP_CTS_IGNORE);
+ sp_set_config_dtr(config, dtr);
+ sp_set_config_dsr(config, SP_DSR_IGNORE);
+ sp_set_config_xon_xoff(config, flowcontrol == 2 ? SP_XONXOFF_INOUT : SP_XONXOFF_DISABLED);
+
+ ret = sp_set_config(serial->data, config);
+ sp_free_config(config);