diff options
Diffstat (limited to 'firmware/target/arm/as3525/ascodec-target.h')
-rw-r--r-- | firmware/target/arm/as3525/ascodec-target.h | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/firmware/target/arm/as3525/ascodec-target.h b/firmware/target/arm/as3525/ascodec-target.h index 3464bbaa51..4b110412c1 100644 --- a/firmware/target/arm/as3525/ascodec-target.h +++ b/firmware/target/arm/as3525/ascodec-target.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #define _ASCODEC_TARGET_H | 26 | #define _ASCODEC_TARGET_H |
27 | 27 | ||
28 | #include "as3514.h" | 28 | #include "as3514.h" |
29 | #include "kernel.h" /* for struct wakeup */ | ||
29 | 30 | ||
30 | /* Charge Pump and Power management Settings */ | 31 | /* Charge Pump and Power management Settings */ |
31 | #define AS314_CP_DCDC3_SETTING \ | 32 | #define AS314_CP_DCDC3_SETTING \ |
@@ -41,13 +42,61 @@ | |||
41 | #define CVDD_1_10 2 | 42 | #define CVDD_1_10 2 |
42 | #define CVDD_1_05 3 | 43 | #define CVDD_1_05 3 |
43 | 44 | ||
45 | #define ASCODEC_REQ_READ 0 | ||
46 | #define ASCODEC_REQ_WRITE 1 | ||
47 | |||
48 | /* | ||
49 | * How many bytes we using in struct ascodec_request for the data buffer. | ||
50 | * 4 fits the alignment best right now. | ||
51 | * We don't actually use more than 2 at the moment (in adc_read). | ||
52 | * Upper limit would be 255 since DACNT is 8 bits! | ||
53 | */ | ||
54 | #define ASCODEC_REQ_MAXLEN 4 | ||
55 | |||
56 | typedef void (ascodec_cb_fn)(unsigned const char *data, unsigned cnt); | ||
57 | |||
58 | struct ascodec_request { | ||
59 | unsigned char type; | ||
60 | unsigned char index; | ||
61 | unsigned char status; | ||
62 | unsigned char cnt; | ||
63 | unsigned char data[ASCODEC_REQ_MAXLEN]; | ||
64 | struct wakeup wkup; | ||
65 | ascodec_cb_fn *callback; | ||
66 | struct ascodec_request *next; | ||
67 | }; | ||
68 | |||
44 | void ascodec_init(void); | 69 | void ascodec_init(void); |
45 | 70 | ||
46 | int ascodec_write(unsigned int index, unsigned int value); | 71 | int ascodec_write(unsigned int index, unsigned int value); |
47 | 72 | ||
48 | int ascodec_read(unsigned int index); | 73 | int ascodec_read(unsigned int index); |
49 | 74 | ||
50 | int ascodec_readbytes(int index, int len, unsigned char *data); | 75 | int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data); |
76 | |||
77 | /* | ||
78 | * The request struct passed in must be allocated statically. | ||
79 | * If you call ascodec_async_write from different places, each | ||
80 | * call needs it's own request struct. | ||
81 | * This comment is duplicated in .c and .h for your convenience. | ||
82 | */ | ||
83 | void ascodec_async_write(unsigned index, unsigned int value, struct ascodec_request *req); | ||
84 | |||
85 | /* | ||
86 | * The request struct passed in must be allocated statically. | ||
87 | * If you call ascodec_async_read from different places, each | ||
88 | * call needs it's own request struct. | ||
89 | * If len is bigger than ASCODEC_REQ_MAXLEN it will be | ||
90 | * set to ASCODEC_REQ_MAXLEN. | ||
91 | * This comment is duplicated in .c and .h for your convenience. | ||
92 | */ | ||
93 | void ascodec_async_read(unsigned index, unsigned int len, | ||
94 | struct ascodec_request *req, ascodec_cb_fn *cb); | ||
95 | |||
96 | void ascodec_req_init(struct ascodec_request *req, int type, | ||
97 | unsigned int index, unsigned int cnt); | ||
98 | |||
99 | void ascodec_submit(struct ascodec_request *req); | ||
51 | 100 | ||
52 | void ascodec_lock(void); | 101 | void ascodec_lock(void); |
53 | 102 | ||