51 ; ; ;Source ;code ;For ;FSK 收发模块 ;Register
void setup_tx (void)
{
set_tx_config ();
set_tx_freq (0);
set_tx_pwr ();
tx_pwr_mng_start_osc ();
cChipStatus = 0x00;
low_batt_cntl();
wakeup_time_cntl();
}
void set_tx_config ()
{
send_spi_cntl(0x9F71); // CLK 10M, CAP 12PF; Deviation 60K/90 //915 Century frequece //
}
void set_tx_freq (unsigned char i)
{
int cntl;
cntl = FreqGroup[i];
send_spi_cntl (cntl);
}
void set_tx_pwr (void)
{
unsigned char c0;
c0 = tx_buf[0];
tx_buf[0] = 0xB0;
spi_master (1);
tx_buf[0] = c0;
}
void tx_pwr_mng (unsigned char mode)
{
switch (mode) {
case NORMAL:
#ifdef Manule_Power_Mangaer
Globe_Pwr_mng_cntl = 0xC03E; // normal mode = ea + es + ex + ET + EB
#else
Globe_Pwr_mng_cntl =0xc0c6; // Auto Power Amplify Clear ET, In order for Wakeuptime continue to work.
#endif
break;
case STANDBY:
#ifdef Manule_Power_Mangaer
Globe_Pwr_mng_cntl = 0xC036; // standby mode = es + ex + ET + EB // disable power amplifier
#else
Globe_Pwr_mng_cntl=0xc0c6; // Auto Power Amplify Clear ET, In order for Wakeuptime continue to work.
#endif
break;
}
send_spi_cntl(Globe_Pwr_mng_cntl);
}
void tx_pwr_mng_start_osc (void)
{
// enable oscillator & sythesizer: es + ex +ET +EB
wait (1); // wait 1ms
#ifdef Manule_Power_Mangaer
send_spi_cntl(0xc034); //Clear ET, In order for Wakeuptime continue to work. (Maybe Mcu is rest , IA4220 still work).
send_spi_cntl(0xc036); //Enable ET,
#else
send_spi_cntl(0xc0c4); // Auto Power Amplify Clear ET, In order for Wakeuptime continue to work.
send_spi_cntl(0xc0c6); //
#endif
}
void low_batt_cntl (void)
{
send_spi_cntl(0xC207); //2.9V
}
void wakeup_time_cntl ()
{
send_spi_cntl(0xE232); // 50ms=500ms
}
void wait (unsigned char millisec)
{
int cnt;
while (millisec--)
for (cnt = 0; cnt < TC_1MS; cnt++)
;
}
void send_spi_cntl (int cntl)
{
unsigned char c0 = tx_buf[0];
unsigned char c1 = tx_buf[1];
tx_buf[0] = (unsigned char) (cntl > > 8);
tx_buf[1] = (unsigned char) (cntl & 0xFF);
spi_master (2);
tx_buf[0] = c0;
tx_buf[1] = c1;
}
void status_read (void)
{
send_spi_cntl(TX_STATUS_RD);
cChipStatus = rx_buf[1];
}
发表时间:2005年5月28日17:08:36