| | |
| | | #include "scpi/parser.h" |
| | | #include "scpi/ieee488.h" |
| | | #include "scpi/error.h" |
| | | #include "scpi/constants.h" |
| | | |
| | | #include <stdio.h> |
| | | |
| | | static const scpi_reg_info_t scpi_reg_details[SCPI_REG_COUNT] = { |
| | |
| | | SCPI_REG_NONE, |
| | | SCPI_REG_NONE, |
| | | 0 |
| | | }, //SCPI_REG_GROUP_STB |
| | | }, /* SCPI_REG_GROUP_STB */ |
| | | { |
| | | SCPI_REG_ESR, |
| | | SCPI_REG_ESE, |
| | |
| | | SCPI_REG_NONE, |
| | | SCPI_REG_STB, |
| | | STB_ESR |
| | | }, //SCPI_REG_GROUP_ESR |
| | | }, /* SCPI_REG_GROUP_ESR */ |
| | | { |
| | | SCPI_REG_OPER, |
| | | SCPI_REG_OPERE, |
| | |
| | | SCPI_REG_NONE, |
| | | SCPI_REG_STB, |
| | | STB_OPS |
| | | }, //SCPI_REG_GROUP_OPER |
| | | }, /* SCPI_REG_GROUP_OPER */ |
| | | { |
| | | SCPI_REG_QUES, |
| | | SCPI_REG_QUESE, |
| | |
| | | SCPI_REG_NONE, |
| | | SCPI_REG_STB, |
| | | STB_QES |
| | | }, //SCPI_REG_GROUP_QUES |
| | | }, /* SCPI_REG_GROUP_QUES */ |
| | | |
| | | #if USE_CUSTOM_REGISTERS |
| | | #ifndef USER_REGISTER_GROUP_DETAILS |
| | |
| | | switch (register_type) { |
| | | case SCPI_REG_CLASS_STB: |
| | | case SCPI_REG_CLASS_SRE: |
| | | ; |
| | | { |
| | | scpi_reg_val_t stb = context->registers[SCPI_REG_STB] & ~STB_SRQ; |
| | | scpi_reg_val_t sre = context->registers[SCPI_REG_SRE] & ~STB_SRQ; |
| | | |
| | | if (stb & sre) { |
| | | ptrans = ((old_val ^ val) & val); |
| | | context->registers[SCPI_REG_STB] |= STB_SRQ; |
| | | if (ptrans & val) { |
| | | if (ptrans & val) |
| | | { |
| | | writeControl(context, SCPI_CTRL_SRQ, context->registers[SCPI_REG_STB]); |
| | | } |
| | | } else { |
| | | } else |
| | | { |
| | | context->registers[SCPI_REG_STB] &= ~STB_SRQ; |
| | | } |
| | | break; |
| | | } |
| | | case SCPI_REG_CLASS_EVEN: |
| | | ; |
| | | { |
| | | scpi_reg_val_t enable; |
| | | if(register_group.enable != SCPI_REG_NONE) { |
| | | enable = SCPI_RegGet(context, register_group.enable); |
| | |
| | | val &= ~(register_group.parent_bit); |
| | | } |
| | | break; |
| | | } |
| | | case SCPI_REG_CLASS_COND: |
| | | { |
| | | name = register_group.event; |
| | | |
| | | if(register_group.ptfilt == SCPI_REG_NONE && register_group.ntfilt == SCPI_REG_NONE) { |
| | |
| | | val = ((ptrans & ptfilt) | (ntrans & ntfilt)) | SCPI_RegGet(context, register_group.event); |
| | | } |
| | | break; |
| | | } |
| | | case SCPI_REG_CLASS_ENAB: |
| | | case SCPI_REG_CLASS_NTR: |
| | | case SCPI_REG_CLASS_PTR: |
| | |
| | | */ |
| | | scpi_result_t SCPI_CoreCls(scpi_t * context) { |
| | | SCPI_ErrorClear(context); |
| | | for (int i = 0; i < SCPI_REG_GROUP_COUNT; ++i) { |
| | | int i; |
| | | for (i = 0; i < SCPI_REG_GROUP_COUNT; ++i) { |
| | | scpi_reg_name_t event_reg = scpi_reg_group_details[i].event; |
| | | if (event_reg != SCPI_REG_STB) { |
| | | SCPI_RegSet(context, event_reg, 0); |
| | |
| | | * @param context |
| | | * @return |
| | | */ |
| | | scpi_result_t SCPI_CoreEse(scpi_t * context) { |
| | | scpi_result_t SCPI_CoreEse(scpi_t * context) |
| | | { |
| | | int32_t new_ESE; |
| | | if (SCPI_ParamInt32(context, &new_ESE, TRUE)) { |
| | | SCPI_RegSet(context, SCPI_REG_ESE, (scpi_reg_val_t) new_ESE); |
| | |
| | | */ |
| | | scpi_result_t SCPI_CoreIdnQ(scpi_t * context) { |
| | | int i; |
| | | for (i = 0; i < 4; i++) { |
| | | if (context->idn[i]) { |
| | | for (i = 0; i < 4; i++) |
| | | { |
| | | if (context->idn[i]) |
| | | { |
| | | char* outPut = "IDNS响应"; |
| | | memcpy(context->outPut,outPut,strlen(outPut)); |
| | | context->interface->write(context,context->idn[i],0); |
| | | SCPI_ResultMnemonic(context, context->idn[i]); |
| | | } else { |
| | | SCPI_ResultMnemonic(context, "0"); |
| | |
| | | * @param context |
| | | * @return |
| | | */ |
| | | scpi_result_t SCPI_CoreOpc(scpi_t * context) { |
| | | scpi_result_t SCPI_CoreOpc(scpi_t * context) |
| | | { |
| | | SCPI_RegSetBits(context, SCPI_REG_ESR, ESR_OPC); |
| | | return SCPI_RES_OK; |
| | | } |
| | |
| | | * @param context |
| | | * @return |
| | | */ |
| | | scpi_result_t SCPI_CoreSreQ(scpi_t * context) { |
| | | SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_SRE)); |
| | | scpi_result_t SCPI_CoreSreQ(scpi_t * context) |
| | | { |
| | | context->interface->write(context,"Registers request start",0); |
| | | for(int i =0;i<SCPI_REG_COUNT;i++) |
| | | { |
| | | context->interface->write(context,(char*)context->registers[i],0); |
| | | } |
| | | context->interface->write(context,"Registers request end",0); |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | |
| | | return SCPI_RES_OK; |
| | | } |
| | | |
| | | |