diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-24 12:35:37 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-24 12:35:37 +0000 |
commit | e1cb054fa0bebd10b40156e4b0318d233ca11d8f (patch) | |
tree | f6442d6cd4d8e9add63769455c67db6ea2b7a03d /firmware/drivers/dac.c | |
parent | b38c2d996d339a68f33a8b681cce359a86f65bcf (diff) |
Now uses i2c_begin/end
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1147 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/dac.c')
-rw-r--r-- | firmware/drivers/dac.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/firmware/drivers/dac.c b/firmware/drivers/dac.c index c968246a61..63695c3c67 100644 --- a/firmware/drivers/dac.c +++ b/firmware/drivers/dac.c @@ -22,23 +22,26 @@ int dac_volume(unsigned int volume) { - int i; - unsigned char buf[16]; + int ret = 0; + unsigned char buf[3]; + + i2c_begin(); if(volume > 0x38) volume = 0x38; - i=0; - buf[i++] = DAC_REG_WRITE | DAC_AVOL; - buf[i++] = (volume & 0x3f) | 0x40; /* Deemphasis ON */ - buf[i++] = volume & 0x3f; + buf[0] = DAC_REG_WRITE | DAC_AVOL; + buf[1] = (volume & 0x3f) | 0x40; /* Deemphasis ON */ + buf[2] = volume & 0x3f; /* send read command */ - if (i2c_write(DAC_DEV_WRITE,buf,i)) + if (i2c_write(DAC_DEV_WRITE,buf,3)) { - return -1; + ret = -1; } - return 0; + + i2c_end(); + return ret; } /****************************************************************** @@ -52,17 +55,20 @@ int dac_volume(unsigned int volume) ******************************************************************/ int dac_config(int value) { - int i; - unsigned char buf[16]; + int ret = 0; + unsigned char buf[2]; - i=0; - buf[i++] = DAC_REG_WRITE | DAC_GCFG; - buf[i++] = value; + i2c_begin(); + + buf[0] = DAC_REG_WRITE | DAC_GCFG; + buf[1] = value; /* send read command */ - if (i2c_write(DAC_DEV_WRITE,buf,i)) + if (i2c_write(DAC_DEV_WRITE,buf,2)) { - return -1; + ret = -1; } + + i2c_end(); return 0; } |