From: Gerhard Sittig Date: Mon, 31 Jan 2022 20:39:30 +0000 (+0100) Subject: kingst-la2016: keep FPGA active after device close X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=66a24ab57caebf6ba3abc57ee085a6fd0df37616;hp=286b3e13cae38e42e5d8baa02f0cee60411e96c0 kingst-la2016: keep FPGA active after device close When the sigrok driver closes as the application shuts down, acquisition of logic input channels will have completed. Generation of PWM signals on output channels can be desirable to keep up. Do not de-initialize the FPGA hardware in the close code path. Which allows to configure PWM by means of sigrok-cli and use the signals between program invocations that reconfigure the generator. Users can always disable channels before the application shuts down if they prefer to. Similar use was seen with PSUs. Make this approach a compile time option. --- diff --git a/src/hardware/kingst-la2016/api.c b/src/hardware/kingst-la2016/api.c index cab6517b..d9cb9b19 100644 --- a/src/hardware/kingst-la2016/api.c +++ b/src/hardware/kingst-la2016/api.c @@ -671,7 +671,8 @@ static int dev_close(struct sr_dev_inst *sdi) if (!usb->devhdl) return SR_ERR_BUG; - la2016_deinit_hardware(sdi); + if (WITH_DEINIT_IN_CLOSE) + la2016_deinit_hardware(sdi); sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.", usb->bus, usb->address, sdi->connection_id, USB_INTERFACE); diff --git a/src/hardware/kingst-la2016/protocol.h b/src/hardware/kingst-la2016/protocol.h index af640f66..3b251ed1 100644 --- a/src/hardware/kingst-la2016/protocol.h +++ b/src/hardware/kingst-la2016/protocol.h @@ -86,6 +86,14 @@ #define LA2016_NUM_PWMCH_MAX 2 +/* + * Whether to de-initialize the device hardware in the driver's close + * callback. It is desirable to e.g. configure PWM channels and leave + * the generator running after the application shuts down. Users can + * always disable channels on their way out if they want to. + */ +#define WITH_DEINIT_IN_CLOSE 0 + #define LA2016_CONVBUFFER_SIZE (4 * 1024 * 1024) struct kingst_model {