diff options
Diffstat (limited to 'firmware/target/arm/as3525/as3525-codec.c')
-rw-r--r-- | firmware/target/arm/as3525/as3525-codec.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/firmware/target/arm/as3525/as3525-codec.c b/firmware/target/arm/as3525/as3525-codec.c index 4d8598eaf1..86bce86c39 100644 --- a/firmware/target/arm/as3525/as3525-codec.c +++ b/firmware/target/arm/as3525/as3525-codec.c | |||
@@ -38,6 +38,7 @@ | |||
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include "ascodec-target.h" | 40 | #include "ascodec-target.h" |
41 | #include "kernel.h" | ||
41 | #include "as3525.h" | 42 | #include "as3525.h" |
42 | 43 | ||
43 | #define I2C2_DATA *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x00)) | 44 | #define I2C2_DATA *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x00)) |
@@ -53,6 +54,7 @@ | |||
53 | #define I2C2_INT_CLR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x40)) | 54 | #define I2C2_INT_CLR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x40)) |
54 | #define I2C2_SADDR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x44)) | 55 | #define I2C2_SADDR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x44)) |
55 | 56 | ||
57 | static struct mutex as_mtx SHAREDBSS_ATTR; | ||
56 | 58 | ||
57 | /* initialises the internal i2c bus and prepares for transfers to the codec */ | 59 | /* initialises the internal i2c bus and prepares for transfers to the codec */ |
58 | void ascodec_init(void) | 60 | void ascodec_init(void) |
@@ -84,7 +86,7 @@ static int i2c_busy(void) | |||
84 | 86 | ||
85 | 87 | ||
86 | /* returns 0 on success, <0 otherwise */ | 88 | /* returns 0 on success, <0 otherwise */ |
87 | int ascodec_write(int index, int value) | 89 | int ascodec_write(unsigned int index, unsigned int value) |
88 | { | 90 | { |
89 | if (index == 0x21) { | 91 | if (index == 0x21) { |
90 | /* prevent setting of the LREG_CP_not bit */ | 92 | /* prevent setting of the LREG_CP_not bit */ |
@@ -110,7 +112,7 @@ int ascodec_write(int index, int value) | |||
110 | 112 | ||
111 | 113 | ||
112 | /* returns value read on success, <0 otherwise */ | 114 | /* returns value read on success, <0 otherwise */ |
113 | int ascodec_read(int index) | 115 | int ascodec_read(unsigned int index) |
114 | { | 116 | { |
115 | /* check if still busy */ | 117 | /* check if still busy */ |
116 | if (i2c_busy()) { | 118 | if (i2c_busy()) { |
@@ -128,3 +130,32 @@ int ascodec_read(int index) | |||
128 | return I2C2_DATA; | 130 | return I2C2_DATA; |
129 | } | 131 | } |
130 | 132 | ||
133 | int ascodec_readbytes(int index, int len, unsigned char *data) | ||
134 | { | ||
135 | int i; | ||
136 | |||
137 | ascodec_lock(); | ||
138 | |||
139 | for(i=0; i<len; i++) | ||
140 | { | ||
141 | int temp = ascodec_read(index+i); | ||
142 | if(temp == -1) | ||
143 | break; | ||
144 | else | ||
145 | data[i] = temp; | ||
146 | } | ||
147 | |||
148 | ascodec_unlock(); | ||
149 | |||
150 | return i; | ||
151 | } | ||
152 | |||
153 | void ascodec_lock(void) | ||
154 | { | ||
155 | mutex_lock(&as_mtx); | ||
156 | } | ||
157 | |||
158 | void ascodec_unlock(void) | ||
159 | { | ||
160 | mutex_unlock(&as_mtx); | ||
161 | } | ||