]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-dad.git/blob - sw/app/lx_dad/distore_simple.h
Prepare build-able skeleton for LX_DAD application.
[fpga/lx-cpu1/lx-dad.git] / sw / app / lx_dad / distore_simple.h
1 #ifndef _DISTORE_SIMPLE_H
2 #define _DISTORE_SIMPLE_H
3
4 #include <string.h>
5 #include <suiut/sui_dinfo.h>
6
7 #include "appl_defs.h"
8
9 #ifdef CONFIG_OC_I2C_DRV_SYSLESS
10 #include <i2c_drv.h>
11 extern i2c_drv_t i2c_drv;
12 #endif
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 enum distore_encformat {
19   DISTORE_ENC_END           = 0x00,
20   DISTORE_ENC_FLOAT_CODE    = 0x10,
21   DISTORE_ENC_SIGNED_CODE   = 0x20,
22   DISTORE_ENC_UNSIGNED_CODE = 0x30,
23   DISTORE_ENC_NUM_LEN       = 0x0f,
24   DISTORE_ENC_NUM_LEN_BITS  =    4,
25   DISTORE_ENC_TEXT_CODE     = 0x80,
26   DISTORE_ENC_TEXT_LEN      = 0x7f,
27 };
28
29 #define DISTORE_FLG_LOAD_ONLY 1
30
31 typedef unsigned short distore_id_t;
32
33 typedef struct distore_des_item_t {
34   sui_dinfo_t *dinfo;
35   unsigned char encform;
36   unsigned char idxlimit;
37   distore_id_t id;
38   unsigned short flags;
39 } distore_des_item_t;
40
41 typedef struct distore_des_array_t {
42   struct {
43     const distore_des_item_t *items;
44     unsigned count;
45   } array;
46 } distore_des_array_t;
47
48 const distore_des_item_t *
49 distore_des_array_at (const distore_des_array_t * array, unsigned indx);
50
51 const distore_des_item_t *
52 distore_des_array_find (const distore_des_array_t * array,
53                         distore_id_t const * key);
54
55 typedef ssize_t distore_wrfnc_t(void *context, const void *buf, size_t count);
56 typedef ssize_t distore_rdfnc_t(void *context, void *buf, size_t count);
57
58 ssize_t distore_count_maxsize(const distore_des_array_t *des);
59
60 int distore_store_data(const distore_des_array_t *des,
61                        distore_wrfnc_t *wrfnc, void *context);
62
63 #define DISTORE_LOAD_IGNORE_UNKNOWN     1
64 #define DISTORE_LOAD_IGNORE_WRITE_ERR   2
65
66 int distore_load_data(const distore_des_array_t *des,
67                        distore_rdfnc_t *rdfnc, void *context, int mode);
68
69 #ifdef __cplusplus
70 } /* extern "C"*/
71 #endif
72
73 #endif /* _DISTORE_SIMPLE_H*/