📄 config.c
字号:
REG_DIV0 = 0xFF; /* divider */
if (G_Eeprom[CONFIG_P_CLK] == P_CLK_4MHZ)
{
REG_DIV1 = 0x01; /* divider for 4 MHz */
}
else
{
REG_DIV1 = 0x00; /* divider for 2 MHz */
}
break;
case REF_CLK_4MHZ_2MHZEXT:
/* supply 2 MHz at REFCLK also at 4 MHz */
/* data rate */
if (G_Eeprom[CONFIG_P_CLK] == P_CLK_4MHZ)
{
REG_DIV0 = 0x01;
}
else
{
REG_DIV0 = 0x00;
}
REG_DIV1 = 0x00; /* divider for REF_CLK = PCLK */
break;
case REF_CLK_CIF_4MHZEXT:
/* board does not supply 2 MHz at PCLK with 4 MHz REFCLK*/
/* data rate */
REG_DIV0 = 0x00;
REG_DIV1 = 0x00; /* divider PCLK = 2 MHz */
break;
default:
// not valid
setting = FALSE;
break;
}
break;
case MODE_COT_INT:
case MODE_RT_LOOP:
/* loop / internal timed */
/* PCM interface is configured as slave */
REG_OE0 = 0x03; /* PCLK, TFSC out, RCLK, RFSC in */
REG_OE1 = 0x3F; /*0x0400 */
REG_MUX_SOC = 0x20; /* */
REG_MUX_CLK = 0x11; /* RFSC,RCLK */
break;
default:
setting = FALSE;
break;
}
break;
default:
setting = FALSE;
break;
}
/* enable emulator */
if ((G_Emulation_Mode == EMUL_MODE) && (setting != FALSE))
{
REG_OE0 |= 0x20;
}
return (setting);
}
/*******************************************************************************
Description:
Receive message to write new configuration settings.
Arguments:
pMsg - Pointer to received message.
Return:
NONE.
Remarks:
After the reset of the mainboard (Reset_Mainboard) and checking of the
transmitted configuration (Config_Check) the EEPROM will be written
(Write_Eeprom) and configuration is done by calling function Initialize_Devices.
If the new configuration is not valid the old configuration (Read_Eeprom)
will be restored.
******************************************************************************/
static void Soc_Config_Write (P_DDS_MSG pMsg)
{
WORD8 error = 0;
/* Read parameters of received
message. */
G_V24 = MsgReadWord8 (pMsg, 0);
//G_Eeprom[CONFIG_AUTO] = MsgReadWord8 (pMsg, 1);
G_Emulation_Mode = MsgReadWord8 (pMsg, 1);
G_Eeprom[CONFIG_INTF] = MsgReadWord8 (pMsg, 2);
G_Eeprom[CONFIG_MODE] = MsgReadWord8 (pMsg, 3);
G_Eeprom[CONFIG_P_CLK] = MsgReadWord8 (pMsg, 4);
G_Eeprom[CONFIG_REF_CLK] = MsgReadWord8 (pMsg, 5);
G_Eeprom[CONFIG_UC_MODE] = MsgReadWord8 (pMsg, 6);
G_Eeprom[CONFIG_FRAME] = MsgReadWord8 (pMsg, 7);
G_Eeprom[CONFIG_SYNC1] = MsgReadWord8 (pMsg, 8);
G_Eeprom[CONFIG_SYNC2] = MsgReadWord8 (pMsg, 9);
if ( ( ((G_Eeprom[CONFIG_UC_MODE] & 0xF0) == 0x00) || ((G_Eeprom[CONFIG_UC_MODE] & 0xF0) == 0xF0) )
&& (G_Emulation_Mode != EMUL_MODE) )
{
/* Initial proceedings. */
Reset_Mainboard ();
}
/* Check the configuration */
V24_PRINT(("\n(SLOT %d) Soc_Config_Write: ", SLOT_NR));
error = Config_Check();
/* Start processing if all
parameters are correct. */
if (error == 0)
{
/* Update configuration array &
store current configuration
in description eeprom. */
Write_Eeprom (FIRST_CONFIG_INDEX, LAST_CONFIG_INDEX);
if (G_Emulation_Mode == EMUL_MODE)
REG_CTRL = 0x40; /* enable LEDs */
Initialize_Devices();
}
else
{
/* Reload current configuration
from description EPROM. */
Read_Eeprom (FIRST_CONFIG_INDEX, LAST_CONFIG_INDEX);
}
/* Free received message
because no message is
returned to the user. */
DdsMsgFree (pMsg);
}
/*******************************************************************************
Description:
Receive message to show the current configuration settings.
Arguments:
pMsg - Pointer to received message.
Return:
NONE.
Remarks:
The configuration will be read from the EEPROM. After validating the
values of the configuration (Config_Check) will be stored in the destination
message and sent back.
******************************************************************************/
static void Soc_Config_Req (P_DDS_MSG pMsg)
{
/* Read parameters of received
message. */
G_V24 = MsgReadWord8 (pMsg, 0);
/* Read current configuration
from description EPROM. */
Read_Eeprom (FIRST_CONFIG_INDEX, LAST_CONFIG_INDEX);
/* V24 control message:
When processing. */
V24_PRINT(("\nSoc_Config_Req: "));
Config_Check();
/* Send description EPROM
content to user. */
//MsgWriteWord8 (pMsg, 0, G_Eeprom[CONFIG_AUTO]);
MsgWriteWord8 (pMsg, 0, 0x00);
MsgWriteWord8 (pMsg, 1, G_Eeprom[CONFIG_INTF]);
MsgWriteWord8 (pMsg, 2, G_Eeprom[CONFIG_MODE]);
MsgWriteWord8 (pMsg, 3, G_Eeprom[CONFIG_P_CLK]);
MsgWriteWord8 (pMsg, 4, G_Eeprom[CONFIG_REF_CLK]);
MsgWriteWord8 (pMsg, 5, G_Eeprom[CONFIG_UC_MODE]);
MsgWriteWord8 (pMsg, 6, G_Eeprom[CONFIG_FRAME]);
MsgWriteWord8 (pMsg, 7, G_Eeprom[CONFIG_SYNC1]);
MsgWriteWord8 (pMsg, 8, G_Eeprom[CONFIG_SYNC2]);
pMsg->dst = MOD_ID_USER_MODULE;
pMsg->src = MOD_ID_CONFIG_MODULE;
pMsg->id = MSG_ID_SOCRATES_CONFIG_RECEIVED;
pMsg->length = LAST_CONFIG_INDEX-FIRST_CONFIG_INDEX;
DdsMsgSend (pMsg);
}
/*******************************************************************************
Description:
Receive message to reset extension board and mainboard (Reset_Mainboard),
reinitialize all devices by calling function Initialize_Devices.
Arguments:
pMsg - Pointer to received message.
Return:
NONE.
Remarks:
NONE.
******************************************************************************/
static void Soc_Config_Reset (P_DDS_MSG pMsg)
{
WORD8 main_board_reset;
const WORD8 *error_text = NULL;
/* Read parameters of received
message. */
G_V24 = MsgReadWord8 (pMsg,0);
main_board_reset = MsgReadWord8 (pMsg,1);
/* V24 control message:
When entering. */
V24_PRINT (("\nSoc_Config_Reset: 0x%02X", main_board_reset));
/* Set error text dependent on
the received parameters. */
if (main_board_reset > 0x02)
error_text = "DEVRES";
/* Start processing if all
parameters are correct. */
if (error_text == NULL)
{
if (main_board_reset == 0x01)
{
Reset_Mainboard ();
Initialize_Devices();
} /* this option is not documented and only
allowed after firmware download by EDL
because AmdExit is called before */
else if (main_board_reset == 0x02)
{
Enable_Interrupt (INT_TIMER);
Reset_Mainboard ();
Initialize_Devices();
}
}
/* V24 control message:
When error. */
if (error_text != NULL)
{
V24_PRINT (("\nSoc_Config_Reset: %s ", Error_Text_Start));
V24_PRINT (("%s ", error_text));
V24_PRINT (("%s", Error_Text_End));
}
/* Free received message
because no message is
returned to the user. */
DdsMsgFree (pMsg);
}
/*******************************************************************************
Description:
Proceed mainboard reset and disable reset line.
Arguments:
NONE.
Return:
NONE.
Remarks:
NONE.
******************************************************************************/
static void Reset_Mainboard (void)
{
WORD8 lpr;
WORD8 mr;
WORD16 i;
/* Read mainboard LPR and MR
register. */
lpr = SMART_2000_LPR;
mr = SMART_2000_MR;
/* Adapt register values. */
mr &= MB_RESET;
SMART_2000_MR = mr;
for(i = 0;i < RESET_TIME; i++);
mr |= MB_RES_Q;
SMART_2000_MR = mr;
}
/*******************************************************************************
Description:
Receive message for binary file information request.
Arguments:
pMsg - Pointer to received message.
Return:
NONE.
Remarks:
Request information about the binary file which is stored in
the flash memory on board (DdsGetBinInfo). Additionally it enables
the user to load a specified file into flash (Flash_Download).
******************************************************************************/
static void Soc_Binary_Info (P_DDS_MSG pMsg)
{
WORD8 i;
BIN_INFO bin_file;
WORD8 action;
const WORD8 *error_text = NULL;
/* Read parameters of received
message. */
G_V24 = MsgReadWord8 (pMsg, 0);
action = MsgReadWord8 (pMsg, 1);
/* V24 control message:
When entering. */
V24_PRINT (("\nSoc_Binary_Info: 0x%02X", action));
#ifdef DEBUG
/* Set error text dependent on
the received parameters. */
if (action > 0x03)
error_text = "ACTION";
#else
/* Set error text dependent on
the received parameters. */
if (action > 0x02)
error_text = "ACTION";
#endif
/* Start processing if all
parameters are correct. */
if (error_text == NULL)
{
if (DdsGetBinInfo (&bin_file) != FALSE)
{
switch (action)
{
/* Send stored file name to user. */
case 0x00:
MsgWriteWord32 (pMsg, 0, bin_file.binLength);
for (i = 0;i < 9; i++)
MsgWriteWord8 (pMsg, i+4, bin_file.binName[i]);
pMsg->dst = MOD_ID_USER_MODULE;
pMsg->src = MOD_ID_CONFIG_MODULE;
pMsg->id = MSG_ID_SOCRATES_BINARY_INFO;
pMsg->length = 13;
DdsMsgSend (pMsg);
break;
/* Load SOCRATES code to flash. */
case 0x01:
Flash_Download(bin_file.pBinStart, bin_file.binLength);
DdsMsgFree (pMsg);
break;
/* Load G.Hs & SOCRATES code to RAM. */
case 0x02:
Soc_Load (0x8000, bin_file.pBinStart, bin_file.binLength);
DdsMsgFree (pMsg);
break;
case 0x03:
DdsMsgFree (pMsg);
V24_PRINT (("\n(SLOT %d) Number of free messages: %d", SLOT_NR, DdsMsgGetNum () ));
break;
default:
DdsMsgFree (pMsg);
break;
}
}
else
{
error_text = "NO_BIN";
}
}
/* V24 control message:
When error. */
if (error_text != NULL)
{
V24_PRINT (("\nSoc_Binary_Info: %s ", Error_Text_Start));
V24_PRINT (("%s ", error_text));
V24_PRINT (("%s", Error_Text_End));
}
}
/*******************************************************************************
Description:
Message entry function of this module.
Arguments:
pMsg - Pointer to received message.
Return:
NONE.
Remarks:
Assigns all module functions to the according function identifier.
******************************************************************************/
static void Config_Msg_Entry (P_DDS_MSG pMsg)
{
switch (pMsg->id)
{
case MSG_ID_SOCRATES_CONFIG_WRITE:
Soc_Config_Write (pMsg);
break;
case MSG_ID_SOCRATES_CONFIG_REQ:
Soc_Config_Req (pMsg);
break;
case MSG_ID_SOCRATES_CONFIG_RESET:
Soc_Config_Reset (pMsg);
break;
case MSG_ID_SOCRATES_BINARY_INFO:
Soc_Binary_Info (pMsg);
break;
default:
printf ("\n(SLOT %d) Module CONFIG.C\t: unknown msg id (0x%02X).", SLOT_NR, pMsg->id);
DdsMsgFree (pMsg);
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -