summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-11-16 13:27:07 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-11-16 13:27:07 +0000
commitffe0b23902ef8e92f60b7c15b53dfbb1f23fce8c (patch)
tree49733d6b9d8489c5b0ca6d4a266339534337dd66 /firmware/drivers
parentfa32b8c1b1112cba4ed19a55dadbd52de85221e9 (diff)
downloadrockbox-ffe0b23902ef8e92f60b7c15b53dfbb1f23fce8c.tar.gz
rockbox-ffe0b23902ef8e92f60b7c15b53dfbb1f23fce8c.zip
Added single-byte read/write functions for the PCF50606 driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7905 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/pcf50606.c29
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
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}