diff options
Diffstat (limited to 'firmware/drivers/pcf50606.c')
-rw-r--r-- | firmware/drivers/pcf50606.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c index 993e56800d..a2045291ec 100644 --- a/firmware/drivers/pcf50606.c +++ b/firmware/drivers/pcf50606.c | |||
@@ -201,7 +201,7 @@ int pcf50606_i2c_write(int address, const unsigned char* buf, int count) | |||
201 | return x; | 201 | return x; |
202 | } | 202 | } |
203 | 203 | ||
204 | int pcf50606_read(int address, unsigned char* buf, int count) | 204 | int pcf50606_read_multiple(int address, unsigned char* buf, int count) |
205 | { | 205 | { |
206 | int i=0; | 206 | int i=0; |
207 | int ret = 0; | 207 | int ret = 0; |
@@ -232,7 +232,19 @@ int pcf50606_read(int address, unsigned char* buf, int count) | |||
232 | return ret; | 232 | return ret; |
233 | } | 233 | } |
234 | 234 | ||
235 | int pcf50606_write(int address, const unsigned char* buf, int count) | 235 | int pcf50606_read(int address) |
236 | { | ||
237 | int ret; | ||
238 | unsigned char c; | ||
239 | |||
240 | ret = pcf50606_read_multiple(address, &c, 1); | ||
241 | if(ret >= 0) | ||
242 | return c; | ||
243 | else | ||
244 | return ret; | ||
245 | } | ||
246 | |||
247 | int pcf50606_write_multiple(int address, const unsigned char* buf, int count) | ||
236 | { | 248 | { |
237 | unsigned char obuf[1]; | 249 | unsigned char obuf[1]; |
238 | int i; | 250 | int i; |
@@ -262,6 +274,12 @@ int pcf50606_write(int address, const unsigned char* buf, int count) | |||
262 | return ret; | 274 | return ret; |
263 | } | 275 | } |
264 | 276 | ||
277 | int pcf50606_write(int address, unsigned char val) | ||
278 | { | ||
279 | return pcf50606_write_multiple(address, &val, 1); | ||
280 | } | ||
281 | |||
282 | |||
265 | /* These voltages were determined by measuring the output of the PCF50606 | 283 | /* These voltages were determined by measuring the output of the PCF50606 |
266 | on a running H300, and verified by disassembling the original firmware */ | 284 | on a running H300, and verified by disassembling the original firmware */ |
267 | static void set_voltages(void) | 285 | static void set_voltages(void) |
@@ -275,13 +293,11 @@ static void set_voltages(void) | |||
275 | 0xef, /* LPREGC1 = 2.4V, ON in all states */ | 293 | 0xef, /* LPREGC1 = 2.4V, ON in all states */ |
276 | }; | 294 | }; |
277 | 295 | ||
278 | pcf50606_write(0x23, buf, 5); | 296 | pcf50606_write_multiple(0x23, buf, 5); |
279 | } | 297 | } |
280 | 298 | ||
281 | void pcf50606_init(void) | 299 | void pcf50606_init(void) |
282 | { | 300 | { |
283 | unsigned char c; | ||
284 | |||
285 | /* Bit banged I2C */ | 301 | /* Bit banged I2C */ |
286 | or_l(0x00002000, &GPIO1_OUT); | 302 | or_l(0x00002000, &GPIO1_OUT); |
287 | or_l(0x00001000, &GPIO_OUT); | 303 | or_l(0x00001000, &GPIO_OUT); |
@@ -293,6 +309,5 @@ void pcf50606_init(void) | |||
293 | set_voltages(); | 309 | set_voltages(); |
294 | 310 | ||
295 | /* Backlight PWM = 512Hz 50/50 */ | 311 | /* Backlight PWM = 512Hz 50/50 */ |
296 | c = 0x13; | 312 | pcf50606_write(0x35, 0x13); |
297 | pcf50606_write(0x35, &c, 1); | ||
298 | } | 313 | } |