summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-05-19 18:03:27 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2012-05-19 18:04:25 +0200
commite4016834822e3211ff0693691c456f3d620cad0a (patch)
treef6e5bd8a60828f3a91fdd69a2964b6b290353b8a /firmware/drivers
parent4f5efac9e5ae326f666d30a8b93cab5a7c18eb4e (diff)
downloadrockbox-e4016834822e3211ff0693691c456f3d620cad0a.tar.gz
rockbox-e4016834822e3211ff0693691c456f3d620cad0a.zip
zenxfi3&stfm1000: implement fmradio i2c and debug screen
Change-Id: I83dbdee13185d9adcf590dc213da5a8c97adb2ba
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/tuner/stfm1000.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/firmware/drivers/tuner/stfm1000.c b/firmware/drivers/tuner/stfm1000.c
index ae96993285..8626d4e2a5 100644
--- a/firmware/drivers/tuner/stfm1000.c
+++ b/firmware/drivers/tuner/stfm1000.c
@@ -31,6 +31,36 @@
31#include "fmradio_i2c.h" /* physical interface driver */ 31#include "fmradio_i2c.h" /* physical interface driver */
32#include "stfm1000.h" 32#include "stfm1000.h"
33 33
34#define STFM100_I2C_ADDR 0xc0
35
36#define CHIPID 0x80
37
38static int stfm1000_read_reg(uint8_t reg, uint32_t *val)
39{
40 uint8_t buf[4];
41 buf[0] = reg;
42 int ret = fmradio_i2c_write(STFM100_I2C_ADDR, buf, 1);
43 if(ret < 0) return ret;
44 ret = fmradio_i2c_read(STFM100_I2C_ADDR, buf, 4);
45 *val = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24;
46 return ret;
47}
48
49static int stfm1000_write_reg(uint8_t reg, uint32_t val)
50{
51 uint8_t buf[5];
52 buf[0] = reg;
53 buf[1] = val & 0xff; buf[2] = (val >> 8) & 0xff;
54 buf[3] = (val >> 16) & 0xff; buf[4] = (val >> 24) & 0xff;
55 return fmradio_i2c_write(STFM100_I2C_ADDR, buf, 5);
56}
57
58void stfm1000_dbg_info(struct stfm1000_dbg_info *nfo)
59{
60 memset(nfo, 0, sizeof(struct stfm1000_dbg_info));
61 stfm1000_read_reg(CHIPID, &nfo->chipid);
62}
63
34void stfm1000_init(void) 64void stfm1000_init(void)
35{ 65{
36} 66}