/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/pcilib.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-18 01:47:47 UTC
  • Revision ID: csa@suren.me-20151018014747-9ji2ygdhz1l9wnt5
Support properties of arbitrary type

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
} pcilib_endianess_t;
42
42
 
43
43
typedef enum {
 
44
    PCILIB_ACCESS_R = 1,                        /**< getting property is allowed */
 
45
    PCILIB_ACCESS_W = 2,                        /**< setting property is allowed */
 
46
    PCILIB_ACCESS_RW = 3
 
47
} pcilib_access_mode_t;
 
48
 
 
49
typedef enum {
44
50
    PCILIB_TYPE_INVALID = 0,                    /**< uninitialized */
45
51
    PCILIB_TYPE_DEFAULT = 0,                    /**< default type */
46
52
    PCILIB_TYPE_STRING = 1,                     /**< char* */
74
80
} pcilib_dma_flags_t;
75
81
 
76
82
typedef enum {
77
 
    PCILIB_STREAMING_STOP = 0,          /**< stop streaming */
78
 
    PCILIB_STREAMING_CONTINUE = 1,      /**< wait the default DMA timeout for a new data */
79
 
    PCILIB_STREAMING_WAIT = 2,          /**< wait the specified timeout for a new data */
80
 
    PCILIB_STREAMING_CHECK = 3,         /**< do not wait for the data, bail out imideatly if no data ready */
81
 
    PCILIB_STREAMING_FAIL = 4,          /**< fail if data is not available on timeout */
82
 
    PCILIB_STREAMING_REQ_FRAGMENT = 5,  /**< only fragment of a packet is read, wait for next fragment and fail if no data during DMA timeout */
83
 
    PCILIB_STREAMING_REQ_PACKET = 6,    /**< wait for next packet and fail if no data during the specified timeout */
84
 
    PCILIB_STREAMING_TIMEOUT_MASK = 3   /**< mask specifying all timeout modes */
 
83
    PCILIB_STREAMING_STOP = 0,                  /**< stop streaming */
 
84
    PCILIB_STREAMING_CONTINUE = 1,              /**< wait the default DMA timeout for a new data */
 
85
    PCILIB_STREAMING_WAIT = 2,                  /**< wait the specified timeout for a new data */
 
86
    PCILIB_STREAMING_CHECK = 3,                 /**< do not wait for the data, bail out imideatly if no data ready */
 
87
    PCILIB_STREAMING_FAIL = 4,                  /**< fail if data is not available on timeout */
 
88
    PCILIB_STREAMING_REQ_FRAGMENT = 5,          /**< only fragment of a packet is read, wait for next fragment and fail if no data during DMA timeout */
 
89
    PCILIB_STREAMING_REQ_PACKET = 6,            /**< wait for next packet and fail if no data during the specified timeout */
 
90
    PCILIB_STREAMING_TIMEOUT_MASK = 3           /**< mask specifying all timeout modes */
85
91
} pcilib_streaming_action_t;
86
92
 
87
93
typedef enum {
104
110
    pcilib_event_info_flags_t flags;            /**< flags */
105
111
} pcilib_event_info_t;
106
112
 
 
113
typedef enum {
 
114
    PCILIB_LIST_FLAGS_DEFAULT = 0,
 
115
    PCILIB_LIST_FLAG_CHILDS = 1                 /**< Request all sub-elements or indicated that sub-elements are available */
 
116
} pcilib_list_flags_t;
 
117
 
