Added 3 more functions.

This commit is contained in:
Dragos Bogdan 2013-05-20 19:05:41 +03:00
parent a1bc241c06
commit 68417a0728
3 changed files with 77 additions and 7 deletions

View File

@ -282,3 +282,64 @@ void ADF7023_TransmitPacket(unsigned char* packet, unsigned char length)
&interruptReg); &interruptReg);
} }
} }
/***************************************************************************//**
* @brief Sets the channel frequency.
*
* @param chFreq - Channel frequency.
*
* @return None.
*******************************************************************************/
void ADF7023_SetChannelFrequency(unsigned long chFreq)
{
chFreq = (unsigned long)(((float)chFreq / 26000000) * 65535);
ADF7023_BBRAMCurrent.channelFreq0 = (chFreq & 0x0000FF) >> 0;
ADF7023_BBRAMCurrent.channelFreq1 = (chFreq & 0x00FF00) >> 8;
ADF7023_BBRAMCurrent.channelFreq2 = (chFreq & 0xFF0000) >> 16;
ADF7023_SetRAM(0x100, 64, (unsigned char*)&ADF7023_BBRAMCurrent);
}
/***************************************************************************//**
* @brief Sets the data rate.
*
* @param dataRate - Data rate.
*
* @return None.
*******************************************************************************/
void ADF7023_SetDataRate(unsigned long dataRate)
{
unsigned char status = 0;
dataRate = (unsigned long)(dataRate / 100);
ADF7023_BBRAMCurrent.radioCfg0 =
BBRAM_RADIO_CFG_0_DATA_RATE_7_0((dataRate & 0x00FF) >> 0);
ADF7023_BBRAMCurrent.radioCfg1 &= ~BBRAM_RADIO_CFG_1_DATA_RATE_11_8(0xF);
ADF7023_BBRAMCurrent.radioCfg1 |=
BBRAM_RADIO_CFG_1_DATA_RATE_11_8((dataRate & 0x0F00) >> 8);
ADF7023_SetRAM(0x100, 64, (unsigned char*)&ADF7023_BBRAMCurrent);
ADF7023_SetFwState(FW_STATE_PHY_OFF);
ADF7023_SetCommand(CMD_CONFIG_DEV);
}
/***************************************************************************//**
* @brief Sets the frequency deviation.
*
* @param freqDev - Frequency deviation.
*
* @return None.
*******************************************************************************/
void ADF7023_SetFrequencyDeviation(unsigned long freqDev)
{
unsigned char status = 0;
freqDev = (unsigned long)(freqDev / 100);
ADF7023_BBRAMCurrent.radioCfg1 &=
~BBRAM_RADIO_CFG_1_FREQ_DEVIATION_11_8(0xF);
ADF7023_BBRAMCurrent.radioCfg1 |=
BBRAM_RADIO_CFG_1_FREQ_DEVIATION_11_8((freqDev & 0x0F00) >> 8);
ADF7023_BBRAMCurrent.radioCfg2 =
BBRAM_RADIO_CFG_2_FREQ_DEVIATION_7_0((freqDev & 0x00FF) >> 0);
ADF7023_SetRAM(0x100, 64, (unsigned char*)&ADF7023_BBRAMCurrent);
ADF7023_SetFwState(FW_STATE_PHY_OFF);
ADF7023_SetCommand(CMD_CONFIG_DEV);
}

View File

@ -398,4 +398,13 @@ void ADF7023_ReceivePacket(unsigned char* packet, unsigned char* length);
/* Transmits one packet. */ /* Transmits one packet. */
void ADF7023_TransmitPacket(unsigned char* packet, unsigned char length); void ADF7023_TransmitPacket(unsigned char* packet, unsigned char length);
/* Sets the channel frequency. */
void ADF7023_SetChannelFrequency(unsigned long chFreq);
/* Sets the data rate. */
void ADF7023_SetDataRate(unsigned long dataRate);
/* Sets the frequency deviation. */
void ADF7023_SetFrequencyDeviation(unsigned long freqDev);
#endif // __ADF7023_H__ #endif // __ADF7023_H__

View File

@ -72,18 +72,18 @@ struct ADF7023_BBRAM ADF7023_BBRAMDefault =
/* swmRssiThresh - 0x108 */ /* swmRssiThresh - 0x108 */
0x31, 0x31,
/* channelFreq0 - 0x109 */ /* channelFreq0 - 0x109 */
0x3B, 0x51, // Channel Frequency: 433 MHz
/* channelFreq1 - 0x10A */ /* channelFreq1 - 0x10A */
0x31, 0xA7, // Channel Frequency: 433 MHz
/* channelFreq2 - 0x10B */ /* channelFreq2 - 0x10B */
0x23, 0x10, // Channel Frequency: 433 MHz
/* radioCfg0 - 0x10C */ /* radioCfg0 - 0x10C */
BBRAM_RADIO_CFG_0_DATA_RATE_7_0(0xF4), BBRAM_RADIO_CFG_0_DATA_RATE_7_0(0xE8), // Data rate: 100 kbps
/* radioCfg1 - 0x10D */ /* radioCfg1 - 0x10D */
BBRAM_RADIO_CFG_1_FREQ_DEVIATION_11_8(1) | BBRAM_RADIO_CFG_1_FREQ_DEVIATION_11_8(0x00) | // Frequency deviation: 25 Hz
BBRAM_RADIO_CFG_1_DATA_RATE_11_8(1), BBRAM_RADIO_CFG_1_DATA_RATE_11_8(0x03), // Data rate: 100 kbps
/* radioCfg2 - 0x10E */ /* radioCfg2 - 0x10E */
BBRAM_RADIO_CFG_2_FREQ_DEVIATION_7_0(0xF4), BBRAM_RADIO_CFG_2_FREQ_DEVIATION_7_0(0xFA), // Frequency deviation: 25 Hz
/* radioCfg3 - 0x10F */ /* radioCfg3 - 0x10F */
0x31, 0x31,
/* radioCfg4 - 0x110 */ /* radioCfg4 - 0x110 */