1 |
9 |
nussgipfel |
/* GECKO3COM
|
2 |
|
|
*
|
3 |
|
|
* Copyright (C) 2009 by
|
4 |
|
|
* ___ ____ _ _
|
5 |
|
|
* ( _`\ ( __)( ) ( )
|
6 |
|
|
* | (_) )| (_ | |_| | Berne University of Applied Sciences
|
7 |
|
|
* | _ <'| _) | _ | School of Engineering and
|
8 |
|
|
* | (_) )| | | | | | Information Technology
|
9 |
|
|
* (____/'(_) (_) (_)
|
10 |
|
|
*
|
11 |
|
|
*
|
12 |
|
|
* This program is free software: you can redistribute it and/or modify
|
13 |
|
|
* it under the terms of the GNU General Public License as published by
|
14 |
|
|
* the Free Software Foundation, either version 3 of the License, or
|
15 |
|
|
* (at your option) any later version.
|
16 |
|
|
*
|
17 |
|
|
* This program is distributed in the hope that it will be useful,
|
18 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
|
|
* GNU General Public License for more details.
|
21 |
|
|
* You should have received a copy of the GNU General Public License
|
22 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
/*********************************************************************/
|
26 |
|
|
/** \file scpi_parser.h
|
27 |
|
|
*********************************************************************
|
28 |
|
|
* \brief General header file for an scpi parser.
|
29 |
|
|
*
|
30 |
|
|
* This SCPI parser header file should be usefull for
|
31 |
|
|
* different parser implementations.
|
32 |
|
|
* You can design your parser for example with a parser
|
33 |
|
|
* generator like re2c (regular expressions to C) or by hand.
|
34 |
|
|
*
|
35 |
|
|
* In this file we define a enum type for the actions to
|
36 |
|
|
* be exceduted outside the parser. Add your desired actions
|
37 |
|
|
* here and implement them elsewhere.
|
38 |
|
|
* To modify the the known commands and the according action
|
39 |
|
|
* modify the scpi_parser.c file.
|
40 |
|
|
*
|
41 |
|
|
* \author Christoph Zimmermann bfh.ch
|
42 |
|
|
* \date 2009-02-04
|
43 |
|
|
*
|
44 |
|
|
*/
|
45 |
|
|
|
46 |
|
|
#ifndef _SCPI_PARSER_H_
|
47 |
|
|
#define _SCPI_PARSER_H_
|
48 |
|
|
|
49 |
|
|
#include "usb_tmc.h"
|
50 |
|
|
|
51 |
|
|
/** \brief define action flags for device dependent commands here.
|
52 |
|
|
* command syntax is defined in the parser itself */
|
53 |
|
|
typedef enum {
|
54 |
|
|
NOACTION,
|
55 |
|
|
SYSTEM_RESET,
|
56 |
|
|
rqFPGA_IDCODE,
|
57 |
|
|
rqFPGA_TYPE,
|
58 |
|
|
rqFPGA_DONE,
|
59 |
|
|
FPGA_CONFIGURE,
|
60 |
|
|
FPGA_COMMUNICATION,
|
61 |
|
|
rqSPI_FILE_LIST,
|
62 |
|
|
SPI_DELETE,
|
63 |
|
|
SPI_WRITE,
|
64 |
|
|
} SCPI_Action;
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
/** \brief struct with the pointers for the scpi_scan
|
68 |
|
|
*
|
69 |
|
|
* struct that contains all pointer needed for the scpi scanner to work.
|
70 |
|
|
* set the source pointer to the start of the scpi message (for example to
|
71 |
|
|
* the endpoint buffer to the byte afterthe usb tmc header). */
|
72 |
|
|
typedef struct Scanner {
|
73 |
|
|
unsigned char *source; /**< pointer to the data to be parsed */
|
74 |
|
|
SCPI_Action action; /**< device command parsed. this value says which action the device should execute now */
|
75 |
|
|
} Scanner;
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
/** \brief parser for scpi/IEEE488.2 commands
|
79 |
|
|
*
|
80 |
|
|
* The parser for scpi 99 and IEEE488.2 commands. Most mandatory commands are
|
81 |
|
|
* implemented (due to memory restrictions) and all of them are handled in
|
82 |
|
|
* the parser. Device dependent commands are handled outside of the parser.
|
83 |
|
|
*
|
84 |
|
|
* \param[in] idata uint16_t *offset pointer to the offset, buffer[offset] is
|
85 |
|
|
* the current position, anything before this is already consumed.
|
86 |
|
|
* \param[in] xdata Scanner *s a Scanner struct with the member *source set to
|
87 |
|
|
* the start of the scpi message
|
88 |
|
|
* \param[in] xdata TMC_Response_Queue *queue pointer to a TMC_Response_Queue
|
89 |
|
|
* \return Status value, 0 if an error occoured in this case the error is
|
90 |
|
|
* written to the IEEE488 event register. */
|
91 |
|
|
int8_t scpi_scan(idata uint16_t *offset, xdata Scanner *s, xdata TMC_Response_Queue *queue);
|
92 |
|
|
|
93 |
|
|
#endif
|