On 5-11-2011 12:53, Michael Sevakis wrote: > ----- Original Message ----- From: "Bertrik Sikken" <bert...@sikken.nl> >> The Si4703 can be configured to capture one RDS packet, then >> raise an pin voltage for 5 ms. My plan is to attach an interrupt >> to this event that wakes up a high-prio thread to read the RDS >> packet. It then feeds the raw RDS packet into a generic RDS processor >> that collects packets until a full RDS message has been assembled. > > I doubt all that is necessary especially with a tuner GPIO interrupt > available in at least some cases and possibly the introduction of an > async I2C driver (not too hard really). I'd suggest not imposing a > particular interface on all hardware but have the hardware implement > those details as a middle layer.
I don't know how to do an async i2c driver. IMO, the simplest is to do not too much in the interrupt itself. Hence the interrupt in my proposal just wakes up a thread that does the actual work. On the AMS targets, i2c to the fm tuner is done by "bit-banging" (GPIO toggling) using udelays to do the timing. Can you do async with that? >> I'm thinking of the following interface: >> - int rds_process(uint16_t data[4]) > > What's that now? RDS is always 4 16-bit words? Yes, basically. In RDS lingo, data is packetized in a 104-bit group, which consist of 4 blocks of 26 bits each. Each block consists of 16 bit actual data and 10 bits sync/error correction bits. So effectively the payload of one packet/group is 4 words of 16 bits each. See also the IEC 62106 document. >> which returns a number indicating what kind of data has been >> received. When something is received, the fm tuner driver can call >> a function to get a copy of the RDS data, something like: >> - bool rds_get_stationname(char *buf, int bufsize) >> - bool rds_get_radiotext(char *buf, int bufsize) > > Could probably just fill-out a structure provided by the caller with a > flag member indicating which are valid (few single-use calls). > >> When the FM frequency is changed, the RDS data is invalidated with >> - void rds_reset(void) > > Why not just reread it? The UI can clear its fields. The tuner can > indicate a frequency change internally and clear its own data. The idea is that the fm tuner driver knows when a channel is switched, tuner is powered off or on, etc. You can't just re-read it, because we want fresh data from the current station. Regards, Bertrik