1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Linus Nielsen Feltzing 2005-11-16 13:27:07 +00:00
parent fa32b8c1b1
commit ffe0b23902
2 changed files with 26 additions and 9 deletions

View file

@ -201,7 +201,7 @@ int pcf50606_i2c_write(int address, const unsigned char* buf, int count)
return x; 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 i=0;
int ret = 0; int ret = 0;
@ -232,7 +232,19 @@ int pcf50606_read(int address, unsigned char* buf, int count)
return ret; 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]; unsigned char obuf[1];
int i; int i;
@ -262,6 +274,12 @@ int pcf50606_write(int address, const unsigned char* buf, int count)
return ret; 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 /* These voltages were determined by measuring the output of the PCF50606
on a running H300, and verified by disassembling the original firmware */ on a running H300, and verified by disassembling the original firmware */
static void set_voltages(void) static void set_voltages(void)
@ -275,13 +293,11 @@ static void set_voltages(void)
0xef, /* LPREGC1 = 2.4V, ON in all states */ 0xef, /* LPREGC1 = 2.4V, ON in all states */
}; };
pcf50606_write(0x23, buf, 5); pcf50606_write_multiple(0x23, buf, 5);
} }
void pcf50606_init(void) void pcf50606_init(void)
{ {
unsigned char c;
/* Bit banged I2C */ /* Bit banged I2C */
or_l(0x00002000, &GPIO1_OUT); or_l(0x00002000, &GPIO1_OUT);
or_l(0x00001000, &GPIO_OUT); or_l(0x00001000, &GPIO_OUT);
@ -293,6 +309,5 @@ void pcf50606_init(void)
set_voltages(); set_voltages();
/* Backlight PWM = 512Hz 50/50 */ /* Backlight PWM = 512Hz 50/50 */
c = 0x13; pcf50606_write(0x35, 0x13);
pcf50606_write(0x35, &c, 1);
} }

View file

@ -21,8 +21,10 @@
#ifdef IRIVER_H300_SERIES #ifdef IRIVER_H300_SERIES
void pcf50606_init(void); void pcf50606_init(void);
int pcf50606_write(int address, const unsigned char* buf, int count); int pcf50606_write_multiple(int address, const unsigned char* buf, int count);
int pcf50606_read(int address, 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
#endif #endif