summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-12-29 12:02:49 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-12-29 12:02:49 +0000
commit7b596416bf2cf533a514b4d1f7b95c6de6efa7d5 (patch)
treee1a0031a93591424eacdf943796680880077a3a4 /firmware/drivers
parent20d81d979a22403c16c1f1c576de63af07b2ea99 (diff)
downloadrockbox-7b596416bf2cf533a514b4d1f7b95c6de6efa7d5.zip
rockbox-7b596416bf2cf533a514b4d1f7b95c6de6efa7d5.tar.gz
rockbox-7b596416bf2cf533a514b4d1f7b95c6de6efa7d5.tar.bz2
rockbox-7b596416bf2cf533a514b4d1f7b95c6de6efa7d5.tar.xz
Gigabeat S: Update RDS processing to use asynchronous I2C rather than thread.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31462 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/rds.c39
-rw-r--r--firmware/drivers/tuner/si4700.c29
2 files changed, 66 insertions, 2 deletions
diff --git a/firmware/drivers/rds.c b/firmware/drivers/rds.c
index 09bc338..828c28b 100644
--- a/firmware/drivers/rds.c
+++ b/firmware/drivers/rds.c
@@ -36,14 +36,46 @@ static char rt_copy[65];
static int rt_segment;
static int rt_abflag;
+#ifdef SI4700_RDS_ASYNC
+/* Functions are called in ISR context */
+#define rds_disable_irq_save() disable_irq_save()
+#define rds_restore_irq(old) restore_irq(old)
+/* Need triple buffer so string isn't clobbered while caller is using it */
+static inline char * get_ps(void)
+{
+ static char ps_out[9];
+ int oldlevel = rds_disable_irq_save();
+ strcpy(ps_out, ps_copy);
+ rds_restore_irq(oldlevel);
+ return ps_out;
+}
+static inline char * get_rt(void)
+{
+ static char rt_out[65];
+ int oldlevel = rds_disable_irq_save();
+ strcpy(rt_out, rt_copy);
+ rds_restore_irq(oldlevel);
+ return rt_out;
+}
+#else /* ndef SI4700_RDS_ASYNC */
+#define rds_disable_irq_save() 0
+#define rds_restore_irq(old) ((void)(old))
+static inline char * get_ps(void) { return ps_copy; }
+static inline char * get_rt(void) { return rt_copy; }
+#endif /* SI4700_RDS_ASYNC */
+
/* resets the rds parser */
void rds_reset(void)
{
+ int oldlevel = rds_disable_irq_save();
+
ps_copy[0] = '\0';
ps_segment = 0;
rt_copy[0] = '\0';
rt_segment = 0;
pi = 0;
+
+ rds_restore_irq(oldlevel);
}
/* initialises the rds parser */
@@ -172,6 +204,9 @@ bool rds_process(uint16_t data[4])
return false;
}
+/* TODO: The caller really should provide the buffer in order to regulate
+ access */
+
/* returns the programme identification code */
uint16_t rds_get_pi(void)
{
@@ -181,12 +216,12 @@ uint16_t rds_get_pi(void)
/* returns the most recent valid programme service name */
char* rds_get_ps(void)
{
- return ps_copy;
+ return get_ps();
}
/* returns the most recent valid RadioText message */
char* rds_get_rt(void)
{
- return rt_copy;
+ return get_rt();
}
diff --git a/firmware/drivers/tuner/si4700.c b/firmware/drivers/tuner/si4700.c
index bebbd0c..0684d20 100644
--- a/firmware/drivers/tuner/si4700.c
+++ b/firmware/drivers/tuner/si4700.c
@@ -556,6 +556,34 @@ void si4700_dbg_info(struct si4700_dbg_info *nfo)
}
#ifdef HAVE_RDS_CAP
+
+#ifdef SI4700_RDS_ASYNC
+/* Read raw RDS info for processing - asynchronously */
+
+/* Assumes regbuf is 32 bytes */
+void si4700_rds_read_raw_async(void)
+{
+ si4700_read_raw_async((RDSD - STATUSRSSI + 1) * 2);
+}
+
+void si4700_rds_read_raw_async_complete(unsigned char *regbuf,
+ uint16_t data[4])
+{
+ const int index = (RDSA - STATUSRSSI) * 2;
+
+ for (int i = 0; i < 4; i++) {
+ data[i] = regbuf[index] << 8 | regbuf[index + 1];
+ regbuf += 2;
+ }
+}
+
+/* Set the event flag */
+void si4700_rds_set_event(void)
+{
+ rds_event = 1;
+}
+
+#else
/* Read raw RDS info for processing */
bool si4700_rds_read_raw(uint16_t data[4])
{
@@ -582,6 +610,7 @@ void si4700_rds_set_event(void)
rds_event = 1;
mutex_unlock(&fmr_mutex);
}
+#endif /* SI4700_RDS_ASYNC */
char * si4700_get_rds_info(int setting)
{