|
@@ -1,5 +1,7 @@
|
|
|
#include "common.h"
|
|
#include "common.h"
|
|
|
#include "board_cfg.h"
|
|
#include "board_cfg.h"
|
|
|
|
|
+#include "systick.h"
|
|
|
|
|
+#include "string.h"
|
|
|
|
|
|
|
|
#if EEPROM_TEST
|
|
#if EEPROM_TEST
|
|
|
|
|
|
|
@@ -15,12 +17,12 @@ void reset_config_for_eeprom(void)
|
|
|
board_t *board = get_board();
|
|
board_t *board = get_board();
|
|
|
if(board)
|
|
if(board)
|
|
|
{
|
|
{
|
|
|
- for(int i = 0; i < MAX_CHANNEL;i++)
|
|
|
|
|
|
|
+ for(uint8_t i = 0; i < MAX_CHANNEL;i++)
|
|
|
{
|
|
{
|
|
|
- board->md_data.rw_data.open.delay_open[i] = (1+i) *100;
|
|
|
|
|
- board->md_data.rw_data.close.delay_close[i] = (1+i) *100;
|
|
|
|
|
|
|
+ board->md_data.rw_data.open.delay_open[i] = (1+i) *1000;
|
|
|
|
|
+ board->md_data.rw_data.close.delay_close[i] = (1+i) *1000;
|
|
|
}
|
|
}
|
|
|
- memset(&board->md_data.rw_data.thr.th[0].v_top,0,sizeof(ac_rw_data_t)-sizeof(ac_delay_open_t)-sizeof(ac_delay_close_t));
|
|
|
|
|
|
|
+ memset((void*)&board->md_data.rw_data.thr.th[0].v_top,0,sizeof(ac_rw_data_t)-sizeof(ac_delay_open_t)-sizeof(ac_delay_close_t));
|
|
|
board->write_eeprom_page(EEPROM_OTHER_ADDR,(uint8_t *)&board->md_data.rw_data.open.delay_open[0], sizeof(ac_rw_data_t));
|
|
board->write_eeprom_page(EEPROM_OTHER_ADDR,(uint8_t *)&board->md_data.rw_data.open.delay_open[0], sizeof(ac_rw_data_t));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -34,35 +36,25 @@ void read_config_from_eeprom(void)
|
|
|
uint16_t device = 0;
|
|
uint16_t device = 0;
|
|
|
board->read_eeprom(EEPROM_DEVICES_ADDR,(uint8_t *)&device,EEPROM_DEVICES_LENTH);
|
|
board->read_eeprom(EEPROM_DEVICES_ADDR,(uint8_t *)&device,EEPROM_DEVICES_LENTH);
|
|
|
|
|
|
|
|
-#if EEPROM_TEST
|
|
|
|
|
- uint8_t test_buff[32] ={0};
|
|
|
|
|
- for(int i =0;i < 32;i++)
|
|
|
|
|
- test_buff[i]=i;
|
|
|
|
|
- board->write_eeprom_page(TEST_ADDR,test_buff,LENTH);
|
|
|
|
|
-
|
|
|
|
|
- for(int i =0;i < 32;i++)
|
|
|
|
|
- test_buff[i]=0;
|
|
|
|
|
- board->read_eeprom_page(TEST_ADDR,test_buff,LENTH);
|
|
|
|
|
-
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
if(device != board->md_data.r_data.dev_chn)
|
|
if(device != board->md_data.r_data.dev_chn)
|
|
|
{
|
|
{
|
|
|
//default write eeprom
|
|
//default write eeprom
|
|
|
board->write_eeprom_page(EEPROM_DEVICES_ADDR,(uint8_t *)&board->md_data.r_data.dev_chn,EEPROM_DEVICES_LENTH);
|
|
board->write_eeprom_page(EEPROM_DEVICES_ADDR,(uint8_t *)&board->md_data.r_data.dev_chn,EEPROM_DEVICES_LENTH);
|
|
|
board->write_eeprom_page(EEPROM_STATUS_ADDR,(uint8_t *)&board->relay_staging_staus[0],2*RelaySlaveChaNum);
|
|
board->write_eeprom_page(EEPROM_STATUS_ADDR,(uint8_t *)&board->relay_staging_staus[0],2*RelaySlaveChaNum);
|
|
|
-
|
|
|
|
|
- for(int i = 0; i < RelaySlaveChaNum;i++)
|
|
|
|
|
|
|
+ board->feed_dog();
|
|
|
|
|
+ for(uint8_t i = 0; i < RelaySlaveChaNum;i++)
|
|
|
{
|
|
{
|
|
|
- board->md_data.rw_data.open.delay_open[i] = (1+i) *100;
|
|
|
|
|
- board->md_data.rw_data.close.delay_close[i] = (1+i) *100;
|
|
|
|
|
|
|
+ board->md_data.rw_data.open.delay_open[i] = (1+i) * 1000;
|
|
|
|
|
+ board->md_data.rw_data.close.delay_close[i] = (1+i) * 1000;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
board->write_eeprom_page(EEPROM_OTHER_ADDR,(uint8_t *)&board->md_data.rw_data.open.delay_open[0], sizeof(ac_rw_data_t));
|
|
board->write_eeprom_page(EEPROM_OTHER_ADDR,(uint8_t *)&board->md_data.rw_data.open.delay_open[0], sizeof(ac_rw_data_t));
|
|
|
iic_data chache={0};
|
|
iic_data chache={0};
|
|
|
- for(int i = 0 ; i < MAX_ROW;i++)
|
|
|
|
|
|
|
+ for(uint8_t i = 0 ; i < MAX_ROW;i++){
|
|
|
board->write_eeprom_page(EEPROM_CONSUMER_ADDR +(CONSUM_PAGE*i),(uint8_t*)&chache.data[0],CONSUM_PAGE);
|
|
board->write_eeprom_page(EEPROM_CONSUMER_ADDR +(CONSUM_PAGE*i),(uint8_t*)&chache.data[0],CONSUM_PAGE);
|
|
|
|
|
+ board->feed_dog();
|
|
|
|
|
+ DelayNms(7);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
//channel open or close
|
|
//channel open or close
|
|
@@ -78,19 +70,19 @@ void read_config_from_eeprom(void)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ board->feed_dog();
|
|
|
board->read_eeprom_page(EEPROM_OTHER_ADDR,(uint8_t *)&board->md_data.rw_data.open.delay_open[0],sizeof(ac_rw_data_t));
|
|
board->read_eeprom_page(EEPROM_OTHER_ADDR,(uint8_t *)&board->md_data.rw_data.open.delay_open[0],sizeof(ac_rw_data_t));
|
|
|
- //get phase information
|
|
|
|
|
-// uint8_t buff[EEPROM_CHANNEL_LENTH] = {0};
|
|
|
|
|
-// board->read_eeprom_page(EEPROM_CHANNEL_PHASE,buff,EEPROM_CHANNEL_LENTH);
|
|
|
|
|
- for(int i = 0 ; i < RelaySlaveChaNum;i++)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ for(uint8_t i = 0 ; i < RelaySlaveChaNum;i++)
|
|
|
{
|
|
{
|
|
|
board->check_threshold(THRESHOLD_OUT,i);
|
|
board->check_threshold(THRESHOLD_OUT,i);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
iic_data chache={0};
|
|
iic_data chache={0};
|
|
|
- for(int i = 0 ; i < MAX_ROW;i++)
|
|
|
|
|
|
|
+ for(uint8_t i = 0 ; i < MAX_ROW;i++)
|
|
|
{
|
|
{
|
|
|
- board->read_eeprom_page(EEPROM_CONSUMER_ADDR +(CONSUM_PAGE*i),&chache,sizeof(iic_data));
|
|
|
|
|
|
|
+ board->feed_dog();
|
|
|
|
|
+ board->read_eeprom_page(EEPROM_CONSUMER_ADDR + (CONSUM_PAGE*i),(uint8_t*)&chache,sizeof(iic_data));
|
|
|
if(board->con_da.index > chache.iic_con.recode_index1)
|
|
if(board->con_da.index > chache.iic_con.recode_index1)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -100,8 +92,9 @@ void read_config_from_eeprom(void)
|
|
|
board->con_da.row = i;
|
|
board->con_da.row = i;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- board->read_eeprom_page(EEPROM_CONSUMER_ADDR +(CONSUM_PAGE*(board->con_da.row)),&chache,sizeof(iic_data));
|
|
|
|
|
- for(int i = 0 ; i < RelaySlaveChaNum;i++)
|
|
|
|
|
|
|
+ board->read_eeprom_page(EEPROM_CONSUMER_ADDR +(CONSUM_PAGE*(board->con_da.row)),(uint8_t*)&chache,sizeof(iic_data));
|
|
|
|
|
+ board->feed_dog();
|
|
|
|
|
+ for(uint16_t i = 0 ; i < RelaySlaveChaNum;i++)
|
|
|
{
|
|
{
|
|
|
board->ele_restore[i] = chache.iic_con.iic_consumer[i];
|
|
board->ele_restore[i] = chache.iic_con.iic_consumer[i];
|
|
|
}
|
|
}
|
|
@@ -112,12 +105,15 @@ void read_config_from_eeprom(void)
|
|
|
board->con_da.row = 0;
|
|
board->con_da.row = 0;
|
|
|
}
|
|
}
|
|
|
board->con_da.index++; //point next write consumer index
|
|
board->con_da.index++; //point next write consumer index
|
|
|
- if(board->con_da.index > 0XFFFFFFFFFFFFFFFF)
|
|
|
|
|
|
|
+ if(board->con_da.index > UINT64_MAX)
|
|
|
{
|
|
{
|
|
|
iic_data chache1={0};
|
|
iic_data chache1={0};
|
|
|
board->con_da.index = 0;
|
|
board->con_da.index = 0;
|
|
|
- for(int i = 0 ; i < MAX_ROW;i++)
|
|
|
|
|
- board->write_eeprom_page(EEPROM_CONSUMER_ADDR +(CONSUM_PAGE*i),&chache1,CONSUM_PAGE);
|
|
|
|
|
|
|
+ for(uint8_t i = 0 ; i < MAX_ROW;i++){
|
|
|
|
|
+ board->feed_dog();
|
|
|
|
|
+ board->write_eeprom_page(EEPROM_CONSUMER_ADDR +(CONSUM_PAGE*i),(uint8_t*)&chache1,CONSUM_PAGE);
|
|
|
|
|
+ DelayNms(7);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//read chn ctrl
|
|
//read chn ctrl
|
|
|
}
|
|
}
|
|
@@ -139,7 +135,7 @@ void set_relay_sta_async(async_data *data)
|
|
|
{
|
|
{
|
|
|
w_eeprom_data_t da = {0};
|
|
w_eeprom_data_t da = {0};
|
|
|
da.lenth =2;
|
|
da.lenth =2;
|
|
|
- memcpy(&da.data,&data->status,2);
|
|
|
|
|
|
|
+ memcpy((void*)&da.data,(void*)&data->status,2);
|
|
|
da.start_addr = (EEPROM_STATUS_ADDR+(data->channel*2));
|
|
da.start_addr = (EEPROM_STATUS_ADDR+(data->channel*2));
|
|
|
board->q_cache.en_queue(&da);
|
|
board->q_cache.en_queue(&da);
|
|
|
}
|
|
}
|