summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/pcf50606.c29
-rw-r--r--firmware/export/pcf50606.h6
2 files changed, 26 insertions, 9 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
204int pcf50606_read(int address, unsigned char* buf, int count) 204int 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
235int pcf50606_write(int address, const unsigned char* buf, int count) 235int 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
247int 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
277int 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 */
267static void set_voltages(void) 285static 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
281void pcf50606_init(void) 299void 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}
diff --git a/firmware/export/pcf50606.h b/firmware/export/pcf50606.h
index 3941ea68d4..fd180bfaee 100644
--- a/firmware/export/pcf50606.h
+++ b/firmware/export/pcf50606.h
@@ -21,8 +21,10 @@
21 21
22#ifdef IRIVER_H300_SERIES 22#ifdef IRIVER_H300_SERIES
23void pcf50606_init(void); 23void pcf50606_init(void);
24int pcf50606_write(int address, const unsigned char* buf, int count); 24int pcf50606_write_multiple(int address, const unsigned char* buf, int count);
25int pcf50606_read(int address, unsigned char* buf, int count); 25int pcf50606_write(int address, unsigned char val);
26int pcf50606_read_multiple(int address, unsigned char* buf, int count);
27int pcf50606_read(int address);
26#endif 28#endif
27 29
28#endif 30#endif