From 06ca0ab8991fe36731ae715a072fb12cc22abcca Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周一, 24 6月 2013 22:19:34 +0800 Subject: [PATCH] Update documentation --- libscpi/src/ieee488.c | 40 +++++++++++++++++++++++----------------- 1 files changed, 23 insertions(+), 17 deletions(-) diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index 6b4e62e..5fd7fe9 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -84,7 +84,7 @@ * @param ctrl number of controll message * @param value value of related register */ -static size_t writeControl(scpi_t * context, int ctrl, scpi_reg_val_t val) { +static size_t writeControl(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) { if (context && context->interface && context->interface->control) { return context->interface->control(context, ctrl, val); } else { @@ -100,11 +100,14 @@ void SCPI_RegSet(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t val) { bool_t srq = FALSE; scpi_reg_val_t mask; + scpi_reg_val_t old_val; if ((name >= SCPI_REG_COUNT) || (context->registers == NULL)) { return; } + /* store old register value */ + old_val = context->registers[name]; /* set register value */ context->registers[name] = val; @@ -116,7 +119,10 @@ mask &= ~STB_SRQ; if (val & mask) { val |= STB_SRQ; - srq = TRUE; + /* avoid sending SRQ if nothing has changed */ + if (old_val != val) { + srq = TRUE; + } } else { val &= ~STB_SRQ; } @@ -145,11 +151,11 @@ case SCPI_REG_COUNT: - // nothing to do + /* nothing to do */ break; } - // set updated register value + /* set updated register value */ context->registers[name] = val; if (srq) { @@ -180,7 +186,7 @@ * @param context */ void SCPI_EventClear(scpi_t * context) { - // TODO + /* TODO */ SCPI_RegSet(context, SCPI_REG_ESR, 0); } @@ -204,9 +210,9 @@ * @return */ scpi_result_t SCPI_CoreEse(scpi_t * context) { - int32_t new_ESE; - if (SCPI_ParamInt(context, &new_ESE, TRUE)) { - SCPI_RegSet(context, SCPI_REG_ESE, new_ESE); + scpi_parameter_t parameter; + if (SCPI_Parameter(context, ¶meter, TRUE)) { + SCPI_RegSet(context, SCPI_REG_ESE, SCPI_ParamGetIntVal(context, ¶meter)); } return SCPI_RES_OK; } @@ -238,9 +244,9 @@ * @return */ scpi_result_t SCPI_CoreIdnQ(scpi_t * context) { - SCPI_ResultString(context, SCPI_MANUFACTURE); - SCPI_ResultString(context, SCPI_DEV_NAME); - SCPI_ResultString(context, SCPI_DEV_VERSION); + SCPI_ResultText(context, SCPI_MANUFACTURE); + SCPI_ResultText(context, SCPI_DEV_NAME); + SCPI_ResultText(context, SCPI_DEV_VERSION); return SCPI_RES_OK; } @@ -260,7 +266,7 @@ * @return */ scpi_result_t SCPI_CoreOpcQ(scpi_t * context) { - // Operation is always completed + /* Operation is always completed */ SCPI_ResultInt(context, 1); return SCPI_RES_OK; } @@ -283,9 +289,9 @@ * @return */ scpi_result_t SCPI_CoreSre(scpi_t * context) { - int32_t new_SRE; - if (SCPI_ParamInt(context, &new_SRE, TRUE)) { - SCPI_RegSet(context, SCPI_REG_SRE, new_SRE); + scpi_parameter_t parameter; + if (SCPI_Parameter(context, ¶meter, TRUE)) { + SCPI_RegSet(context, SCPI_REG_SRE, SCPI_ParamGetIntVal(context, ¶meter)); } return SCPI_RES_OK; } @@ -319,7 +325,7 @@ int result = 0; if (context && context->interface && context->interface->test) { result = context->interface->test(context); - } + } SCPI_ResultInt(context, result); return SCPI_RES_OK; } @@ -331,7 +337,7 @@ */ scpi_result_t SCPI_CoreWai(scpi_t * context) { (void) context; - // NOP + /* NOP */ return SCPI_RES_OK; } -- Gitblit v1.9.1