📄 iai_ebid.c
字号:
/*
** ============================================================================
**
** FILE
** IAI_EBID.c
**
** DESCRIPTION
** Testcard Board Identification EEPROM handling
**
** CREATED
** Silicon Laboratories Hungary Ltd
**
** COPYRIGHT
** Copyright 2008 Silicon Laboratories, Inc.
** http://www.silabs.com
**
** ============================================================================
*/
/*------------------------------------------------------------------------*/
/* INCLUDE */
/*------------------------------------------------------------------------*/
#include "IAI_EBID.h"
#include <string.h>
#include "IA443x_rf.h"
/*------------------------------------------------------------------------*/
/* GLOBAL variables */
/*------------------------------------------------------------------------*/
xdata EBID_DATA TestcardData;
xdata SPECIAL_REGISTERS SpecialRegisters;
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: EBID_DATABASES GetEBIDDataFromEEPROM(void)
+
+ DESCRIPTION: It read the data from the EEPROM and set the variables accordingly
+
+ RETURN: the EEPROM database
+
+ NOTES:
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
EBID_DATABASES GetEBIDDataFromEEPROM(void)
{
xdata uint8 temp8, i, string[9];
xdata uint16 temp16;
TestcardData.valid_info = FALSE;
//figure out what database (s) are available
temp8 = SpiReadByteFromTestcardEEPROM( 0x0000 );
if( (temp8 & POWER_DB) == POWER_DB )
{//the Power Description Database is implemented, use this
return POWER_DB;
}
if( (temp8 & WIRELINE_DB) == WIRELINE_DB )
{//the Wireline Description Database is implemented, use this
return WIRELINE_DB;
}
if( (temp8 & WIRELESS_DB) == WIRELESS_DB )
{//the Wireless Description Database is implemented, use this
TestcardData.valid_info = TRUE;
//find out the chip type
TestcardData.chip_type = NOT_AVAILABLE;
SpiReadSegmentFromTestcardEEPROM(0x0010, string, 8);
if( memcmp(&string[2], "4020", 4) == 0 ) TestcardData.chip_type = SI4020;
if( memcmp(&string[2], "4021", 4) == 0 ) TestcardData.chip_type = SI4021;
if( memcmp(&string[2], "4022", 4) == 0 ) TestcardData.chip_type = SI4022;
if( memcmp(&string[2], "4030", 4) == 0 ) TestcardData.chip_type = SI4030;
if( memcmp(&string[2], "4031", 4) == 0 ) TestcardData.chip_type = SI4031;
if( memcmp(&string[2], "4032", 4) == 0 ) TestcardData.chip_type = SI4032;
if( memcmp(&string[2], "4315", 4) == 0 ) TestcardData.chip_type = SI4315;
if( memcmp(&string[2], "4320", 4) == 0 ) TestcardData.chip_type = SI4320;
if( memcmp(&string[2], "4322", 4) == 0 ) TestcardData.chip_type = SI4322;
if( memcmp(&string[2], "4330", 4) == 0 ) TestcardData.chip_type = SI4330;
if( memcmp(&string[2], "4322", 4) == 0 ) TestcardData.chip_type = SI4322;
if( memcmp(&string[2], "4420", 4) == 0 ) TestcardData.chip_type = SI4420;
if( memcmp(&string[2], "4421", 4) == 0 ) TestcardData.chip_type = SI4421;
if( memcmp(&string[2], "4430", 4) == 0 ) TestcardData.chip_type = SI4430;
if( memcmp(&string[2], "4431", 4) == 0 ) TestcardData.chip_type = SI4431;
if( memcmp(&string[2], "4432", 4) == 0 ) TestcardData.chip_type = SI4432;
if( memcmp(&string[2], "4520", 4) == 0 ) TestcardData.chip_type = SI4520;
//get chip revision
SpiReadSegmentFromTestcardEEPROM(0x0018, &TestcardData.chip_revision[0], 2);
//get serial number
temp8 = SpiReadByteFromTestcardEEPROM( 0x0034 );
TestcardData.serial_nmbr = ((uint16)temp8 << 8) + SpiReadByteFromTestcardEEPROM( 0x0035 );
//get supported frequency bands
temp8 = SpiReadByteFromTestcardEEPROM( 0x0043 );
TestcardData.freq_band = ((uint16)temp8 << 8) + SpiReadByteFromTestcardEEPROM( 0x0044 );
//get antenna connection type
TestcardData.ant_type = SpiReadByteFromTestcardEEPROM( 0x0045 );
//get special registers
temp8 = SpiReadByteFromTestcardEEPROM( 0x004F);
SpecialRegisters.nmbr_of_registers = temp8;
if( temp8 > 0 )
{
for(i=0;i<temp8;i++)
{
temp16 = ((uint16)SpiReadByteFromTestcardEEPROM(0x0050 + (i << 1) )) << 8;
temp16 += (uint16)SpiReadByteFromTestcardEEPROM(0x0050 + ((i << 1)+1));
SpecialRegisters.registers[i] = temp16;
}
}
return WIRELESS_DB;
}
//check whether demo specific database is implemented or not
switch( temp8 & 0x0F )
{
case EZRADIO_PRO:
TestcardData.valid_info = TRUE;
TestcardData.chip_type = SI4432;
TestcardData.chip_revision[0] = 'X';
TestcardData.chip_revision[1] = '2';
TestcardData.serial_nmbr = (uint16)SpiReadByteFromTestcardEEPROM( 0x0001 );
TestcardData.freq_band = 0x0300; //868-960MHz
TestcardData.ant_type = SEPARATE_SMA;
//set special registers
SpecialRegisters.nmbr_of_registers = 2;
SpecialRegisters.registers[0] = ((uint16)(VCOCurrentTrimming | 0x80) << 8) + (uint16)SpiReadByteFromTestcardEEPROM( 0x0002 );
SpecialRegisters.registers[1] = ((uint16)( CrystalOscillatorLoadCapacitance | 0x80) << 8) + (uint16)SpiReadByteFromTestcardEEPROM( 0x0003 );
break;
case EZRADIO_PRO_OFFSET:
TestcardData.valid_info = TRUE;
TestcardData.chip_type = SI4432;
TestcardData.chip_revision[0] = 'X';
TestcardData.chip_revision[1] = '2';
TestcardData.serial_nmbr = (uint16)SpiReadByteFromTestcardEEPROM( 0x0001 );
//figure out the frequency band
temp8 = SpiReadByteFromTestcardEEPROM( 0x0004 );
switch( temp8 )
{
case 0xFE:
TestcardData.freq_band = 0x0010; //434MHz
break;
case 0xFF:
default:
TestcardData.freq_band = 0x0300; //868-960MHz
break;
}
//figure out the antenna connection type
temp8 = SpiReadByteFromTestcardEEPROM( 0x0005 );
switch( temp8 )
{
case 0xFD:
TestcardData.ant_type = ANT_DIVERSITY;
break;
case 0xFE:
TestcardData.ant_type = SMA_TRX_SWITCH;
break;
case 0xFF:
default:
TestcardData.ant_type = SEPARATE_SMA;
break;
}
//set special registers
SpecialRegisters.nmbr_of_registers = 4;
SpecialRegisters.registers[0] = ((uint16)(VCOCurrentTrimming | 0x80) << 8) + (uint16)SpiReadByteFromTestcardEEPROM( 0x0002 );
SpecialRegisters.registers[1] = ((uint16)(CrystalOscillatorLoadCapacitance | 0x80) << 8) + (uint16)SpiReadByteFromTestcardEEPROM( 0x0003 );
SpecialRegisters.registers[2] = ((uint16)(0x80 | FrequencyOffset) << 8) + 0x00E3;
SpecialRegisters.registers[3] = ((uint16)(0x80 | FrequencyChannelControl) << 8) + 0x0003;
break;
default:
//no special database is available
return NO_EEPROM;
break;
}
return NO_EEPROM;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ FUNCTION NAME: void SetSpecialRegisters(void)
+
+ DESCRIPTION: set all the special (not default) registers of the chip
+
+ RETURN: None
+
+ INPUT: None
+
+ NOTES:
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void SetSpecialRegisters(void)
{
xdata uint8 i;
xdata UU16 temp;
for(i=0;i<SpecialRegisters.nmbr_of_registers;i++)
{
temp.U16 = SpecialRegisters.registers[i];
SpiRfWriteWord( temp );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -