|
void save_data(void)
{
//TIM4_ITConfig(TIM4_IT_UPDATE, DISABLE);
UART1_ITConfig(UART1_IT_TXE, DISABLE);
UART1_ITConfig(UART1_IT_RXNE_OR, DISABLE);
//UART1_ClearITPendingBit(UART1_IT_TXE);
//UART1_ClearITPendingBit(UART1_IT_RXNE_OR);
UART1_Cmd(DISABLE);
delay_ms(10);
GPIO_Init(GPIOA, GPIO_PIN_5|GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_FAST);
GPIO_WriteHigh(GPIOA, GPIO_PIN_4);
GPIO_WriteLow(GPIOA, GPIO_PIN_5);
delay_ms(10);
//TIM4_Cmd(DISABLE);
//IWDG_ReloadCounter(); //喂狗
//系统时间设置
if(value_index >= 1000 && value_index < 2000)
{
switch(value_index-1000)
{
case 25:
if(value_temp > 59) value_temp = 59; else if(value_temp < 0) value_temp = 0;
M41T0_ByteWrite(HEX_BCD((u8)value_temp), 0);
break;//秒
case 26:
if(value_temp > 59) value_temp = 59; else if(value_temp < 0) value_temp = 0;
M41T0_ByteWrite(HEX_BCD((u8)value_temp), 1);
break;//分
case 27:
if(value_temp > 23) value_temp = 23; else if(value_temp < 0) value_temp = 0;
M41T0_ByteWrite(HEX_BCD((u8)value_temp), 2);
break;//时
case 29: //日
if(value_temp > 31) value_temp = 31; else if(value_temp < 1) value_temp = 1;
M41T0_ByteWrite(HEX_BCD((u8)value_temp), 4);
break;
case 30: //月
if(value_temp > 12) value_temp = 12; else if(value_temp < 1) value_temp = 1;
M41T0_ByteWrite(HEX_BCD((u8)value_temp), 5);
break;
case 31: //年
if(value_temp > 99) value_temp = 99; else if(value_temp < 10) value_temp = 10;
M41T0_ByteWrite(HEX_BCD((u8)value_temp), 6);
break;
default: return;
}
}
else if(value_index >= 20 && value_index <= 48) //可设参数,
{
if(value_temp > user_para_max[value_index-20]) value_temp = user_para_max[value_index-20];
else if(value_temp < user_para_min[value_index-20]) value_temp = user_para_min[value_index-20];
data.vw[value_index] = value_temp;
write_u16(user_para_addr+(value_index-user_para_start_index)*2, value_temp);
}
else if(value_index >= 2000 && value_index < 3000) //检修参数
{
switch(value_index-2000)
{
case device_check_start_index+0: //选择机头
if(value_temp > comp_num) value_temp = comp_num; else if(value_temp < 0)value_temp = 0;
data.vw[device_check_start_index] = value_temp;
break;
case device_check_start_index+1: //冷冻设备
case device_check_start_index+2: //冷却设备
if(value_temp > 1) value_temp = 1; else if(value_temp < 0) value_temp = 0;
data.vw[value_index-2000] = value_temp;
break;
default: break;
}
}
else if(value_index >= 3000 && value_index < 4000) //保存密码
{
}
value_index = 0;
//TIM4_Cmd(ENABLE);
GPIO_Init(GPIOA, GPIO_PIN_5|GPIO_PIN_4, GPIO_MODE_IN_PU_NO_IT);
//UART1_Cmd(ENABLE);
delay_ms(10);
UART1_Cmd(ENABLE);
//TIM4_ITConfig(TIM4_IT_UPDATE, ENABLE);
UART1_ITConfig(UART1_IT_TXE, ENABLE);
UART1_ITConfig(UART1_IT_RXNE_OR, ENABLE);
IWDG_ReloadCounter(); //喂狗
} |
|