/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
  */
/* USER CODE END Header */
#include "includes.h"

const uint8_t CONFIG_BOARD_SELF = CONFIG_BOARD_SINGLE;

data_buff_t save_dcBuff = {0};
uint8_t valid_dcBuff = 0;
uint16_t save_DiffRangeHigh, save_PresRangeHigh;

// 配置外设引脚、时钟等
static void Modules_Init()
{
	Vcc_Init();
	Console_Init();
	SFlash_Init();
	Config_Init();
	LCD_Init();
}

// 打开外设，配置中断等
static void Modules_Open()
{
	Console_Open();
	SFlash_Open();
	Config_Open(&valid_dcBuff);
	LCD_MyOpen();	// form.h
}


osThreadId_t defaultTaskHandle;

/* USER CODE BEGIN PV */
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void StartDefaultTask(void *argument);

/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
  // 读取启动原因代码
  Get_ResetFlags();
  /* USER CODE END 1 */
  

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */
  Modules_Init();
  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  /* USER CODE BEGIN 2 */
  Modules_Open();
  /* USER CODE END 2 */

  osKernelInitialize();

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* definition and creation of defaultTask */
  const osThreadAttr_t defaultTask_attributes = {
    .name = "defaultTask",
    .priority = (osPriority_t) osPriorityNormal,
    .stack_size = 1024
  };
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);

  if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0)
  {
  Error_Handler();  
  }
  LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
  LL_RCC_HSI_Enable();

   /* Wait till HSI is ready */
  while(LL_RCC_HSI_IsReady() != 1)
  {
    
  }
  LL_RCC_HSI_SetCalibTrimming(16);
  LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);

   /* Wait till System clock is ready */
  while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI)
  {
  
  }
  LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
  LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
  LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
  LL_SetSystemCoreClock(16000000);
  LL_RCC_SetUSARTClockSource(LL_RCC_USART2_CLKSOURCE_PCLK1);
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/* USER CODE BEGIN Header_StartDefaultTask */
/**
  * @brief  Function implementing the defaultTask thread.
  * @param  argument: Not used 
  * @retval None
  */
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
	/* USER CODE BEGIN 5 */
	uint32_t i;
	char buf[20];

	// 屏幕全亮
	HT1621_AllOn();
	delay_ms(1000);

	printf("\nSave config to sflash ...\n");

	// 保存原来的配置
	save_dcBuff = dcBuff;
	
	// 强制修改
	Config_setBottleDefParam(&dcBuff);
	Config_setSensorDefParam(&dcBuff);
	Config_setDataDefParam(&dcBuff);
	Config_setDisplayDefParam(&dcBuff);

#if 1	
	// 保留原来的PSN号
	memmove(dcBuff.configBottle.PSN, save_dcBuff.configBottle.PSN, 6);
#else
	// 写入固定的PSN号
	dcBuff.configBottle.PSN[0] = 21;
	dcBuff.configBottle.PSN[1] = 12;
	dcBuff.configBottle.PSN[2] = 28;
	dcBuff.configBottle.PSN[3] = 20;
	dcBuff.configBottle.PSN[4] = 0;
	dcBuff.configBottle.PSN[5] = 15;
#endif
	// 如果原来有配置，则保留原来的标定数据
	if(valid_dcBuff)
	{
		// 保留默认的量程
		save_DiffRangeHigh = dcBuff.configSensor.sensorDPress.highRange;
		save_PresRangeHigh = dcBuff.configSensor.sensorPress.highRange;
		// 恢复原来的传感器数据
		dcBuff.configSensor = save_dcBuff.configSensor;
		// 恢复默认的量程
		dcBuff.configSensor.sensorDPress.highRange = save_DiffRangeHigh;
		dcBuff.configSensor.sensorPress.highRange = save_PresRangeHigh;
	}
	
	// 保存配置
	Config_SaveConfig();
	
	// 读出配置信息
	memset(&dcBuff, 0, sizeof(dcBuff));
	Config_LoadConfig();
	
	// 显示版本及配置信息
	printf("\n****\tPSN: 20%02d%02d%02d%02d%03d ****\n", dcBuff.configBottle.PSN[0], dcBuff.configBottle.PSN[1], 
		dcBuff.configBottle.PSN[2], dcBuff.configBottle.PSN[3], 
		(dcBuff.configBottle.PSN[4] << 8) | dcBuff.configBottle.PSN[5]);

	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 11)
		printf("\n****\t_DUWAPING_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 12)
		printf("\n****\t_DUWAPING_LOCAL_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 13)
		printf("\n****\t_DUWAPING_LANSHI_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 15)
		printf("\n****\t_LOCAL_DISP_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 16)
		printf("\n****\t_LOCAL_ANTI_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 17)
		printf("\n****\t_LANSHI_TTS_ANTI_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 18)
		printf("\n****\t_LANSHI_TTS_LEAK02_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 20)
		printf("\n****\t_DUWAPING_LOCAL_ANTI_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 25)
		printf("\n****\t_LOCAL_DISP_1S_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 26)
		printf("\n****\t_LOCAL_ANTI_SINGLE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 27)
		printf("\n****\t_LANSHI_TTS_ANTI_SINGLE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 28)
		printf("\n****\t_ANJIEHUI4_TTS_LEAK02_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 29)
		printf("\n****\t_LNG_LORA_4G_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 30)
		printf("\n****\t_LNG_LORA_LOCAL_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 31)
		printf("\n****\t_LANSHI_TTS_ANTI_NORM_OPEN_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 70)
		printf("\n****\t_ANJIEHUI4_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 71)
		printf("\n****\t_ANJIEHUI4_ANTI_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 72)
		printf("\n****\t_ANJIEHUI4_PRAXAIR_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 73)
		printf("\n****\t_ANJIEHUI4_LINDE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 74)
		printf("\n****\t_ANJIEHUI4_ALARM_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 75)
		printf("\n****\t_ANJIEHUI4_JINHONG_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 76)
		printf("\n****\t_ANJIEHUI4_LINDE_ALARM_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 77)
		printf("\n****\t_LOCAL_ALARM_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 78)
		printf("\n****\t_ANJIEHUI4_R0SEMOUNT_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 96)
		printf("\n****\t_LANSHI_ROSEMOUNT_485TEMPR_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 98)
		printf("\n****\t_PCT_LEVEL_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 124)
		printf("\n****\t_ANJIEHUI4_CHAOYANG_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 125)
		printf("\n****\t_HUIDA_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 127)
		printf("\n****\t_HUAGONG_BOX_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 148)
		printf("\n****\t_LANSHI_CAOCHE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 149)
		printf("\n****\t_CAOCHE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 162)
		printf("\n****\t_BOX_500_2_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 163)
		printf("\n****\t_BOX_1000_2_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 164)
		printf("\n****\t_BOX_1000_3_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 194)
		printf("\n****\t_LANSHI_BOX_1000_3_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 195)
		printf("\n****\t_LANSHI_TTS_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 196)
		printf("\n****\t_FURUI_TTS_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 197)
		printf("\n****\t_BASF_MAGNETIC_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 198)
		printf("\n****\t_PCT_LEVEL_CAOCHE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 199)
		printf("\n****\t_CIDC_MAIKE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 202)
		printf("\n****\t_PRAXAIR_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 203)
		printf("\n****\t_PRAXAIR_DOL_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 204)
		printf("\n****\t_PRAXAIR_TTS_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 205)
		printf("\n****\t_YINGDE_TTS_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 206)
		printf("\n****\t_MESSER_TTS_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 207)
		printf("\n****\t_GUANGGANG_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 212)
		printf("\n****\t_YINGDE_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 213)
		printf("\n****\t_LINDE_HTTPS_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 214)
		printf("\n****\t_MESSER_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 215)
		printf("\n****\t_FAYEKONG_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 216)
		printf("\n****\t_BAOGANG_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 217)
		printf("\n****\t_LANSHI_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 218)
		printf("\n****\t_FUSHIKANG_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 219)
		printf("\n****\t_ZHONGHAIYOU_BOX_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 220)
		printf("\n****\t_FAYEKONG_TTS_CHARGE_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 222)
		printf("\n****\t_YINGDE_DOL_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 223)
		printf("\n****\t_LINDE_HTTPS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 224)
		printf("\n****\t_LINDE_HTTPS_DOL_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 225)
		printf("\n****\t_CHATE_TTS_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 226)
		printf("\n****\t_TRAIN_BOX_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 227)
		printf("\n****\t_LANSHI_TTS_ALARM_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 228)
		printf("\n****\t_AOYANG_BOX_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 229)
		printf("\n****\t_BRASIL_BOX_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 230)
		printf("\n****\t_TTS_TEMPR_420MA_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 231)
		printf("\n****\t_LANSHI_ZNY_HEYUAN_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 232)
		printf("\n****\t_LEVEL_P2_ALARM_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 233)
		printf("\n****\t_LEVEL_P1_ALARM_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 238)
		printf("\n****\t_2ND_420MA_OUT_LEVEL_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 239)
		printf("\n****\t_ANJIEHUI4_ALL_420MA_VER_ ***\n");
	if(dcBuff.configDisplay.op_HARDWARE_VER_MAJOR == 240)
		printf("\n****\t_PAKISTAN_VER_ ***\n");
  
	printf("\n****\tHardVer: %d ***\n", dcBuff.configDisplay.op_HARDWARE_VER_MAJOR);

	if(dcBuff.configDisplay.op_DISP_MMWC_ONLY)
		printf("\n\t*** op_DISP_MMWC_ONLY = 1 ***\n");
	if(dcBuff.configDisplay.op_DOL_VER)
		printf("\n\t*** op_DOL_VER = 1 ***\n");
	if(dcBuff.configDisplay.op_BOX_VER)
		printf("\n\t*** op_BOX_VER = 1 ***\n");
	if(dcBuff.configDisplay.op_CELL_LOCATION)
		printf("\n\t*** op_CELL_LOCATION = 1 ***\n");
	if(dcBuff.configDisplay.op_NO_LOCATION)
		printf("\n\t*** op_NO_LOCATION = 1 ***\n");
	if(dcBuff.configDisplay.op_LEVEL_SENSOR_ONLY)
		printf("\n\t*** op_LEVEL_SENSOR_ONLY = 1 ***\n");
	if(!dcBuff.configDisplay.op_USE_PT100_SENSOR)
		printf("\n\t*** op_USE_PT100_SENSOR = 0 ***\n");
	if(!dcBuff.configDisplay.op_LEVEL_SENSOR_ONLY && dcBuff.configDisplay.op_USE_PT100_SENSOR && dcBuff.configDisplay.op_PT100_MULTI != 10)
		printf("\n\t*** op_PT100_MULTI = %d ***\n", dcBuff.configDisplay.op_PT100_MULTI);
	if(!dcBuff.configDisplay.op_PT100_3LINE)
		printf("\n\t*** op_PT100_3LINE = 0 ***\n");
	if(!dcBuff.configDisplay.op_DIFF_RESIST)
		printf("\n\t*** op_DIFF_RESIST = 0 ***\n");
	if(dcBuff.configDisplay.op_SEND_GPS_DATA)
		printf("\n\t*** op_SEND_GPS_DATA = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_CAPACITY_SENSOR)
		printf("\n\t*** op_USE_CAPACITY_SENSOR = 1 ***\n");
	if(dcBuff.configDisplay.op_LOCAL_DISP)
		printf("\n\t*** op_LOCAL_DISP = 1 ***\n");
	if(dcBuff.configDisplay.op_LOCAL_DISP_1S)
		printf("\n\t*** op_LOCAL_DISP_1S = 1 ***\n");
	if(dcBuff.configDisplay.op_ANTI_OVERFILL)
		printf("\n\t*** op_ANTI_OVERFILL = 1 ***\n");
	if(dcBuff.configDisplay.op_ANTI_SINGLE_CTRL)
		printf("\n\t*** op_ANTI_SINGLE_CTRL = 1 ***\n");
	if(dcBuff.configDisplay.op_ANTI_NORM_OPEN)
		printf("\n\t*** op_ANTI_NORM_OPEN = 1 ***\n");
	if(dcBuff.configDisplay.op_ANTI_AUTO_FILL)
		printf("\n\t*** op_ANTI_AUTO_FILL = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_PCT_CAP)
		printf("\n\t*** op_USE_PCT_CAP = 1 ***\n");
	if(dcBuff.configDisplay.op_ALARM_OUTPUT)
		printf("\n\t*** op_ALARM_OUTPUT = 1 ***\n");
	if(dcBuff.configDisplay.op_LOW_ALARM_OUTPUT)
		printf("\n\t*** op_LOW_ALARM_OUTPUT = 1 ***\n");
	if(dcBuff.configDisplay.op_PRESS_ALARM_OUTPUT)
		printf("\n\t*** op_PRESS_ALARM_OUTPUT = 1 ***\n");
	if(dcBuff.configDisplay.op_LOW_PRESS_ALARM_OUTPUT)
		printf("\n\t*** op_LOW_PRESS_ALARM_OUTPUT = 1 ***\n");
	if(dcBuff.configDisplay.op_TRAIN)
		printf("\n\t*** op_TRAIN = 1 ***\n");
	if(dcBuff.configDisplay.op_DIFF_420MA)
		printf("\n\t*** op_DIFF_420MA = 1 ***\n");
	if(dcBuff.configDisplay.op_PRESS_420MA)
		printf("\n\t*** op_PRESS_420MA = 1 ***\n");
	if(dcBuff.configDisplay.op_2ND_420MA_OUT_LEVEL)
		printf("\n\t*** op_2ND_420MA_OUT_LEVEL = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_R0SEMOUNT)
		printf("\n\t*** op_USE_R0SEMOUNT = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_SOLAR)
		printf("\n\t*** op_USE_SOLAR = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_O2_LEAK)
		printf("\n\t*** op_USE_O2_LEAK = 1 ***\n");
	if(dcBuff.configDisplay.op_LEAK_ALARM_OUTPUT)
		printf("\n\t*** op_LEAK_ALARM_OUTPUT = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_DOL_TTL)
		printf("\n\t*** op_USE_DOL_TTL = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_HEIGHT_LEVEL)
		printf("\n\t*** op_USE_HEIGHT_LEVEL = 1 ***\n");
	if(dcBuff.configDisplay.op_USE_PCT_LEVEL)
		printf("\n\t*** op_USE_PCT_LEVEL = 1 ***\n");
	if(dcBuff.configDisplay.op_LNG_LORA)
		printf("\n\t*** op_LNG_LORA = 1 ***\n");
	if(dcBuff.configBottle.dispMode != DISP_MODE_ALL)
		printf("\n\t*** dispMode = %d ***\n", dcBuff.configBottle.dispMode);
	
	if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_MQTT)
		printf("\n*** op_SERVER_PROTOCOL:\tMQTT ***\n");
	else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_HTTPS)
		printf("\n*** op_SERVER_PROTOCOL:\tHTTPS ***\n");
	else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_HTTP)
		printf("\n*** op_SERVER_PROTOCOL:\tHTTP ***\n");
	else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_TRAIN)
		printf("\n*** op_SERVER_PROTOCOL:\tTRAIN ***\n");
	else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_AOYANG)
		printf("\n*** op_SERVER_PROTOCOL:\tAOYANG ***\n");
	else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_FURUI)
		printf("\n*** op_SERVER_PROTOCOL:\tFURUI ***\n");
	else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_HUIDA)
		printf("\n*** op_SERVER_PROTOCOL:\tHUIDA ***\n");
	else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_CHAOYANG)
		printf("\n*** op_SERVER_PROTOCOL:\tCHAOYANG ***\n");
  else if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_PAKISTAN)
		printf("\n*** op_SERVER_PROTOCOL:\tPAKISTAN ***\n");
	else
		printf("\n*** op_SERVER_PROTOCOL:\tTCP ***\n");
	printf("\n*** Server:\t%s:%d ***\n", 
		dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_MQTT ? 
		SERVER_URLs[dcBuff.configDisplay.op_SERVER_INDEX] : dcBuff.configData.server, 
		dcBuff.configData.port);
	if(dcBuff.configDisplay.op_SERVER_PROTOCOL == SERVER_PROTOCOL_TCP && dcBuff.configDisplay.op_UNIDIR_COMM)
		printf("\n\t*** op_UNIDIR_COMM = 1 ***\n");
	
	printf("\n*** Sample:\t%ds ***\n", dcBuff.configData.intervalSample);
	printf("\n*** Send:\t%ds ***\n", dcBuff.configData.intervalTrans);
	
	// 屏幕全熄
	HT1621_AllOff();
	delay_ms(1000);
	
	// 显示发送周期、采集周期、版本号
	sprintf(buf, "%04d%3d%06d", 
		dcBuff.configData.intervalSample, dcBuff.configDisplay.op_HARDWARE_VER_MAJOR,
		dcBuff.configData.intervalTrans);
	for(i = 0; i < strlen(buf); i++)
		Disp_DispChar(i, buf[i]);
	HT1621_Refresh();

	printf("\nPlease program the main-program ...\n");
	
   /* Infinite loop */
	while(1)
	{
		printf(".");
		delay_ms(1000);
	}
  /* USER CODE END 5 */ 
}

/**
  * @brief  Period elapsed callback in non blocking mode
  * @note   This function is called  when TIM1 interrupt took place, inside
  * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
  * a global variable "uwTick" used as application time base.
  * @param  htim : TIM handle
  * @retval None
  */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
  /* USER CODE BEGIN Callback 0 */

  /* USER CODE END Callback 0 */
  if (htim->Instance == TIM1) {
    HAL_IncTick();
  }
  /* USER CODE BEGIN Callback 1 */

  /* USER CODE END Callback 1 */
}

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */

  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(char *file, uint32_t line)
{ 
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
