summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c41
1 files changed, 23 insertions, 18 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 108a6d0944..ee91b99c0f 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
@@ -26,7 +26,7 @@
26#include "thread.h" 26#include "thread.h"
27#include "mc13783.h" 27#include "mc13783.h"
28#include "iomuxc-imx31.h" 28#include "iomuxc-imx31.h"
29#include "gpio-imx31.h" 29#include "gpio-target.h"
30#include "i2c-imx31.h" 30#include "i2c-imx31.h"
31#include "fmradio_i2c.h" 31#include "fmradio_i2c.h"
32#include "rds.h" 32#include "rds.h"
@@ -139,20 +139,25 @@ static struct si4700_i2c_transfer_desc
139 .xfer = { .node = &si4700_i2c_node } 139 .xfer = { .node = &si4700_i2c_node }
140}; 140};
141 141
142static bool int_restore;
143
142static void si4700_rds_read_raw_callback(struct i2c_transfer_desc *xfer) 144static void si4700_rds_read_raw_callback(struct i2c_transfer_desc *xfer)
143{ 145{
144 struct si4700_i2c_transfer_desc *xf = 146 struct si4700_i2c_transfer_desc *xf =
145 (struct si4700_i2c_transfer_desc *)xfer; 147 (struct si4700_i2c_transfer_desc *)xfer;
146 148
147 if (xfer->rxcount != 0) 149 if (xfer->rxcount == 0)
148 return; /* Read didn't finish */ 150 {
149 151 uint16_t rds_data[4];
150 uint16_t rds_data[4]; 152 si4700_rds_read_raw_async_complete(xf->regbuf, rds_data);
151 153
152 si4700_rds_read_raw_async_complete(xf->regbuf, rds_data); 154 if (rds_process(rds_data))
155 si4700_rds_set_event();
156 }
157 /* else read didn't finish */
153 158
154 if (rds_process(rds_data)) 159 if (int_restore)
155 si4700_rds_set_event(); 160 gpio_int_enable(SI4700_EVENT_ID);
156} 161}
157 162
158/* Callback from si4700_rds_read_raw to execute the read */ 163/* Callback from si4700_rds_read_raw to execute the read */
@@ -169,10 +174,13 @@ void si4700_read_raw_async(int count)
169} 174}
170 175
171/* RDS GPIO interrupt handler - start RDS data read */ 176/* RDS GPIO interrupt handler - start RDS data read */
172void si4700_stc_rds_event(void) 177void INT_SI4700_RDS(void)
173{ 178{
174 /* read and clear the interrupt */ 179 /* mask and clear the interrupt */
175 SI4700_GPIO_STC_RDS_ISR = (1ul << SI4700_GPIO_STC_RDS_LINE); 180 gpio_int_disable(SI4700_EVENT_ID);
181 gpio_int_clear(SI4700_EVENT_ID);
182
183 /* read the RDS data */
176 si4700_rds_read_raw_async(); 184 si4700_rds_read_raw_async();
177} 185}
178 186
@@ -180,13 +188,10 @@ void si4700_stc_rds_event(void)
180 powering down */ 188 powering down */
181void si4700_rds_powerup(bool on) 189void si4700_rds_powerup(bool on)
182{ 190{
183 gpio_disable_event(SI4700_STC_RDS_EVENT_ID); 191 int_restore = on;
184 192 gpio_int_disable(SI4700_EVENT_ID);
185 if (on) 193 gpio_int_clear(SI4700_EVENT_ID);
186 { 194 gpio_enable_event(SI4700_EVENT_ID, on);
187 SI4700_GPIO_STC_RDS_ISR = (1ul << SI4700_GPIO_STC_RDS_LINE);
188 gpio_enable_event(SI4700_STC_RDS_EVENT_ID);
189 }
190} 195}
191 196
192/* One-time RDS init at startup */ 197/* One-time RDS init at startup */