From cd4342670f0ddc38eb2a40fd94f68c2f26a8861b Mon Sep 17 00:00:00 2001 From: Jonas Schumacher Date: Fri, 24 Mar 2023 11:29:35 +0100 Subject: [PATCH] Fix mapping of in and out for dios (#57) * Add pause to have a slightly longer counter trigger reset time * Possibly fix mapping * Final fix * Fix doubled part --- src/client/julia/src/CounterTrigger.jl | 1 + src/lib/rp-daq-lib.c | 10 +++++----- src/lib/rp-daq-lib.h | 4 ++-- src/server/scpi_commands.c | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/client/julia/src/CounterTrigger.jl b/src/client/julia/src/CounterTrigger.jl index 9ed76ce9..d627e926 100644 --- a/src/client/julia/src/CounterTrigger.jl +++ b/src/client/julia/src/CounterTrigger.jl @@ -156,6 +156,7 @@ true counterTrigger_reset!(rp::RedPitaya, val) = query(rp, scpiCommand(counterTrigger_reset!, val), scpiReturn(counterTrigger_reset!)) function counterTrigger_reset!(rp::RedPitaya) counterTrigger_reset!(rp, true) + sleep(0.05) counterTrigger_reset!(rp, false) end scpiCommand(::typeof(counterTrigger_reset!), val::Bool) = scpiCommand(counterTrigger_reset!, val ? "ON" : "OFF") diff --git a/src/lib/rp-daq-lib.c b/src/lib/rp-daq-lib.c index f262e22a..51844e31 100644 --- a/src/lib/rp-daq-lib.c +++ b/src/lib/rp-daq-lib.c @@ -1161,10 +1161,10 @@ int getDIODirection(const char* pin) { uint32_t register_value = *((uint8_t *)(cfg + 9)); register_value = ((register_value & (0x1 << (pinInternal))) >> (pinInternal)); - if(register_value == IN) { - return IN; + if(register_value == DIO_IN) { + return DIO_IN; } else { - return OUT; + return DIO_OUT; } } @@ -1174,9 +1174,9 @@ int setDIODirection(const char* pin, int value) { return -3; } - if(value == OUT) { + if(value == DIO_OUT) { *((uint8_t *)(cfg + 9)) &= ~(0x1 << (pinInternal)); - } else if(value == IN) { + } else if(value == DIO_IN) { *((uint8_t *)(cfg + 9)) |= (0x1 << (pinInternal)); } else { return -1; diff --git a/src/lib/rp-daq-lib.h b/src/lib/rp-daq-lib.h index 215a889d..5b4644b1 100644 --- a/src/lib/rp-daq-lib.h +++ b/src/lib/rp-daq-lib.h @@ -53,8 +53,8 @@ #define OFF 0 #define ON 1 -#define IN 0 -#define OUT 1 +#define DIO_IN 1 +#define DIO_OUT 0 #define CALIB_VERSION 1 diff --git a/src/server/scpi_commands.c b/src/server/scpi_commands.c index 1c8ca4bf..d0402f4f 100644 --- a/src/server/scpi_commands.c +++ b/src/server/scpi_commands.c @@ -600,8 +600,8 @@ static scpi_result_t RP_XADC_GetXADCValueVolt(scpi_t * context) { } scpi_choice_def_t inout_modes[] = { - {"IN", IN}, - {"OUT", OUT}, + {"IN", DIO_IN}, + {"OUT", DIO_OUT}, SCPI_CHOICE_LIST_END /* termination of option list */ };