107
118
typedef struct {
108
 
    pcilib_value_type_t type;
109
 
    const char *unit;
110
 
    const char *format;
 
119
    pcilib_value_type_t type;                   /**< Current data type */
 
120
    const char *unit;                           /**< Units (if known) */
 
121
    const char *format;                         /**< requested printf format (may enforce using output in hex form) */
111
122
 
112
123
    union {
113
 
        long ival;
114
 
        double fval;
115
 
        const char *sval;
 
124
        long ival;                              /**< The value if type = PCILIB_TYPE_LONG */
 
125
        double fval;                            /**< The value if type = PCILIB_TYPE_DOUBLE */
 
126
        const char *sval;                       /**< The value if type = PCILIB_TYPE_STRING, the pointer may point to static location or reference actual string in str or data */
116
127
    };
117
128
 
118
129
        // This is a private part
119
 
    size_t size;
120
 
    void *data;
121
 
    char str[16];
 
130
    size_t size;                                /**< Size of the data */
 
131
    void *data;                                 /**< Arbitrary data, for instance actual string referenced by the sval */
 
132
    char str[16];                               /**< Used for shorter strings converted from integer/float types */
122
133
} pcilib_value_t;
123
134
 
 
135
typedef struct {
 
136
    const char *name;                           /**< Name of the property view */
 
137
    const char *path;                           /**< Full path to the property */
 
138
    const char *description;                    /**< Short description */
 
139
    pcilib_value_type_t type;                   /**< The default data type or PCILIB_TYPE_INVALID if directory */
 
140
    pcilib_access_mode_t mode;                  /**< Specifies if the view is read/write-only */
 
141
    pcilib_list_flags_t flags;                  /**< Indicates if have sub-folders, etc. */
 
142
    const char *unit;                           /**< Returned unit (if any) */
 
143
} pcilib_property_info_t;
 
144
 
124
145
 
125
146
#define PCILIB_BAR_DETECT               ((pcilib_bar_t)-1)
126
147
#define PCILIB_BAR_INVALID              ((pcilib_bar_t)-1)
218
239
int pcilib_write_register_by_id(pcilib_t *ctx, pcilib_register_t reg, pcilib_register_value_t value);
219
240
int pcilib_read_register(pcilib_t *ctx, const char *bank, const char *regname, pcilib_register_value_t *value);
220
241
int pcilib_write_register(pcilib_t *ctx, const char *bank, const char *regname, pcilib_register_value_t value);
 
242
int pcilib_read_register_view(pcilib_t *ctx, const char *bank, const char *regname, const char *unit, pcilib_value_t *value);
 
243
int pcilib_write_register_view(pcilib_t *ctx, const char *bank, const char *regname, const char *unit, const pcilib_value_t *value);
221
244
 
222
245
void pcilib_clean_value(pcilib_t *ctx, pcilib_value_t *val);
223
246
int pcilib_copy_value(pcilib_t *ctx, pcilib_value_t *dst, const pcilib_value_t *src);
228
251
double pcilib_get_value_as_float(pcilib_t *ctx, const pcilib_value_t *val, int *err);
229
252
long pcilib_get_value_as_int(pcilib_t *ctx, const pcilib_value_t *val, int *err);
230
253
pcilib_register_value_t pcilib_get_value_as_register_value(pcilib_t *ctx, const pcilib_value_t *val, int *err);
231
 
 
232
254
int pcilib_convert_value_unit(pcilib_t *ctx, pcilib_value_t *val, const char *unit_name);
233
255
int pcilib_convert_value_type(pcilib_t *ctx, pcilib_value_t *val, pcilib_value_type_t type);
234
256
 
235
 
int pcilib_read_register_view(pcilib_t *ctx, const char *bank, const char *regname, const char *unit, pcilib_value_t *value);
236
 
int pcilib_write_register_view(pcilib_t *ctx, const char *bank, const char *regname, const char *unit, const pcilib_value_t *value);
 
257
pcilib_property_info_t *pcilib_get_property_list(pcilib_t *ctx, const char *branch, pcilib_list_flags_t flags);
 
258
void pcilib_free_property_info(pcilib_t *ctx, pcilib_property_info_t *info);
 
259
int pcilib_get_property(pcilib_t *ctx, const char *prop, pcilib_value_t *val);
 
260
int pcilib_set_property(pcilib_t *ctx, const char *prop, const pcilib_value_t *val);
 
261
 
237
262
 
238
263
int pcilib_reset(pcilib_t *ctx);
239
264
int pcilib_trigger(pcilib_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data);