scpi-parser, adopted from github
libscpi/ieee488.c@0:d8aca47812e0, 2014-11-14 (annotated)
- Committer:
- iesensor
- Date:
- Fri Nov 14 01:07:59 2014 +0000
- Revision:
- 0:d8aca47812e0
tested on K64F
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
iesensor | 0:d8aca47812e0 | 1 | /*- |
iesensor | 0:d8aca47812e0 | 2 | * Copyright (c) 2012-2013 Jan Breuer, |
iesensor | 0:d8aca47812e0 | 3 | * |
iesensor | 0:d8aca47812e0 | 4 | * All Rights Reserved |
iesensor | 0:d8aca47812e0 | 5 | * |
iesensor | 0:d8aca47812e0 | 6 | * Redistribution and use in source and binary forms, with or without |
iesensor | 0:d8aca47812e0 | 7 | * modification, are permitted provided that the following conditions are |
iesensor | 0:d8aca47812e0 | 8 | * met: |
iesensor | 0:d8aca47812e0 | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
iesensor | 0:d8aca47812e0 | 10 | * this list of conditions and the following disclaimer. |
iesensor | 0:d8aca47812e0 | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
iesensor | 0:d8aca47812e0 | 12 | * notice, this list of conditions and the following disclaimer in the |
iesensor | 0:d8aca47812e0 | 13 | * documentation and/or other materials provided with the distribution. |
iesensor | 0:d8aca47812e0 | 14 | * |
iesensor | 0:d8aca47812e0 | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
iesensor | 0:d8aca47812e0 | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
iesensor | 0:d8aca47812e0 | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
iesensor | 0:d8aca47812e0 | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE |
iesensor | 0:d8aca47812e0 | 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
iesensor | 0:d8aca47812e0 | 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
iesensor | 0:d8aca47812e0 | 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
iesensor | 0:d8aca47812e0 | 22 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
iesensor | 0:d8aca47812e0 | 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
iesensor | 0:d8aca47812e0 | 24 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
iesensor | 0:d8aca47812e0 | 25 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
iesensor | 0:d8aca47812e0 | 26 | */ |
iesensor | 0:d8aca47812e0 | 27 | |
iesensor | 0:d8aca47812e0 | 28 | /** |
iesensor | 0:d8aca47812e0 | 29 | * @file scpi_ieee488.c |
iesensor | 0:d8aca47812e0 | 30 | * @date Thu Nov 15 10:58:45 UTC 2012 |
iesensor | 0:d8aca47812e0 | 31 | * |
iesensor | 0:d8aca47812e0 | 32 | * @brief Implementation of IEEE488.2 commands and state model |
iesensor | 0:d8aca47812e0 | 33 | * |
iesensor | 0:d8aca47812e0 | 34 | * |
iesensor | 0:d8aca47812e0 | 35 | */ |
iesensor | 0:d8aca47812e0 | 36 | |
iesensor | 0:d8aca47812e0 | 37 | #include "scpi/parser.h" |
iesensor | 0:d8aca47812e0 | 38 | #include "scpi/ieee488.h" |
iesensor | 0:d8aca47812e0 | 39 | #include "scpi/error.h" |
iesensor | 0:d8aca47812e0 | 40 | #include "scpi/constants.h" |
iesensor | 0:d8aca47812e0 | 41 | |
iesensor | 0:d8aca47812e0 | 42 | #include <stdio.h> |
iesensor | 0:d8aca47812e0 | 43 | |
iesensor | 0:d8aca47812e0 | 44 | /** |
iesensor | 0:d8aca47812e0 | 45 | * Update register value |
iesensor | 0:d8aca47812e0 | 46 | * @param context |
iesensor | 0:d8aca47812e0 | 47 | * @param name - register name |
iesensor | 0:d8aca47812e0 | 48 | */ |
iesensor | 0:d8aca47812e0 | 49 | static void regUpdate(scpi_t * context, scpi_reg_name_t name) { |
iesensor | 0:d8aca47812e0 | 50 | SCPI_RegSet(context, name, SCPI_RegGet(context, name)); |
iesensor | 0:d8aca47812e0 | 51 | } |
iesensor | 0:d8aca47812e0 | 52 | |
iesensor | 0:d8aca47812e0 | 53 | /** |
iesensor | 0:d8aca47812e0 | 54 | * Update STB register according to value and its mask register |
iesensor | 0:d8aca47812e0 | 55 | * @param context |
iesensor | 0:d8aca47812e0 | 56 | * @param val value of register |
iesensor | 0:d8aca47812e0 | 57 | * @param mask name of mask register (enable register) |
iesensor | 0:d8aca47812e0 | 58 | * @param stbBits bits to clear or set in STB |
iesensor | 0:d8aca47812e0 | 59 | */ |
iesensor | 0:d8aca47812e0 | 60 | static void regUpdateSTB(scpi_t * context, scpi_reg_val_t val, scpi_reg_name_t mask, scpi_reg_val_t stbBits) { |
iesensor | 0:d8aca47812e0 | 61 | if (val & SCPI_RegGet(context, mask)) { |
iesensor | 0:d8aca47812e0 | 62 | SCPI_RegSetBits(context, SCPI_REG_STB, stbBits); |
iesensor | 0:d8aca47812e0 | 63 | } else { |
iesensor | 0:d8aca47812e0 | 64 | SCPI_RegClearBits(context, SCPI_REG_STB, stbBits); |
iesensor | 0:d8aca47812e0 | 65 | } |
iesensor | 0:d8aca47812e0 | 66 | } |
iesensor | 0:d8aca47812e0 | 67 | |
iesensor | 0:d8aca47812e0 | 68 | /** |
iesensor | 0:d8aca47812e0 | 69 | * Get register value |
iesensor | 0:d8aca47812e0 | 70 | * @param name - register name |
iesensor | 0:d8aca47812e0 | 71 | * @return register value |
iesensor | 0:d8aca47812e0 | 72 | */ |
iesensor | 0:d8aca47812e0 | 73 | scpi_reg_val_t SCPI_RegGet(scpi_t * context, scpi_reg_name_t name) { |
iesensor | 0:d8aca47812e0 | 74 | if ((name < SCPI_REG_COUNT) && (context->registers != NULL)) { |
iesensor | 0:d8aca47812e0 | 75 | return context->registers[name]; |
iesensor | 0:d8aca47812e0 | 76 | } else { |
iesensor | 0:d8aca47812e0 | 77 | return 0; |
iesensor | 0:d8aca47812e0 | 78 | } |
iesensor | 0:d8aca47812e0 | 79 | } |
iesensor | 0:d8aca47812e0 | 80 | |
iesensor | 0:d8aca47812e0 | 81 | /** |
iesensor | 0:d8aca47812e0 | 82 | * Wrapper function to control interface from context |
iesensor | 0:d8aca47812e0 | 83 | * @param context |
iesensor | 0:d8aca47812e0 | 84 | * @param ctrl number of controll message |
iesensor | 0:d8aca47812e0 | 85 | * @param value value of related register |
iesensor | 0:d8aca47812e0 | 86 | */ |
iesensor | 0:d8aca47812e0 | 87 | static size_t writeControl(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) { |
iesensor | 0:d8aca47812e0 | 88 | if (context && context->interface && context->interface->control) { |
iesensor | 0:d8aca47812e0 | 89 | return context->interface->control(context, ctrl, val); |
iesensor | 0:d8aca47812e0 | 90 | } else { |
iesensor | 0:d8aca47812e0 | 91 | return 0; |
iesensor | 0:d8aca47812e0 | 92 | } |
iesensor | 0:d8aca47812e0 | 93 | } |
iesensor | 0:d8aca47812e0 | 94 | |
iesensor | 0:d8aca47812e0 | 95 | /** |
iesensor | 0:d8aca47812e0 | 96 | * Set register value |
iesensor | 0:d8aca47812e0 | 97 | * @param name - register name |
iesensor | 0:d8aca47812e0 | 98 | * @param val - new value |
iesensor | 0:d8aca47812e0 | 99 | */ |
iesensor | 0:d8aca47812e0 | 100 | void SCPI_RegSet(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t val) { |
iesensor | 0:d8aca47812e0 | 101 | scpi_bool_t srq = FALSE; |
iesensor | 0:d8aca47812e0 | 102 | scpi_reg_val_t mask; |
iesensor | 0:d8aca47812e0 | 103 | scpi_reg_val_t old_val; |
iesensor | 0:d8aca47812e0 | 104 | |
iesensor | 0:d8aca47812e0 | 105 | if ((name >= SCPI_REG_COUNT) || (context->registers == NULL)) { |
iesensor | 0:d8aca47812e0 | 106 | return; |
iesensor | 0:d8aca47812e0 | 107 | } |
iesensor | 0:d8aca47812e0 | 108 | |
iesensor | 0:d8aca47812e0 | 109 | /* store old register value */ |
iesensor | 0:d8aca47812e0 | 110 | old_val = context->registers[name]; |
iesensor | 0:d8aca47812e0 | 111 | |
iesensor | 0:d8aca47812e0 | 112 | /* set register value */ |
iesensor | 0:d8aca47812e0 | 113 | context->registers[name] = val; |
iesensor | 0:d8aca47812e0 | 114 | |
iesensor | 0:d8aca47812e0 | 115 | /** @TODO: remove recutsion */ |
iesensor | 0:d8aca47812e0 | 116 | switch (name) { |
iesensor | 0:d8aca47812e0 | 117 | case SCPI_REG_STB: |
iesensor | 0:d8aca47812e0 | 118 | mask = SCPI_RegGet(context, SCPI_REG_SRE); |
iesensor | 0:d8aca47812e0 | 119 | mask &= ~STB_SRQ; |
iesensor | 0:d8aca47812e0 | 120 | if (val & mask) { |
iesensor | 0:d8aca47812e0 | 121 | val |= STB_SRQ; |
iesensor | 0:d8aca47812e0 | 122 | /* avoid sending SRQ if nothing has changed */ |
iesensor | 0:d8aca47812e0 | 123 | if (old_val != val) { |
iesensor | 0:d8aca47812e0 | 124 | srq = TRUE; |
iesensor | 0:d8aca47812e0 | 125 | } |
iesensor | 0:d8aca47812e0 | 126 | } else { |
iesensor | 0:d8aca47812e0 | 127 | val &= ~STB_SRQ; |
iesensor | 0:d8aca47812e0 | 128 | } |
iesensor | 0:d8aca47812e0 | 129 | break; |
iesensor | 0:d8aca47812e0 | 130 | case SCPI_REG_SRE: |
iesensor | 0:d8aca47812e0 | 131 | regUpdate(context, SCPI_REG_STB); |
iesensor | 0:d8aca47812e0 | 132 | break; |
iesensor | 0:d8aca47812e0 | 133 | case SCPI_REG_ESR: |
iesensor | 0:d8aca47812e0 | 134 | regUpdateSTB(context, val, SCPI_REG_ESE, STB_ESR); |
iesensor | 0:d8aca47812e0 | 135 | break; |
iesensor | 0:d8aca47812e0 | 136 | case SCPI_REG_ESE: |
iesensor | 0:d8aca47812e0 | 137 | regUpdate(context, SCPI_REG_ESR); |
iesensor | 0:d8aca47812e0 | 138 | break; |
iesensor | 0:d8aca47812e0 | 139 | case SCPI_REG_QUES: |
iesensor | 0:d8aca47812e0 | 140 | regUpdateSTB(context, val, SCPI_REG_QUESE, STB_QES); |
iesensor | 0:d8aca47812e0 | 141 | break; |
iesensor | 0:d8aca47812e0 | 142 | case SCPI_REG_QUESE: |
iesensor | 0:d8aca47812e0 | 143 | regUpdate(context, SCPI_REG_QUES); |
iesensor | 0:d8aca47812e0 | 144 | break; |
iesensor | 0:d8aca47812e0 | 145 | case SCPI_REG_OPER: |
iesensor | 0:d8aca47812e0 | 146 | regUpdateSTB(context, val, SCPI_REG_OPERE, STB_OPS); |
iesensor | 0:d8aca47812e0 | 147 | break; |
iesensor | 0:d8aca47812e0 | 148 | case SCPI_REG_OPERE: |
iesensor | 0:d8aca47812e0 | 149 | regUpdate(context, SCPI_REG_OPER); |
iesensor | 0:d8aca47812e0 | 150 | break; |
iesensor | 0:d8aca47812e0 | 151 | |
iesensor | 0:d8aca47812e0 | 152 | |
iesensor | 0:d8aca47812e0 | 153 | case SCPI_REG_COUNT: |
iesensor | 0:d8aca47812e0 | 154 | /* nothing to do */ |
iesensor | 0:d8aca47812e0 | 155 | break; |
iesensor | 0:d8aca47812e0 | 156 | } |
iesensor | 0:d8aca47812e0 | 157 | |
iesensor | 0:d8aca47812e0 | 158 | /* set updated register value */ |
iesensor | 0:d8aca47812e0 | 159 | context->registers[name] = val; |
iesensor | 0:d8aca47812e0 | 160 | |
iesensor | 0:d8aca47812e0 | 161 | if (srq) { |
iesensor | 0:d8aca47812e0 | 162 | writeControl(context, SCPI_CTRL_SRQ, SCPI_RegGet(context, SCPI_REG_STB)); |
iesensor | 0:d8aca47812e0 | 163 | } |
iesensor | 0:d8aca47812e0 | 164 | } |
iesensor | 0:d8aca47812e0 | 165 | |
iesensor | 0:d8aca47812e0 | 166 | /** |
iesensor | 0:d8aca47812e0 | 167 | * Set register bits |
iesensor | 0:d8aca47812e0 | 168 | * @param name - register name |
iesensor | 0:d8aca47812e0 | 169 | * @param bits bit mask |
iesensor | 0:d8aca47812e0 | 170 | */ |
iesensor | 0:d8aca47812e0 | 171 | void SCPI_RegSetBits(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t bits) { |
iesensor | 0:d8aca47812e0 | 172 | SCPI_RegSet(context, name, SCPI_RegGet(context, name) | bits); |
iesensor | 0:d8aca47812e0 | 173 | } |
iesensor | 0:d8aca47812e0 | 174 | |
iesensor | 0:d8aca47812e0 | 175 | /** |
iesensor | 0:d8aca47812e0 | 176 | * Clear register bits |
iesensor | 0:d8aca47812e0 | 177 | * @param name - register name |
iesensor | 0:d8aca47812e0 | 178 | * @param bits bit mask |
iesensor | 0:d8aca47812e0 | 179 | */ |
iesensor | 0:d8aca47812e0 | 180 | void SCPI_RegClearBits(scpi_t * context, scpi_reg_name_t name, scpi_reg_val_t bits) { |
iesensor | 0:d8aca47812e0 | 181 | SCPI_RegSet(context, name, SCPI_RegGet(context, name) & ~bits); |
iesensor | 0:d8aca47812e0 | 182 | } |
iesensor | 0:d8aca47812e0 | 183 | |
iesensor | 0:d8aca47812e0 | 184 | /** |
iesensor | 0:d8aca47812e0 | 185 | * Clear event register |
iesensor | 0:d8aca47812e0 | 186 | * @param context |
iesensor | 0:d8aca47812e0 | 187 | */ |
iesensor | 0:d8aca47812e0 | 188 | void SCPI_EventClear(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 189 | /* TODO */ |
iesensor | 0:d8aca47812e0 | 190 | SCPI_RegSet(context, SCPI_REG_ESR, 0); |
iesensor | 0:d8aca47812e0 | 191 | } |
iesensor | 0:d8aca47812e0 | 192 | |
iesensor | 0:d8aca47812e0 | 193 | /** |
iesensor | 0:d8aca47812e0 | 194 | * *CLS - This command clears all status data structures in a device. |
iesensor | 0:d8aca47812e0 | 195 | * For a device which minimally complies with SCPI. (SCPI std 4.1.3.2) |
iesensor | 0:d8aca47812e0 | 196 | * @param context |
iesensor | 0:d8aca47812e0 | 197 | * @return |
iesensor | 0:d8aca47812e0 | 198 | */ |
iesensor | 0:d8aca47812e0 | 199 | scpi_result_t SCPI_CoreCls(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 200 | SCPI_EventClear(context); |
iesensor | 0:d8aca47812e0 | 201 | SCPI_ErrorClear(context); |
iesensor | 0:d8aca47812e0 | 202 | SCPI_RegSet(context, SCPI_REG_OPER, 0); |
iesensor | 0:d8aca47812e0 | 203 | SCPI_RegSet(context, SCPI_REG_QUES, 0); |
iesensor | 0:d8aca47812e0 | 204 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 205 | } |
iesensor | 0:d8aca47812e0 | 206 | |
iesensor | 0:d8aca47812e0 | 207 | /** |
iesensor | 0:d8aca47812e0 | 208 | * *ESE |
iesensor | 0:d8aca47812e0 | 209 | * @param context |
iesensor | 0:d8aca47812e0 | 210 | * @return |
iesensor | 0:d8aca47812e0 | 211 | */ |
iesensor | 0:d8aca47812e0 | 212 | scpi_result_t SCPI_CoreEse(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 213 | int32_t new_ESE; |
iesensor | 0:d8aca47812e0 | 214 | if (SCPI_ParamInt(context, &new_ESE, TRUE)) { |
iesensor | 0:d8aca47812e0 | 215 | SCPI_RegSet(context, SCPI_REG_ESE, new_ESE); |
iesensor | 0:d8aca47812e0 | 216 | } |
iesensor | 0:d8aca47812e0 | 217 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 218 | } |
iesensor | 0:d8aca47812e0 | 219 | |
iesensor | 0:d8aca47812e0 | 220 | /** |
iesensor | 0:d8aca47812e0 | 221 | * *ESE? |
iesensor | 0:d8aca47812e0 | 222 | * @param context |
iesensor | 0:d8aca47812e0 | 223 | * @return |
iesensor | 0:d8aca47812e0 | 224 | */ |
iesensor | 0:d8aca47812e0 | 225 | scpi_result_t SCPI_CoreEseQ(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 226 | SCPI_ResultInt(context, SCPI_RegGet(context, SCPI_REG_ESE)); |
iesensor | 0:d8aca47812e0 | 227 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 228 | } |
iesensor | 0:d8aca47812e0 | 229 | |
iesensor | 0:d8aca47812e0 | 230 | /** |
iesensor | 0:d8aca47812e0 | 231 | * *ESR? |
iesensor | 0:d8aca47812e0 | 232 | * @param context |
iesensor | 0:d8aca47812e0 | 233 | * @return |
iesensor | 0:d8aca47812e0 | 234 | */ |
iesensor | 0:d8aca47812e0 | 235 | scpi_result_t SCPI_CoreEsrQ(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 236 | SCPI_ResultInt(context, SCPI_RegGet(context, SCPI_REG_ESR)); |
iesensor | 0:d8aca47812e0 | 237 | SCPI_RegSet(context, SCPI_REG_ESR, 0); |
iesensor | 0:d8aca47812e0 | 238 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 239 | } |
iesensor | 0:d8aca47812e0 | 240 | |
iesensor | 0:d8aca47812e0 | 241 | /** |
iesensor | 0:d8aca47812e0 | 242 | * *IDN? |
iesensor | 0:d8aca47812e0 | 243 | * |
iesensor | 0:d8aca47812e0 | 244 | * field1: MANUFACTURE |
iesensor | 0:d8aca47812e0 | 245 | * field2: MODEL |
iesensor | 0:d8aca47812e0 | 246 | * field4: SUBSYSTEMS REVISIONS |
iesensor | 0:d8aca47812e0 | 247 | * |
iesensor | 0:d8aca47812e0 | 248 | * example: MANUFACTURE,MODEL,0,01-02-01 |
iesensor | 0:d8aca47812e0 | 249 | * @param context |
iesensor | 0:d8aca47812e0 | 250 | * @return |
iesensor | 0:d8aca47812e0 | 251 | */ |
iesensor | 0:d8aca47812e0 | 252 | scpi_result_t SCPI_CoreIdnQ(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 253 | SCPI_ResultString(context, context->idn[0]); |
iesensor | 0:d8aca47812e0 | 254 | SCPI_ResultString(context, context->idn[1]); |
iesensor | 0:d8aca47812e0 | 255 | SCPI_ResultString(context, context->idn[2]); |
iesensor | 0:d8aca47812e0 | 256 | SCPI_ResultString(context, context->idn[3]); |
iesensor | 0:d8aca47812e0 | 257 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 258 | } |
iesensor | 0:d8aca47812e0 | 259 | |
iesensor | 0:d8aca47812e0 | 260 | /** |
iesensor | 0:d8aca47812e0 | 261 | * *OPC |
iesensor | 0:d8aca47812e0 | 262 | * @param context |
iesensor | 0:d8aca47812e0 | 263 | * @return |
iesensor | 0:d8aca47812e0 | 264 | */ |
iesensor | 0:d8aca47812e0 | 265 | scpi_result_t SCPI_CoreOpc(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 266 | SCPI_RegSetBits(context, SCPI_REG_ESR, ESR_OPC); |
iesensor | 0:d8aca47812e0 | 267 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 268 | } |
iesensor | 0:d8aca47812e0 | 269 | |
iesensor | 0:d8aca47812e0 | 270 | /** |
iesensor | 0:d8aca47812e0 | 271 | * *OPC? |
iesensor | 0:d8aca47812e0 | 272 | * @param context |
iesensor | 0:d8aca47812e0 | 273 | * @return |
iesensor | 0:d8aca47812e0 | 274 | */ |
iesensor | 0:d8aca47812e0 | 275 | scpi_result_t SCPI_CoreOpcQ(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 276 | /* Operation is always completed */ |
iesensor | 0:d8aca47812e0 | 277 | SCPI_ResultInt(context, 1); |
iesensor | 0:d8aca47812e0 | 278 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 279 | } |
iesensor | 0:d8aca47812e0 | 280 | |
iesensor | 0:d8aca47812e0 | 281 | /** |
iesensor | 0:d8aca47812e0 | 282 | * *RST |
iesensor | 0:d8aca47812e0 | 283 | * @param context |
iesensor | 0:d8aca47812e0 | 284 | * @return |
iesensor | 0:d8aca47812e0 | 285 | */ |
iesensor | 0:d8aca47812e0 | 286 | scpi_result_t SCPI_CoreRst(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 287 | if (context && context->interface && context->interface->reset) { |
iesensor | 0:d8aca47812e0 | 288 | return context->interface->reset(context); |
iesensor | 0:d8aca47812e0 | 289 | } |
iesensor | 0:d8aca47812e0 | 290 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 291 | } |
iesensor | 0:d8aca47812e0 | 292 | |
iesensor | 0:d8aca47812e0 | 293 | /** |
iesensor | 0:d8aca47812e0 | 294 | * *SRE |
iesensor | 0:d8aca47812e0 | 295 | * @param context |
iesensor | 0:d8aca47812e0 | 296 | * @return |
iesensor | 0:d8aca47812e0 | 297 | */ |
iesensor | 0:d8aca47812e0 | 298 | scpi_result_t SCPI_CoreSre(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 299 | int32_t new_SRE; |
iesensor | 0:d8aca47812e0 | 300 | if (SCPI_ParamInt(context, &new_SRE, TRUE)) { |
iesensor | 0:d8aca47812e0 | 301 | SCPI_RegSet(context, SCPI_REG_SRE, new_SRE); |
iesensor | 0:d8aca47812e0 | 302 | } |
iesensor | 0:d8aca47812e0 | 303 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 304 | } |
iesensor | 0:d8aca47812e0 | 305 | |
iesensor | 0:d8aca47812e0 | 306 | /** |
iesensor | 0:d8aca47812e0 | 307 | * *SRE? |
iesensor | 0:d8aca47812e0 | 308 | * @param context |
iesensor | 0:d8aca47812e0 | 309 | * @return |
iesensor | 0:d8aca47812e0 | 310 | */ |
iesensor | 0:d8aca47812e0 | 311 | scpi_result_t SCPI_CoreSreQ(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 312 | SCPI_ResultInt(context, SCPI_RegGet(context, SCPI_REG_SRE)); |
iesensor | 0:d8aca47812e0 | 313 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 314 | } |
iesensor | 0:d8aca47812e0 | 315 | |
iesensor | 0:d8aca47812e0 | 316 | /** |
iesensor | 0:d8aca47812e0 | 317 | * *STB? |
iesensor | 0:d8aca47812e0 | 318 | * @param context |
iesensor | 0:d8aca47812e0 | 319 | * @return |
iesensor | 0:d8aca47812e0 | 320 | */ |
iesensor | 0:d8aca47812e0 | 321 | scpi_result_t SCPI_CoreStbQ(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 322 | SCPI_ResultInt(context, SCPI_RegGet(context, SCPI_REG_STB)); |
iesensor | 0:d8aca47812e0 | 323 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 324 | } |
iesensor | 0:d8aca47812e0 | 325 | |
iesensor | 0:d8aca47812e0 | 326 | /** |
iesensor | 0:d8aca47812e0 | 327 | * *TST? |
iesensor | 0:d8aca47812e0 | 328 | * @param context |
iesensor | 0:d8aca47812e0 | 329 | * @return |
iesensor | 0:d8aca47812e0 | 330 | */ |
iesensor | 0:d8aca47812e0 | 331 | scpi_result_t SCPI_CoreTstQ(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 332 | int result = 0; |
iesensor | 0:d8aca47812e0 | 333 | if (context && context->interface && context->interface->test) { |
iesensor | 0:d8aca47812e0 | 334 | result = context->interface->test(context); |
iesensor | 0:d8aca47812e0 | 335 | } |
iesensor | 0:d8aca47812e0 | 336 | SCPI_ResultInt(context, result); |
iesensor | 0:d8aca47812e0 | 337 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 338 | } |
iesensor | 0:d8aca47812e0 | 339 | |
iesensor | 0:d8aca47812e0 | 340 | /** |
iesensor | 0:d8aca47812e0 | 341 | * *WAI |
iesensor | 0:d8aca47812e0 | 342 | * @param context |
iesensor | 0:d8aca47812e0 | 343 | * @return |
iesensor | 0:d8aca47812e0 | 344 | */ |
iesensor | 0:d8aca47812e0 | 345 | scpi_result_t SCPI_CoreWai(scpi_t * context) { |
iesensor | 0:d8aca47812e0 | 346 | (void) context; |
iesensor | 0:d8aca47812e0 | 347 | /* NOP */ |
iesensor | 0:d8aca47812e0 | 348 | return SCPI_RES_OK; |
iesensor | 0:d8aca47812e0 | 349 | } |
iesensor | 0:d8aca47812e0 | 350 |