From 017336ed912627a2c242d80b4fbb75bf3b1b83a3 Mon Sep 17 00:00:00 2001 From: Howard Li <bighorn@pursuitofchallenge.com> Date: 周三, 29 4月 2020 02:29:30 +0800 Subject: [PATCH] Add macros for adding device-specific registers --- libscpi/inc/scpi/types.h | 16 ++++++++++++++-- libscpi/src/ieee488.c | 20 ++++++++++++++++++-- libscpi/inc/scpi/config.h | 4 ++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/libscpi/inc/scpi/config.h b/libscpi/inc/scpi/config.h index c391e12..2d3652e 100644 --- a/libscpi/inc/scpi/config.h +++ b/libscpi/inc/scpi/config.h @@ -57,6 +57,10 @@ #define SCPI_LINE_ENDING LINE_ENDING_CRLF #endif +#ifndef USE_CUSTOM_REGISTERS +#define USE_CUSTOM_REGISTERS 0 +#endif + /** * Detect, if it has limited resources or it is running on a full blown operating system. * All values can be overiden by scpi_user_config.h diff --git a/libscpi/inc/scpi/types.h b/libscpi/inc/scpi/types.h index 75d187f..6fca535 100644 --- a/libscpi/inc/scpi/types.h +++ b/libscpi/inc/scpi/types.h @@ -78,7 +78,13 @@ SCPI_REG_QUESE, /* QUEStionable status Enable Register */ SCPI_REG_QUESC, /* QUEStionable status Condition Register */ - /* Add device specific registers here*/ +#if USE_CUSTOM_REGISTERS +#ifndef USER_REGISTERS +#error "No user registers defined" +#else + USER_REGISTERS +#endif +#endif /* number of registers */ SCPI_REG_COUNT, @@ -126,7 +132,13 @@ SCPI_REG_GROUP_OPER, SCPI_REG_GROUP_QUES, - /* Add device specific register groups here*/ +#if USE_CUSTOM_REGISTERS +#ifndef USER_REGISTER_GROUPS +#error "No user register groups defined" +#else + USER_REGISTER_GROUPS +#endif +#endif /* last definition - number of register groups */ SCPI_REG_GROUP_COUNT diff --git a/libscpi/src/ieee488.c b/libscpi/src/ieee488.c index 6323454..d03708e 100644 --- a/libscpi/src/ieee488.c +++ b/libscpi/src/ieee488.c @@ -53,7 +53,15 @@ { 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*/ + +#if USE_CUSTOM_REGISTERS +#ifndef USER_REGISTER_DETAILS +#error "No user register details defined" +#else + USER_REGISTER_DETAILS +#endif +#endif + }; static const scpi_reg_group_info_t scpi_reg_group_details[SCPI_REG_GROUP_COUNT] = { @@ -93,7 +101,15 @@ SCPI_REG_STB, STB_QES }, //SCPI_REG_GROUP_QUES - /* Add device specific register group details here*/ + +#if USE_CUSTOM_REGISTERS +#ifndef USER_REGISTER_GROUP_DETAILS +#error "No user register group details defined" +#else + USER_REGISTER_GROUP_DETAILS +#endif +#endif + }; /** -- Gitblit v1.9.1