]> sigrok.org Git - libsigrok.git/commitdiff
asix-sigma: more u16 sample memory access nits (timestamps, values)
authorGerhard Sittig <redacted>
Wed, 13 May 2020 16:26:54 +0000 (18:26 +0200)
committerGerhard Sittig <redacted>
Fri, 29 May 2020 05:50:33 +0000 (07:50 +0200)
Further "flatten" the DRAM layout's declaration for sample data. Declare
timestamps and sample data as uint16_t, keep accessing them via endianess
aware conversion routines. Accessing a larger integer in smaller quantities
is perfectly fine, the inverse direction would be problematic.

src/hardware/asix-sigma/protocol.c
src/hardware/asix-sigma/protocol.h

index 1875b75658d8358f4a41938f5e0a6c9d64d23476..f052c51cc6091ece3ff8dc0160d771a1df6ca57a 100644 (file)
@@ -1121,7 +1121,7 @@ static int check_and_submit_sample(struct dev_context *devc,
  */
 static uint16_t sigma_dram_cluster_ts(struct sigma_dram_cluster *cluster)
 {
-       return read_u16le(&cluster->timestamp[0]);
+       return read_u16le((const uint8_t *)&cluster->timestamp);
 }
 
 /*
@@ -1129,7 +1129,7 @@ static uint16_t sigma_dram_cluster_ts(struct sigma_dram_cluster *cluster)
  */
 static uint16_t sigma_dram_cluster_data(struct sigma_dram_cluster *cl, int idx)
 {
-       return read_u16le(&cl->samples[idx].sample[0]);
+       return read_u16le((const uint8_t *)&cl->samples[idx]);
 }
 
 /*
index 64b8a02c89b91b4a7ddd8abc667974e5eb96c7f0..8c4f2dfbc2fd2a2902fe4cddcecebe2b8e9b358c 100644 (file)
@@ -205,10 +205,8 @@ enum sigma_read_register {
 
 struct sigma_dram_line {
        struct sigma_dram_cluster {
-               uint8_t timestamp[sizeof(uint16_t)];
-               struct sigma_dram_event {
-                       uint8_t sample[sizeof(uint16_t)];
-               } samples[EVENTS_PER_CLUSTER];
+               uint16_t timestamp;
+               uint16_t samples[EVENTS_PER_CLUSTER];
        } cluster[CLUSTERS_PER_ROW];
 };