From 11c25f2b26fb582f339d91797fc56a33757c7c85 Mon Sep 17 00:00:00 2001 From: Howard Li <bighorn@pursuitofchallenge.com> Date: 周日, 19 4月 2020 12:09:25 +0800 Subject: [PATCH] Add register-related types --- libscpi/inc/scpi/types.h | 49 +++++++++++++++++++++++- libscpi/src/ieee488.c | 54 +++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 2 deletions(-) diff --git a/libscpi/inc/scpi/types.h b/libscpi/inc/scpi/types.h index ce238dc..75d187f 100644 --- a/libscpi/inc/scpi/types.h +++ b/libscpi/inc/scpi/types.h @@ -78,8 +78,12 @@ SCPI_REG_QUESE, /* QUEStionable status Enable Register */ SCPI_REG_QUESC, /* QUEStionable status Condition Register */ - /* last definition - number of registers */ - SCPI_REG_COUNT + /* Add device specific registers here*/ + + /* number of registers */ + SCPI_REG_COUNT, + /* last definition - a value for no register */ + SCPI_REG_NONE }; typedef enum _scpi_reg_name_t scpi_reg_name_t; @@ -105,6 +109,47 @@ typedef uint16_t scpi_reg_val_t; + enum _scpi_reg_class_t { + SCPI_REG_CLASS_STB = 0, + SCPI_REG_CLASS_SRE, + SCPI_REG_CLASS_EVEN, + SCPI_REG_CLASS_ENAB, + SCPI_REG_CLASS_COND, + SCPI_REG_CLASS_NTR, + SCPI_REG_CLASS_PTR, + }; + typedef enum _scpi_reg_class_t scpi_reg_class_t; + + enum _scpi_reg_group_t { + SCPI_REG_GROUP_STB = 0, + SCPI_REG_GROUP_ESR, + SCPI_REG_GROUP_OPER, + SCPI_REG_GROUP_QUES, + + /* Add device specific register groups here*/ + + /* last definition - number of register groups */ + SCPI_REG_GROUP_COUNT + }; + typedef enum _scpi_reg_group_t scpi_reg_group_t; + + struct _scpi_reg_info_t { + scpi_reg_class_t type; + scpi_reg_group_t group; + }; + typedef struct _scpi_reg_info_t scpi_reg_info_t; + + struct _scpi_reg_group_info_t { + scpi_reg_name_t event; + scpi_reg_name_t enable; + scpi_reg_name_t condition; + scpi_reg_name_t ptfilt; + scpi_reg_name_t ntfilt; + scpi_reg_name_t parent_reg; + scpi_reg_val_t parent_bit; + }; + typedef struct _scpi_reg_group_info_t scpi_reg_group_info_t; + /* scpi commands */ enum _scpi_result_t { SCPI_RES_OK = 1, diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index 2102ee2..d55a8f8 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -42,6 +42,60 @@ #include <stdio.h> +static const scpi_reg_info_t scpi_reg_details[SCPI_REG_COUNT] = { + { SCPI_REG_CLASS_STB, SCPI_REG_GROUP_STB }, + { SCPI_REG_CLASS_SRE, SCPI_REG_GROUP_STB }, + { SCPI_REG_CLASS_EVEN, SCPI_REG_GROUP_ESR }, + { SCPI_REG_CLASS_ENAB, SCPI_REG_GROUP_ESR }, + { SCPI_REG_CLASS_EVEN, SCPI_REG_GROUP_OPER }, + { SCPI_REG_CLASS_ENAB, SCPI_REG_GROUP_OPER }, + { SCPI_REG_CLASS_COND, SCPI_REG_GROUP_OPER }, + { SCPI_REG_CLASS_EVEN, SCPI_REG_GROUP_QUES }, + { SCPI_REG_CLASS_ENAB, SCPI_REG_GROUP_QUES }, + { SCPI_REG_CLASS_COND, SCPI_REG_GROUP_QUES }, + /* Add device specific register details here*/ +}; + +static const scpi_reg_group_info_t scpi_reg_group_details[SCPI_REG_GROUP_COUNT] = { + { + SCPI_REG_STB, + SCPI_REG_SRE, + SCPI_REG_NONE, + SCPI_REG_NONE, + SCPI_REG_NONE, + SCPI_REG_NONE, + 0 + }, //SCPI_REG_GROUP_STB + { + SCPI_REG_ESR, + SCPI_REG_ESE, + SCPI_REG_NONE, + SCPI_REG_NONE, + SCPI_REG_NONE, + SCPI_REG_STB, + STB_ESR + }, //SCPI_REG_GROUP_ESR + { + SCPI_REG_OPER, + SCPI_REG_OPERE, + SCPI_REG_OPERC, + SCPI_REG_NONE, + SCPI_REG_NONE, + SCPI_REG_STB, + STB_OPS + }, //SCPI_REG_GROUP_OPER + { + SCPI_REG_QUES, + SCPI_REG_QUESE, + SCPI_REG_QUESC, + SCPI_REG_NONE, + SCPI_REG_NONE, + SCPI_REG_STB, + STB_QES + }, //SCPI_REG_GROUP_QUES + /* Add device specific register group details here*/ +}; + /** * Update register value * @param context -- Gitblit v1.9.1