📄 wbrxtest.c
字号:
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <stddef.h>
#include "typedefs.h"
#include "c8051F320.h"
#include "portdef.h"
#include "si47xxWBRX.h"
#include "WBRXtest.h"
#include "propertydefs.h"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Function prototypes
//-----------------------------------------------------------------------------
void wait_ms(u16 ms);
void _nop_(void);
//-----------------------------------------------------------------------------
// Externals
//-----------------------------------------------------------------------------
extern u16 xdata seek_preset[];
//-----------------------------------------------------------------------------
// This exercises the minimum number of function calls to initiate a tune when
// the Si47xx device is first initialized.
//-----------------------------------------------------------------------------
void test_WBRXtune(void)
{
si47xxWBRX_initialize();
si47xxWBRX_set_volume(63); // full volume, turn off mute
si47xxWBRX_tune(64960); // tune to Station 1 (162.4MHz = 64960)
wait_ms(DEMO_DELAY);
}
//-----------------------------------------------------------------------------
// Test the volume. Starts at mute, moves up through all 63 steps.
//-----------------------------------------------------------------------------
void test_WBRXvolume(void)
{
u8 vol;
for (vol=0; vol<63; vol++) {
si47xxWBRX_set_volume(vol);
wait_ms(500);
}
}
//-----------------------------------------------------------------------------
// Test the power down function of the part. Unlike the Si470x parts the Si47xx
// parts need to be fully initialized after power down.
//-----------------------------------------------------------------------------
void test_WBRXpowerCycle(void)
{
si47xxWBRX_powerdown(); // Test powerdown with audio hi-z
wait_ms(DEMO_DELAY); // Wait 5s before starting next test
si47xxWBRX_powerup(); // Powerup without reset, the part will need to be tuned again.
si47xxWBRX_configure();
si47xxWBRX_set_volume(63); // full volume, turn off mute
si47xxWBRX_tune(64960);
wait_ms(DEMO_DELAY); // Wait 5s before starting next test
}
//-----------------------------------------------------------------------------
// This routine scans all seven weather band frequencies and tunes to channel// with the highest RSSI.//-----------------------------------------------------------------------------void test_WBRX_scan(void) { u16 i;
u16 best_frequency;
u8 best_rssi = 0;
// Mute the audio
si47xxWBRX_mute(1);
for(i=64960;i<=65020;i+=10)
{
si47xxWBRX_tune(i);
if( si47xxWBRX_get_rssi() > best_rssi)
{
best_rssi = si47xxWBRX_get_rssi();
best_frequency = si47xxWBRX_get_frequency();
}
}
// Tune to station with highest RSSI.
si47xxWBRX_tune(best_frequency);
// Get the 1050kHz alert tone status
si47xxWBRX_get_alert();
// Unmute
si47xxWBRX_mute(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -