summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx31
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/target/arm/imx31
parent20d81d979a22403c16c1f1c576de63af07b2ea99 (diff)
downloadrockbox-7b596416bf2cf533a514b4d1f7b95c6de6efa7d5.tar.gz
rockbox-7b596416bf2cf533a514b4d1f7b95c6de6efa7d5.zip
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/target/arm/imx31')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
index e0457e367a..a7b9bc21da 100644
--- a/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
@@ -128,15 +128,52 @@ bool si4700_st(void)
/* Low-level RDS Support */
-static struct semaphore rds_sema;
-static uint32_t rds_stack[DEFAULT_STACK_SIZE/sizeof(uint32_t)];
-/* RDS GPIO interrupt handler */
+/* Transfer descriptor for RDS async operations */
+struct si4700_i2c_transfer_desc
+{
+ struct i2c_transfer_desc xfer;
+ unsigned char regbuf[32];
+} si4700_xfer =
+{
+ .xfer = { .node = &si4700_i2c_node }
+};
+
+static void si4700_rds_read_raw_callback(struct i2c_transfer_desc *xfer)
+{
+ struct si4700_i2c_transfer_desc *xf =
+ (struct si4700_i2c_transfer_desc *)xfer;
+
+ if (xfer->rxcount != 0)
+ return; /* Read didn't finish */
+
+ uint16_t rds_data[4];
+
+ si4700_rds_read_raw_async_complete(xf->regbuf, rds_data);
+
+ if (rds_process(rds_data))
+ si4700_rds_set_event();
+}
+
+/* Callback from si4700_rds_read_raw to execute the read */
+void si4700_read_raw_async(int count)
+{
+ si4700_xfer.xfer.txdata = NULL;
+ si4700_xfer.xfer.txcount = 0;
+ si4700_xfer.xfer.rxdata = si4700_xfer.regbuf;
+ si4700_xfer.xfer.rxcount = count;
+ si4700_xfer.xfer.callback = si4700_rds_read_raw_callback;
+ si4700_xfer.xfer.next = NULL;
+
+ i2c_transfer(&si4700_xfer.xfer);
+}
+
+/* RDS GPIO interrupt handler - start RDS data read */
void si4700_stc_rds_event(void)
{
/* read and clear the interrupt */
SI4700_GPIO_STC_RDS_ISR = (1ul << SI4700_GPIO_STC_RDS_LINE);
- semaphore_release(&rds_sema);
+ si4700_rds_read_raw_async();
}
/* Called with on=true after full radio power up, and with on=false before
@@ -152,26 +189,8 @@ void si4700_rds_powerup(bool on)
}
}
-/* Captures RDS data and processes it */
-/* Use of a thread here is likely temporary */
-static void NORETURN_ATTR rds_thread(void)
-{
- uint16_t rds_data[4];
-
- while (1)
- {
- semaphore_wait(&rds_sema, TIMEOUT_BLOCK);
-
- if (si4700_rds_read_raw(rds_data) && rds_process(rds_data))
- si4700_rds_set_event();
- }
-}
-
/* One-time RDS init at startup */
void si4700_rds_init(void)
{
- semaphore_init(&rds_sema, 1, 0);
rds_init();
- create_thread(rds_thread, rds_stack, sizeof(rds_stack), 0, "rds"
- IF_PRIO(, PRIORITY_REALTIME) IF_COP(, CPU));
}