]> sigrok.org Git - libsigrok.git/commitdiff
kingst-la2016: reduce scope of a few more declarations
authorGerhard Sittig <redacted>
Sun, 30 Jan 2022 10:03:27 +0000 (11:03 +0100)
committerGerhard Sittig <redacted>
Sun, 6 Feb 2022 17:53:53 +0000 (18:53 +0100)
Reduce the number of "top level declarations" in the protocol.h header.
Move hardware register related structs and capture data layout literals
to protocol.c where they are exclusively used. Move the capture info (a
set of values which describe the most recently completed acquisition)
into the device context itself.

src/hardware/kingst-la2016/protocol.c
src/hardware/kingst-la2016/protocol.h

index f7e2f208d18d4ee2f5faba7bb95545b13b5a5397..3f9156c49b29c3c47c9500d8eb56bce59d173e67 100644 (file)
@@ -95,6 +95,10 @@ static const struct kingst_model models[] = {
 #define RUNSTATE_TRGD_BIT      (1UL << 2)
 #define RUNSTATE_POST_BIT      (1UL << 3)
 
+/* Properties related to the layout of capture data downloads. */
+#define NUM_PACKETS_IN_CHUNK   5
+#define TRANSFER_PACKET_LENGTH 16
+
 static int ctrl_in(const struct sr_dev_inst *sdi,
        uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
        void *data, uint16_t wLength)
@@ -514,7 +518,12 @@ static int set_trigger_config(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        struct sr_trigger *trigger;
-       struct trigger_cfg cfg;
+       struct trigger_cfg {
+               uint32_t channels;
+               uint32_t enabled;
+               uint32_t level;
+               uint32_t high_or_falling;
+       } cfg;
        GSList *stages;
        GSList *channel;
        struct sr_trigger_stage *stage1;
index 2569da50d5e72b9b6a026cf019b73c5d074305cc..66c0fcbc504720f05b60bc7cfbfce72f5fd2acfc 100644 (file)
@@ -88,22 +88,6 @@ struct kingst_model {
        uint64_t memory_bits;   /* RAM capacity in Gbit (1, 2, 4). */
 };
 
-struct trigger_cfg {
-       uint32_t channels;
-       uint32_t enabled;
-       uint32_t level;
-       uint32_t high_or_falling;
-};
-
-struct capture_info {
-       uint32_t n_rep_packets;
-       uint32_t n_rep_packets_before_trigger;
-       uint32_t write_pos;
-};
-
-#define NUM_PACKETS_IN_CHUNK   5
-#define TRANSFER_PACKET_LENGTH 16
-
 struct dev_context {
        uint16_t usb_pid;
        char *mcu_firmware;
@@ -128,7 +112,11 @@ struct dev_context {
        gboolean trigger_involved;
        gboolean completion_seen;
        gboolean download_finished;
-       struct capture_info info;
+       struct capture_info {
+               uint32_t n_rep_packets;
+               uint32_t n_rep_packets_before_trigger;
+               uint32_t write_pos;
+       } info;
        uint32_t n_transfer_packets_to_read; /* each with 5 acq packets */
        uint32_t n_bytes_to_read;
        uint32_t n_reps_until_trigger;