Exemplo n.º 1
0
static void si4700_set_frequency(int freq)
{
    static const unsigned int spacings[3] =
    {
          200000, /* SYSCONFIG2_SPACE_200KHZ */
          100000, /* SYSCONFIG2_SPACE_100KHZ */
           50000, /* SYSCONFIG2_SPACE_50KHZ  */
    };
    static const unsigned int bands[3] =
    {
        87500000, /* SYSCONFIG2_BAND_875_1080 */
        76000000, /* SYSCONFIG2_BAND_760_1080 */
        76000000, /* SYSCONFIG2_BAND_760_900  */
    };

    /* check BAND and spacings */
    int space = SYSCONFIG2_SPACEr(cache[SYSCONFIG2]);
    int band = SYSCONFIG2_BANDr(cache[SYSCONFIG2]);
    int chan = (freq - bands[band]) / spacings[space];
    int readchan;

    do
    {
        /* tuning should be done within 60 ms according to the datasheet */
        si4700_write_reg(CHANNEL, CHANNEL_CHANw(chan) | CHANNEL_TUNE);
        sleep(HZ * 60 / 1000);

        /* get tune result */
        readchan = si4700_read_reg(READCHAN) & READCHAN_READCHAN;

        si4700_write_clear(CHANNEL, CHANNEL_TUNE);
    } while (!((cache[STATUSRSSI] & STATUSRSSI_STC) && (readchan == chan)));
}
Exemplo n.º 2
0
static void rda5802_set_frequency(int freq)
{
    int i;
    uint16_t readchan;

    /* check BAND and spacings */
    int start = CHANNEL_BANDr(cache[CHANNEL]) & 1 ? 76000000 : 87000000;
    int chan = (freq - start) / 50000;

    for (i = 0; i < 5; i++) {
        /* tune and wait a bit */
        rda5802_write_masked(CHANNEL, CHANNEL_CHANw(chan) | CHANNEL_TUNE,
                                CHANNEL_CHAN | CHANNEL_TUNE);
        rda5802_write_cache();
        sleep(HZ * 70 / 1000);
        rda5802_write_clear(CHANNEL, CHANNEL_TUNE);
        rda5802_write_cache();
        
        /* check if tuning was successful */
        readchan = rda5802_read_reg(READCHAN);
        if (readchan & READCHAN_STC) {
            if (READCHAN_READCHANr(readchan) == chan) {
                break;
            }
        }
    }
}
Exemplo n.º 3
0
static void rda5802_set_frequency(int freq)
{
    int i;
    uint16_t readchan;
    static const int spacings[] = {100000, 200000, 50000, 50000};
    static const int bandstart[] = {87000000, 76000000, 76000000, 65000000};

    /* calculate channel number */
    int start = bandstart[CHANNEL_BANDr(cache[CHANNEL])];
    int space = spacings[CHANNEL_SPACEr(cache[CHANNEL])];
    int chan = (freq - start) / space;

    for (i = 0; i < 5; i++) {
        /* tune and wait a bit */
        rda5802_write_masked(CHANNEL, CHANNEL_CHANw(chan) | CHANNEL_TUNE,
                                CHANNEL_CHAN | CHANNEL_TUNE);
        rda5802_write_cache();
        sleep(HZ * 70 / 1000);
        rda5802_write_clear(CHANNEL, CHANNEL_TUNE);
        rda5802_write_cache();
        
        /* check if tuning was successful */
        readchan = rda5802_read_reg(READCHAN);
        if (readchan & READCHAN_STC) {
            if (READCHAN_READCHANr(readchan) == chan) {
                break;
            }
        }
    }
}