@@ -110,7 +110,19 @@ static scpi_result_t SCPI_DigitalOutputQ(scpi_t * context) {
110
110
return SCPI_RES_OK ;
111
111
}
112
112
113
- // TODO gpio in commands
113
+ static scpi_result_t SCPI_DigitalInputQ (scpi_t * context ) {
114
+ int32_t numbers [1 ];
115
+
116
+ // retrieve the output index
117
+ SCPI_CommandNumbers (context , numbers , 1 , 0 );
118
+ if (! ((numbers [0 ] > -1 ) && (numbers [0 ] < inPinCount ()))) {
119
+ SCPI_ErrorPush (context , SCPI_ERROR_INVALID_SUFFIX );
120
+ return SCPI_RES_ERR ;
121
+ }
122
+
123
+ SCPI_ResultBool (context , isInPinAt (numbers [0 ]));
124
+ return SCPI_RES_OK ;
125
+ }
114
126
115
127
static scpi_result_t SCPI_AnalogInputQ (scpi_t * context ) {
116
128
int32_t numbers [1 ];
@@ -200,7 +212,7 @@ const scpi_command_t scpi_commands[] = {
200
212
/* custom commands for the switch */
201
213
{.pattern = "DIGItal:OUTPut#" , .callback = SCPI_DigitalOutput ,},
202
214
{.pattern = "DIGItal:OUTPut#?" , .callback = SCPI_DigitalOutputQ ,},
203
- // TODO gpio in commands
215
+ {. pattern = "DIGItal:INPut#?" , . callback = SCPI_DigitalInputQ ,},
204
216
// adc commands
205
217
{.pattern = "ANAlog:INPut#:RAW?" , .callback = SCPI_AnalogInputQ ,},
206
218
{.pattern = "ANAlog:HIRES:INPut#:RAW?" , .callback = SCPI_Analog16InputQ ,},
@@ -265,8 +277,8 @@ scpi_result_t SCPI_Reset(scpi_t * context) {
265
277
void initInstrument () {
266
278
initGpioUtils ();
267
279
initOutPins ();
280
+ initInPins ();
268
281
initI2CUtils ();
269
- // TODO input pins
270
282
initAdcUtils ();
271
283
initAdcPins ();
272
284
initAdc16Reg ();
0 commit comments