tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/36680?usp=email ) Change subject: fw: Update the helpers in misc.{c,h} for the new tick measurement hw ...................................................................... fw: Update the helpers in misc.{c,h} for the new tick measurement hw Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: Ia881fead7a40f773969a016db05bea0a1fa1604f --- M firmware/ice40-riscv/e1-tracer/misc.c M firmware/ice40-riscv/e1-tracer/misc.h M firmware/ice40-riscv/icE1usb/misc.c M firmware/ice40-riscv/icE1usb/misc.h 4 files changed, 53 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/80/36680/1 diff --git a/firmware/ice40-riscv/e1-tracer/misc.c b/firmware/ice40-riscv/e1-tracer/misc.c index c2e0763..6f5c88a 100644 --- a/firmware/ice40-riscv/e1-tracer/misc.c +++ b/firmware/ice40-riscv/e1-tracer/misc.c @@ -15,10 +15,11 @@ struct misc { uint32_t warmboot; uint32_t _rsvd0[3];; - struct { - uint16_t rx; - uint16_t _rsvd1; - } e1_tick[2]; + union { + uint32_t e1_tick_sel; + uint16_t e1_tick[2]; + }; + uint32_t _rsvd1; struct { uint32_t _rsvd2; uint32_t now; @@ -29,10 +30,15 @@ void -e1_tick_read(uint16_t *ticks) +e1_tick_sel(int type) { - ticks[0] = misc_regs->e1_tick[0].rx; - ticks[1] = misc_regs->e1_tick[1].rx; + misc_regs->e1_tick_sel = (type << 16) | type; +} + +uint16_t +e1_tick_read(int port) +{ + return misc_regs->e1_tick[port]; } diff --git a/firmware/ice40-riscv/e1-tracer/misc.h b/firmware/ice40-riscv/e1-tracer/misc.h index 42dfe51..2944743 100644 --- a/firmware/ice40-riscv/e1-tracer/misc.h +++ b/firmware/ice40-riscv/e1-tracer/misc.h @@ -10,6 +10,14 @@ #include <stdbool.h> #include <stdint.h> -void e1_tick_read(uint16_t *ticks); +enum e1_tick_type { + TICK_TX = 0, + TICK_RX_PULSE = 1, + TICK_RX_SAMPLE = 2, + TICK_RX_ONE = 3, +}; + +void e1_tick_sel(int type); +uint16_t e1_tick_read(int port); void reboot(int fw); diff --git a/firmware/ice40-riscv/icE1usb/misc.c b/firmware/ice40-riscv/icE1usb/misc.c index b8419aa..1445580 100644 --- a/firmware/ice40-riscv/icE1usb/misc.c +++ b/firmware/ice40-riscv/icE1usb/misc.c @@ -21,11 +21,12 @@ uint8_t _rsvd; } gpio; uint32_t e1_led; - uint32_t _rsvd; - struct { - uint16_t rx; - uint16_t tx; - } e1_tick[2]; + uint32_t _rsvd0; + union { + uint32_t e1_tick_sel; + uint16_t e1_tick[2]; + }; + uint32_t _rsvd1; struct { uint32_t pps; uint32_t now; @@ -116,10 +117,16 @@ } +void +e1_tick_sel(int type) +{ + misc_regs->e1_tick_sel = (type << 16) | type; +} + uint16_t e1_tick_read(int port) { - return misc_regs->e1_tick[port].tx; + return misc_regs->e1_tick[port]; } diff --git a/firmware/ice40-riscv/icE1usb/misc.h b/firmware/ice40-riscv/icE1usb/misc.h index b72793f..ca99951 100644 --- a/firmware/ice40-riscv/icE1usb/misc.h +++ b/firmware/ice40-riscv/icE1usb/misc.h @@ -34,6 +34,14 @@ void e1_led_pause(void); void e1_led_set(bool enable, uint8_t cfg); +enum e1_tick_type { + TICK_TX = 0, + TICK_RX_PULSE = 1, + TICK_RX_SAMPLE = 2, + TICK_RX_ONE = 3, +}; + +void e1_tick_sel(int type); uint16_t e1_tick_read(int port); bool time_elapsed(uint32_t ref, unsigned int tick); -- To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/36680?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1-hardware Gerrit-Branch: master Gerrit-Change-Id: Ia881fead7a40f773969a016db05bea0a1fa1604f Gerrit-Change-Number: 36680 Gerrit-PatchSet: 1 Gerrit-Owner: tnt <tnt@246tNt.com> Gerrit-MessageType: newchange