summaryrefslogtreecommitdiff
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
parentfa32b8c1b1112cba4ed19a55dadbd52de85221e9 (diff)
downloadrockbox-ffe0b23902ef8e92f60b7c15b53dfbb1f23fce8c.zip
rockbox-ffe0b23902ef8e92f60b7c15b53dfbb1f23fce8c.tar.gz
rockbox-ffe0b23902ef8e92f60b7c15b53dfbb1f23fce8c.tar.bz2
rockbox-ffe0b23902ef8e92f60b7c15b53dfbb1f23fce8c.tar.xz
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
-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 993e568..a204529 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)
return x;
}
-int pcf50606_read(int address, unsigned char* buf, int count)
+int pcf50606_read_multiple(int address, unsigned char* buf, int count)
{
int i=0;
int ret = 0;
@@ -232,7 +232,19 @@ int pcf50606_read(int address, unsigned char* buf, int count)
return ret;
}
-int pcf50606_write(int address, const unsigned char* buf, int count)
+int pcf50606_read(int address)
+{
+ int ret;
+ unsigned char c;
+
+ ret = pcf50606_read_multiple(address, &c, 1);
+ if(ret >= 0)
+ return c;
+ else
+ return ret;
+}
+
+int pcf50606_write_multiple(int address, const unsigned char* buf, int count)
{
unsigned char obuf[1];
int i;
@@ -262,6 +274,12 @@ int pcf50606_write(int address, const unsigned char* buf, int count)
return ret;
}
+int pcf50606_write(int address, unsigned char val)
+{
+ return pcf50606_write_multiple(address, &val, 1);
+}
+
+
/* These voltages were determined by measuring the output of the PCF50606
on a running H300, and verified by disassembling the original firmware */
static void set_voltages(void)
@@ -275,13 +293,11 @@ static void set_voltages(void)
0xef, /* LPREGC1 = 2.4V, ON in all states */
};
- pcf50606_write(0x23, buf, 5);
+ pcf50606_write_multiple(0x23, buf, 5);
}
void pcf50606_init(void)
{
- unsigned char c;
-
/* Bit banged I2C */
or_l(0x00002000, &GPIO1_OUT);
or_l(0x00001000, &GPIO_OUT);
@@ -293,6 +309,5 @@ void pcf50606_init(void)
set_voltages();
/* Backlight PWM = 512Hz 50/50 */
- c = 0x13;
- pcf50606_write(0x35, &c, 1);
+ pcf50606_write(0x35, 0x13);
}
diff --git a/firmware/export/pcf50606.h b/firmware/export/pcf50606.h
index 3941ea6..fd180bf 100644
--- a/firmware/export/pcf50606.h
+++ b/firmware/export/pcf50606.h
@@ -21,8 +21,10 @@
#ifdef IRIVER_H300_SERIES
void pcf50606_init(void);
-int pcf50606_write(int address, const unsigned char* buf, int count);
-int pcf50606_read(int address, unsigned char* buf, int count);
+int pcf50606_write_multiple(int address, const unsigned char* buf, int count);
+int pcf50606_write(int address, unsigned char val);
+int pcf50606_read_multiple(int address, unsigned char* buf, int count);
+int pcf50606_read(int address);
#endif
#endif