📄 test.c
字号:
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <stddef.h>
#include "typedefs.h"
#include "example.h"
#include "c8051F320.h"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Function prototypes
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Externals
//-----------------------------------------------------------------------------
extern u16 seek_preset[];
extern u16 xdata RdsDataAvailable;
//-----------------------------------------------------------------------------
// Simple routine that tests the si470x driver functions.
//
// This particular test just:
// - Resets Si470x
// - Sets default values and takes the Si470x out of powerdown mode
// - Waits for agc to settle
// - Fills the preset array with the strongest stations found
// - Loops through each preset pausing on each one
//
//-----------------------------------------------------------------------------
void test_autoseek(void)
{
u16 preset_freq;
u8 preset_number;
si470x_reset();
si470x_initialize();
si470x_set_volume (0xf, 1); // full volume, turn off mute
wait_ms(2500); // let agc settle after powerup before performing autoseek
// only required for rev10 and earlier
si470x_autoseek(); // populate the preset array with strongest stations
_nop_(); // break here to inspect preset array
preset_number = 0;
while (1) {
// tune to the next station in the preset array
preset_freq = seek_preset[preset_number];
if (preset_freq != 0) {
si470x_tune (preset_freq);
wait_ms(5000);
}
// put the device in powerdown mode, wait, then powerup again
si470x_powerdown();
wait_ms(2000);
si470x_powerup();
preset_number ++;
if (preset_number == NUM_SEEK_PRESETS )
preset_number = 0;
}
}
//-----------------------------------------------------------------------------
//
//
//
//
//-----------------------------------------------------------------------------
void test_rds(void)
{
si470x_reset();
si470x_initialize();
si470x_set_volume (0xf, 1); // full volume, turn off mute
si470x_tune(10230); // tune to a station
initRds(); // Initialize RDS
while (1)
{
wait_gpio2(0);
updateRds();
wait_gpio2(1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -