Skip to content

Commit

Permalink
Fix mapping of in and out for dios (#57)
Browse files Browse the repository at this point in the history
* Add pause to have a slightly longer counter trigger reset time

* Possibly fix mapping

* Final fix

* Fix doubled part
  • Loading branch information
jonschumacher authored Mar 24, 2023
1 parent 12b4178 commit cd43426
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/client/julia/src/CounterTrigger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions src/lib/rp-daq-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/rp-daq-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/server/scpi_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
};

Expand Down

0 comments on commit cd43426

Please sign in to comment.