|
|
@@ -342,64 +342,66 @@ int equ_init_file_config(void)
|
|
|
*/
|
|
|
int equ_led_init(void)
|
|
|
{
|
|
|
- int i,j;
|
|
|
+ int i, j, slot, index;
|
|
|
|
|
|
- // 默认没有配置任何灯
|
|
|
- for(i=0;i<EQU_SLOT_NUM_MAX;i++)
|
|
|
- {
|
|
|
- g_led_slot[i].num = 0;
|
|
|
- for(j=0;j<LED_MAX_NUM;j++)
|
|
|
- {
|
|
|
- g_led_slot[i].sn[j].no = LED_NULL;
|
|
|
- }
|
|
|
- }
|
|
|
+ // 默认没有配置任何灯
|
|
|
+ for (i = 0; i < EQU_SLOT_NUM_MAX; i++)
|
|
|
+ {
|
|
|
+ g_led_slot[i].num = 0;
|
|
|
+ for (j = 0; j < LED_MAX_NUM; j++)
|
|
|
+ {
|
|
|
+ g_led_slot[i].sn[j].no = LED_NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
#if 0
|
|
|
- // 初始化公共灯
|
|
|
- for(i=0; i< PUB_LED_NUM; i++)
|
|
|
- {
|
|
|
- index = g_sw_pub.led_cfg_index[i];
|
|
|
- if ((index != INDEX_INVALLID))
|
|
|
- {
|
|
|
- slot = g_equ_config_do[index].slot;
|
|
|
- index = g_equ_config_do[index].index;
|
|
|
-
|
|
|
- g_led_slot[slot].sn[index].sw = 0;
|
|
|
- g_led_slot[slot].sn[index].no = i;
|
|
|
-
|
|
|
- index++;
|
|
|
- if(index > g_led_slot[slot].num)
|
|
|
- {
|
|
|
- g_led_slot[slot].num = index;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 初始化开关灯
|
|
|
- for(sw=0; sw<SWITCH_NUM_MAX; sw++)
|
|
|
- {
|
|
|
- for(i=0; i< SW_LED_NUM; i++)
|
|
|
- {
|
|
|
- index = g_sw[sw].led_cfg_index[i];
|
|
|
- if ((index != INDEX_INVALLID))
|
|
|
- {
|
|
|
- slot = g_equ_config_do[index].slot;
|
|
|
- index = g_equ_config_do[index].index;
|
|
|
-
|
|
|
- g_led_slot[slot].sn[index].sw = sw;
|
|
|
- g_led_slot[slot].sn[index].no = i;
|
|
|
-
|
|
|
- index++;
|
|
|
- if(index > g_led_slot[slot].num)
|
|
|
- {
|
|
|
- g_led_slot[slot].num = index;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // 初始化公共灯
|
|
|
+ for (i = 0; i < PUB_LED_NUM; i++)
|
|
|
+ {
|
|
|
+ index = g_sw_pub.led_cfg_index[i];
|
|
|
+ if ((index != INDEX_INVALLID))
|
|
|
+ {
|
|
|
+ slot = g_equ_config_do[index].slot;
|
|
|
+ index = g_equ_config_do[index].index;
|
|
|
+
|
|
|
+ g_led_slot[slot].sn[index].sw = 0;
|
|
|
+ g_led_slot[slot].sn[index].no = i;
|
|
|
+ dp_info_h_c("i = %d, slot = %d, index = %d", i, slot, index);
|
|
|
+
|
|
|
+ index++;
|
|
|
+ if (index > g_led_slot[slot].num)
|
|
|
+ {
|
|
|
+ g_led_slot[slot].num = index;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化开关灯
|
|
|
+ for (int sw = 0; sw < SWITCH_NUM_MAX; sw++)
|
|
|
+ {
|
|
|
+ for (i = 0; i < SW_LED_NUM; i++)
|
|
|
+ {
|
|
|
+ index = g_sw[sw].led_cfg_index[i];
|
|
|
+ if ((index != INDEX_INVALLID))
|
|
|
+ {
|
|
|
+ slot = g_equ_config_do[index].slot;
|
|
|
+ index = g_equ_config_do[index].index;
|
|
|
+ dp_info_h_c("i = %d, slot = %d, index = %d, sw = %d", i, slot, index, sw);
|
|
|
+
|
|
|
+ g_led_slot[slot].sn[index].sw = sw;
|
|
|
+ g_led_slot[slot].sn[index].no = i;
|
|
|
+
|
|
|
+ index++;
|
|
|
+ if (index > g_led_slot[slot].num)
|
|
|
+ {
|
|
|
+ g_led_slot[slot].num = index;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
- return 0;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
int equ_config_check(void)
|
|
|
@@ -413,7 +415,7 @@ int equ_config_check(void)
|
|
|
BOARD_TYPE_FUXI_DO,
|
|
|
BOARD_TYPE_FUXI_AC,
|
|
|
BOARD_TYPE_FUXI_24LED,
|
|
|
- -1,
|
|
|
+ BOARD_TYPE_MAIN,
|
|
|
-1,
|
|
|
-1,
|
|
|
-1,
|
|
|
@@ -451,103 +453,108 @@ int equ_config_check(void)
|
|
|
*/
|
|
|
int equ_init(void)
|
|
|
{
|
|
|
- int i,ret;
|
|
|
- struct timespec ts;
|
|
|
+ int i, ret;
|
|
|
+ struct timespec ts;
|
|
|
|
|
|
- // 得到装置地址和硬件版本
|
|
|
- g_slot_addr = gpio_get_addr();
|
|
|
- g_hw_version = gpio_get_version();
|
|
|
- rt_printf("g_hw_version=0x%02x, g_slot_addr=0x%02x.\r\n",g_hw_version,g_slot_addr);
|
|
|
+ // 得到装置地址和硬件版本
|
|
|
+ g_slot_addr = gpio_get_addr();
|
|
|
+ g_hw_version = gpio_get_version();
|
|
|
+ rt_printf("g_hw_version=0x%02x, g_slot_addr=0x%02x.\r\n", g_hw_version, g_slot_addr);
|
|
|
|
|
|
- // 装置板卡资源
|
|
|
- ret = equ_init_file_brd_res();
|
|
|
- if(ret != 0)
|
|
|
- {
|
|
|
- rt_err_set(ERR_CODE_EQU_RESOURCE,0);
|
|
|
- dp_err_n_c_rt("equ_init_file_resource err(ret=%d)",ret);
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ // 装置板卡资源
|
|
|
+ ret = equ_init_file_brd_res();
|
|
|
+ if (ret != 0)
|
|
|
+ {
|
|
|
+ rt_err_set(ERR_CODE_EQU_RESOURCE, 0);
|
|
|
+ dp_err_n_c_rt("equ_init_file_resource err(ret=%d)", ret);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
|
|
|
- // 装载装置配置
|
|
|
- ret = equ_init_file_config();
|
|
|
- if(ret != 0)
|
|
|
- {
|
|
|
- rt_err_set(ERR_CODE_EQU_CONFIG,0);
|
|
|
- dp_err_n_c_rt("equ_init_file_config err(ret=%d)",ret);
|
|
|
- return -2;
|
|
|
- }
|
|
|
+ // 装载装置配置
|
|
|
+ ret = equ_init_file_config();
|
|
|
+ if (ret != 0)
|
|
|
+ {
|
|
|
+ rt_err_set(ERR_CODE_EQU_CONFIG, 0);
|
|
|
+ dp_err_n_c_rt("equ_init_file_config err(ret=%d)", ret);
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
|
|
|
- // 初始化板卡信息
|
|
|
- memset(g_board_info,0,sizeof(g_board_info));
|
|
|
- clk_time_get(&ts);
|
|
|
- for(i=0; i<g_equ_config->equ_slot_num; i++)
|
|
|
- {
|
|
|
- if(equ_info_brd_type(g_equ_config->brd_type[i]) == 0)
|
|
|
- {
|
|
|
- equ_led_init();
|
|
|
- dp_err_n_c_rt("板卡类型不存在(type=%d)!",g_equ_config->brd_type[i]);
|
|
|
- return -3;
|
|
|
- }
|
|
|
-
|
|
|
- g_board_info[i].type = g_equ_config->brd_type[i];
|
|
|
- g_board_info[i].di_num = _equ_get_di_num(i);
|
|
|
- g_board_info[i].do_num = _equ_get_do_num(i);
|
|
|
- g_board_info[i].ac_num = _equ_get_ac_num(i);
|
|
|
+ // 初始化板卡信息
|
|
|
+ memset(g_board_info, 0, sizeof(g_board_info));
|
|
|
+ clk_time_get(&ts);
|
|
|
+ for (i = 0; i < g_equ_config->equ_slot_num; i++)
|
|
|
+ {
|
|
|
+ if (equ_info_brd_type(g_equ_config->brd_type[i]) == 0)
|
|
|
+ {
|
|
|
+ equ_led_init();
|
|
|
+ dp_err_n_c_rt("板卡类型不存在(type=%d)!", g_equ_config->brd_type[i]);
|
|
|
+ return -3;
|
|
|
+ }
|
|
|
|
|
|
- if((g_board_info[i].type < BOARD_TYPE_GROUP_RS)
|
|
|
- && (g_board_info[i].di_num || g_board_info[i].do_num || g_board_info[i].ac_num))
|
|
|
- {
|
|
|
- // 板卡需要周期性的检查是否正常工作。
|
|
|
- g_board_info[i].is_check = 1;
|
|
|
- }
|
|
|
+ g_board_info[i].type = g_equ_config->brd_type[i];
|
|
|
+ g_board_info[i].di_num = _equ_get_di_num(i);
|
|
|
+ g_board_info[i].do_num = _equ_get_do_num(i);
|
|
|
+ g_board_info[i].ac_num = _equ_get_ac_num(i);
|
|
|
|
|
|
- g_board_info[i].us0 = ustimer_get_origin();
|
|
|
- g_board_info[i].is_ok = 1;
|
|
|
+ if (0 != g_board_info[i].di_num)
|
|
|
+ dp_info_nt("g_board_info[%d].di_num = %d ", i, g_board_info[i].di_num);
|
|
|
+ if (0 != g_board_info[i].do_num)
|
|
|
+ dp_info_nt("g_board_info[%d].do_num = %d ", i, g_board_info[i].do_num);
|
|
|
+ if (0 != g_board_info[i].ac_num)
|
|
|
+ dp_info_nt("g_board_info[%d].ac_num = %d ", i, g_board_info[i].ac_num);
|
|
|
|
|
|
- // 主板信息
|
|
|
- if(g_board_info[i].type == BOARD_TYPE_MAIN || g_board_info[i].type == BOARD_TYPE_FTUMAIN || g_board_info[i].type == BOARD_TYPE_FBDTU_MAIN|| g_board_info[i].type == BOARD_TYPE_FBDTU_MAIN1)
|
|
|
- {
|
|
|
- g_board_info[i].crc = m_CodeCrc;
|
|
|
- g_board_info[i].version = VER_NUM;
|
|
|
- }
|
|
|
- }
|
|
|
+ if ((g_board_info[i].type < BOARD_TYPE_GROUP_RS) && (g_board_info[i].di_num || g_board_info[i].do_num || g_board_info[i].ac_num))
|
|
|
+ {
|
|
|
+ // 板卡需要周期性的检查是否正常工作。
|
|
|
+ g_board_info[i].is_check = 1;
|
|
|
+ }
|
|
|
|
|
|
- // 模拟通道配置
|
|
|
- memset(g_equ_adc_inv,0,sizeof(g_equ_adc_inv));
|
|
|
- for(i=0; i<g_equ_config->ac_num; i++)
|
|
|
- {
|
|
|
- u32 adc;
|
|
|
- adc = equ_get_ac_channel(g_equ_config_ac[i].slot,g_equ_config_ac[i].index);
|
|
|
- if (adc<CFG_ADC_CHANNEL)
|
|
|
- {
|
|
|
- // 是否配置
|
|
|
- if(g_equ_config_ac[i].type)
|
|
|
- {
|
|
|
- g_equ_adc_config[adc] = 1;
|
|
|
- }
|
|
|
-
|
|
|
- // 是否取反
|
|
|
- if (g_equ_config_ac[i].is_ct_inverse)
|
|
|
- {
|
|
|
- g_equ_adc_inv[g_equ_adc_inv_num++] = adc;
|
|
|
- }
|
|
|
+ g_board_info[i].us0 = ustimer_get_origin();
|
|
|
+ g_board_info[i].is_ok = 1;
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
+ // 主板信息
|
|
|
+ if (g_board_info[i].type == BOARD_TYPE_MAIN)
|
|
|
+ {
|
|
|
+ g_board_info[i].crc = m_CodeCrc;
|
|
|
+ g_board_info[i].version = VER_NUM;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 初始化灯
|
|
|
- equ_led_init();
|
|
|
+ // 模拟通道配置
|
|
|
+ memset(g_equ_adc_inv, 0, sizeof(g_equ_adc_inv));
|
|
|
+ for (i = 0; i < g_equ_config->ac_num; i++)
|
|
|
+ {
|
|
|
+ u32 adc;
|
|
|
+ adc = equ_get_ac_channel(g_equ_config_ac[i].slot, g_equ_config_ac[i].index);
|
|
|
+ if (adc < CFG_ADC_CHANNEL)
|
|
|
+ {
|
|
|
+ // 是否配置
|
|
|
+ if (g_equ_config_ac[i].type)
|
|
|
+ {
|
|
|
+ g_equ_adc_config[adc] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否取反
|
|
|
+ if (g_equ_config_ac[i].is_ct_inverse)
|
|
|
+ {
|
|
|
+ g_equ_adc_inv[g_equ_adc_inv_num++] = adc;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ret = equ_config_check();
|
|
|
- if(ret)
|
|
|
- {
|
|
|
- dp_err_n_c_rt("%s:ret=%d",__func__,ret);
|
|
|
- return -4;
|
|
|
- }
|
|
|
+ // 初始化灯
|
|
|
+ equ_led_init();
|
|
|
+
|
|
|
+ ret = equ_config_check();
|
|
|
+ if (ret)
|
|
|
+ {
|
|
|
+ dp_err_n_c_rt("%s:ret=%d", __func__, ret);
|
|
|
+ return -4;
|
|
|
+ }
|
|
|
|
|
|
equ_init_di();
|
|
|
|
|
|
- return 0;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
/******************************************************************************
|