Subversion Repositories DashDisplay

Rev

Rev 76 | Rev 78 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /* USER CODE BEGIN Header */
  2. /**
  3.  ******************************************************************************
  4.  * @file           : main.c
  5.  * @brief          : Main program body
  6.  ******************************************************************************
  7.  * @attention
  8.  *
  9.  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  10.  * All rights reserved.</center></h2>
  11.  *
  12.  * This software component is licensed by ST under BSD 3-Clause license,
  13.  * the "License"; You may not use this file except in compliance with the
  14.  * License. You may obtain a copy of the License at:
  15.  *                        opensource.org/licenses/BSD-3-Clause
  16.  *
  17.  ******************************************************************************
  18.  */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22.  
  23. /* Private includes ----------------------------------------------------------*/
  24. /* USER CODE BEGIN Includes */
  25. #include <math.h>
  26.  
  27. #include "libPLX/plx.h"
  28. #include "libPLX/displayinfo.h"
  29. #include "libPLX/commsLib.h"
  30. #include "libSerial/serialUtils.H"
  31.  
  32. #include "libSmallPrintf/small_printf.h"
  33. #include "libNMEA/nmea.h"
  34. #include "switches.h"
  35. #include <string.h>
  36.  
  37. /* USER CODE END Includes */
  38.  
  39. /* Private typedef -----------------------------------------------------------*/
  40. /* USER CODE BEGIN PTD */
  41.  
  42. /* USER CODE END PTD */
  43.  
  44. /* Private define ------------------------------------------------------------*/
  45. /* USER CODE BEGIN PD */
  46. /* USER CODE END PD */
  47.  
  48. /* Private macro -------------------------------------------------------------*/
  49. /* USER CODE BEGIN PM */
  50.  
  51. /* USER CODE END PM */
  52.  
  53. /* Private variables ---------------------------------------------------------*/
  54. I2C_HandleTypeDef hi2c1;
  55.  
  56. SPI_HandleTypeDef hspi1;
  57.  
  58. TIM_HandleTypeDef htim2;
  59. TIM_HandleTypeDef htim3;
  60. TIM_HandleTypeDef htim9;
  61.  
  62. UART_HandleTypeDef huart4;
  63. UART_HandleTypeDef huart1;
  64. UART_HandleTypeDef huart2;
  65. UART_HandleTypeDef huart3;
  66.  
  67. /* USER CODE BEGIN PV */
  68. /* Private variables ---------------------------------------------------------*/
  69.  
  70. ///@brief  timeout when the ignition is switched off
  71. uint32_t const IGNITION_OFF_TIMEOUT = 30000UL;
  72.  
  73. /// @brief 1000mS per logger period, print average per period
  74. uint32_t const LOGGER_INTERVAL = 250UL;
  75.  
  76. /// @brief  about 10 seconds after twiddle, save the dial position.
  77. const int DialTimeout = 100;
  78.  
  79. /// @brief Unused Observation
  80. uniqueObs_t const nullObs = {PLX_MAX_OBS,
  81.                              PLX_MAX_INST};
  82.  
  83. /// @brief Null context
  84. context_t const nullContext = {.knobPos = -1,
  85.                                .dial_timer = 0,
  86.                                .dial0 = -1,
  87.                                .dial1 = -1,
  88.                                .OldObservation = nullObs};
  89.  
  90. /// @brief Define a null item
  91. info_t const nullInfo = {.Max = 0,
  92.                          .Min = 0xFFF,
  93.                          .sum = 0,
  94.                          .count = 0,
  95.                          .updated = 0,
  96.                          .lastUpdated = 0,
  97.                          .observation = nullObs};
  98.  
  99. context_t contexts[MAX_DISPLAYS];
  100.  
  101. /// @brief Data storage for readings
  102. info_t Info[INFO_SIZE];
  103.  
  104. uint32_t Latch_Timer;
  105.  
  106. // location for GPS data
  107. Location loc;
  108.  
  109. /// @brief Time when the logged data will be sent
  110. uint32_t nextTickReload;
  111.  
  112. // data timeout
  113. uint32_t dataTimeout = 0; //
  114.  
  115. // USART buffers
  116. uint8_t uc1_tx_buffer[TX_USART_BUFF_SIZ];
  117. uint8_t uc1_rx_buffer[RX_USART_BUFF_SIZ];
  118.  
  119. uint8_t uc2_tx_buffer[TX_USART_BUFF_SIZ];
  120. uint8_t uc2_rx_buffer[RX_USART_BUFF_SIZ];
  121.  
  122. uint8_t uc3_tx_buffer[TX_USART_BUFF_SIZ];
  123. uint8_t uc3_rx_buffer[RX_USART_BUFF_SIZ];
  124.  
  125. uint8_t uc4_tx_buffer[TX_USART_BUFF_SIZ];
  126. uint8_t uc4_rx_buffer[RX_USART_BUFF_SIZ];
  127.  
  128. /* USER CODE END PV */
  129.  
  130. /* Private function prototypes -----------------------------------------------*/
  131. void SystemClock_Config(void);
  132. static void MX_GPIO_Init(void);
  133. static void MX_SPI1_Init(void);
  134. static void MX_USART1_UART_Init(void);
  135. static void MX_USART2_UART_Init(void);
  136. static void MX_USART3_UART_Init(void);
  137. static void MX_TIM3_Init(void);
  138. static void MX_TIM9_Init(void);
  139. static void MX_TIM2_Init(void);
  140. static void MX_UART4_Init(void);
  141. static void MX_I2C1_Init(void);
  142. /* USER CODE BEGIN PFP */
  143.  
  144. // the dial is the switch number we are using.
  145. // suppress is the ItemIndex we wish to suppress on this display
  146. int DisplayCurrent(int dial, int suppress)
  147. {
  148.   return cc_display(dial, suppress);
  149. }
  150.  
  151. /// \note  HC-05 only accepts : 9600,19200,38400,57600,115200,230400,460800 baud
  152. /// \brief Setup Bluetooth module
  153. void initModule(struct usart_ctl *ctl, uint32_t baudRate)
  154. {
  155.   char initBuf[60];
  156.   // switch to command mode
  157.   HAL_GPIO_WritePin(BT_RESET_GPIO_Port, BT_RESET_Pin, GPIO_PIN_SET);
  158.   HAL_Delay(500);
  159.   // clear the button press
  160.   HAL_GPIO_WritePin(BT_RESET_GPIO_Port, BT_RESET_Pin, GPIO_PIN_RESET);
  161.   HAL_Delay(500);
  162.   setBaud(ctl, 38400);
  163.   int initLen = small_sprintf(initBuf, "AT\nAT+UART?\nAT+UART=%ld,0,0\n", baudRate);
  164.   const char buf[] = "AT+RESET\n";
  165.   sendString(ctl, initBuf, initLen);
  166.   HAL_Delay(500);
  167.   initLen = small_sprintf(initBuf, buf);
  168.   sendString(ctl, initBuf, initLen);
  169.  
  170.   TxWaitEmpty(ctl);
  171.  
  172.   // switch back to normal comms at new baud rate
  173.   setBaud(ctl, baudRate);
  174.   HAL_Delay(100);
  175. }
  176.  
  177. // workspace for RMC data read from GPS module.
  178. volatile uint16_t rmc_length;
  179.  
  180. uint8_t rmc_callback(uint8_t *data, uint16_t length)
  181. {
  182.   // send it back out
  183.   rmc_length = length;
  184.  
  185.   sendString(&uc3, (const char *)data, length);
  186.  
  187.   nextTickReload = HAL_GetTick() + LOGGER_INTERVAL;
  188.  
  189.   return 0;
  190. }
  191.  
  192. // check if bluetooth connected
  193. uint8_t btConnected()
  194. {
  195.   return HAL_GPIO_ReadPin(BT_STATE_GPIO_Port, BT_STATE_Pin) == GPIO_PIN_SET;
  196. }
  197.  
  198. /// @brief return true if this slot is unused
  199. /// @param ptr pointer to the slot to
  200. uint8_t isUnused(int index)
  201. {
  202.   if (index < 0 || index > PLX_MAX_OBS)
  203.     return false;
  204.   return Info[index].observation.Instance == PLX_MAX_INST && Info[index].observation.Obs == PLX_MAX_OBS;
  205. }
  206.  
  207. /// @brief Determine if an entry is currently valid
  208. /// @param index the number of the array entry to display
  209. /// @return true if the entry contains data which is fresh
  210. uint8_t isValid(int index)
  211. {
  212.   if (index < 0 || index > INFO_SIZE)
  213.     return false;
  214.   if (isUnused(index))
  215.     return false;
  216.  
  217.   uint32_t age = HAL_GetTick() - Info[index].lastUpdated;
  218.  
  219.   if (age > 300)
  220.     return false;
  221.  
  222.   return true;
  223. }
  224.  
  225. /* USER CODE END PFP */
  226.  
  227. /* Private user code ---------------------------------------------------------*/
  228. /* USER CODE BEGIN 0 */
  229.  
  230. unsigned mapToIndex(unsigned instance, unsigned item)
  231. {
  232.   return  instance  + item * PLX_MAX_INST_LIMIT;
  233. }
  234.  
  235. void libPLXcallbackSendUserData(struct usart_ctl *instance)
  236. {
  237.   (void)instance;
  238. }
  239.  
  240. void libPLXcallbackRecievedData(PLX_SensorInfo *info)
  241. {
  242.   // received some data , timeout is reset
  243.   dataTimeout = 0;
  244.  
  245.   // search to see if the item already has a slot in the Info[] array
  246.   // match the observation and instance: if found, update entry
  247.   enum PLX_Observations observation = ConvPLX(info->AddrH,
  248.                                               info->AddrL);
  249.  
  250.   char instance = info->Instance;
  251.  
  252.   // validate the current item, discard out of range
  253.   if ((instance > PLX_MAX_INST_LIMIT) || (observation > PLX_MAX_OBS))
  254.     return;
  255.  
  256.  
  257.   unsigned currentSlot = mapToIndex(instance ,observation);
  258.  
  259.  
  260.   int16_t data = ConvPLX(info->ReadingH,
  261.                          info->ReadingL);
  262.  
  263.   Info[currentSlot].observation.Obs = observation;
  264.  
  265.   Info[currentSlot].observation.Instance = instance;
  266.   Info[currentSlot].data = data;
  267.   if (data > Info[currentSlot].Max)
  268.   {
  269.     Info[currentSlot].Max = data;
  270.   }
  271.   if (data < Info[currentSlot].Min)
  272.   {
  273.     Info[currentSlot].Min = data;
  274.   }
  275.   // take an average
  276.   Info[currentSlot].sum += data;
  277.   Info[currentSlot].count++;
  278.   // note the last update time
  279.   Info[currentSlot].lastUpdated = HAL_GetTick();
  280.   Info[currentSlot].updated = 1; // it has been updated
  281.  
  282. }
  283. /* USER CODE END 0 */
  284.  
  285. /**
  286.  * @brief  The application entry point.
  287.  * @retval int
  288.  */
  289. int main(void)
  290. {
  291.  
  292.   /* USER CODE BEGIN 1 */
  293.   __HAL_RCC_SPI1_CLK_ENABLE();
  294.   __HAL_RCC_USART1_CLK_ENABLE(); // PLX main port
  295.   __HAL_RCC_USART2_CLK_ENABLE(); // debug port
  296.   __HAL_RCC_USART3_CLK_ENABLE(); // Bluetooth port
  297.   __HAL_RCC_UART4_CLK_ENABLE();  // NMEA0183 port
  298.  
  299.   __HAL_RCC_TIM3_CLK_ENABLE();
  300.  
  301.   __HAL_RCC_TIM9_CLK_ENABLE();
  302.  
  303.   /* USER CODE END 1 */
  304.  
  305.   /* MCU Configuration--------------------------------------------------------*/
  306.  
  307.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  308.   HAL_Init();
  309.  
  310.   /* USER CODE BEGIN Init */
  311.  
  312.   /* USER CODE END Init */
  313.  
  314.   /* Configure the system clock */
  315.   SystemClock_Config();
  316.  
  317.   /* USER CODE BEGIN SysInit */
  318.   // Switch handler called on sysTick interrupt.
  319.   InitSwitches();
  320.  
  321.   /* USER CODE END SysInit */
  322.  
  323.   /* Initialize all configured peripherals */
  324.   MX_GPIO_Init();
  325.   MX_SPI1_Init();
  326.   MX_USART1_UART_Init();
  327.   MX_USART2_UART_Init();
  328.   MX_USART3_UART_Init();
  329.   MX_TIM3_Init();
  330.   MX_TIM9_Init();
  331.   MX_TIM2_Init();
  332.   MX_UART4_Init();
  333.   MX_I2C1_Init();
  334.   /* USER CODE BEGIN 2 */
  335.  
  336.   /* Turn on USART1 IRQ */
  337.   HAL_NVIC_SetPriority(USART1_IRQn, 2, 0);
  338.   HAL_NVIC_EnableIRQ(USART1_IRQn);
  339.  
  340.   /* Turn on USART2 IRQ  */
  341.   HAL_NVIC_SetPriority(USART2_IRQn, 4, 0);
  342.   HAL_NVIC_EnableIRQ(USART2_IRQn);
  343.  
  344.   /* turn on USART3 IRQ */
  345.   HAL_NVIC_SetPriority(USART3_IRQn, 4, 0);
  346.   HAL_NVIC_EnableIRQ(USART3_IRQn);
  347.  
  348.   /* turn on UART4 IRQ */
  349.   HAL_NVIC_SetPriority(UART4_IRQn, 4, 0);
  350.   HAL_NVIC_EnableIRQ(UART4_IRQn);
  351.  
  352.   /* setup the USART control blocks */
  353.   init_usart_ctl(&uc1, &huart1, uc1_tx_buffer,
  354.                  uc1_rx_buffer,
  355.                  TX_USART_BUFF_SIZ,
  356.                  TX_USART_BUFF_SIZ);
  357.   init_usart_ctl(&uc2, &huart2, uc2_tx_buffer,
  358.                  uc2_rx_buffer,
  359.                  TX_USART_BUFF_SIZ,
  360.                  TX_USART_BUFF_SIZ);
  361.   init_usart_ctl(&uc3, &huart3, uc3_tx_buffer,
  362.                  uc3_rx_buffer,
  363.                  TX_USART_BUFF_SIZ,
  364.                  TX_USART_BUFF_SIZ);
  365.   init_usart_ctl(&uc4, &huart4, uc4_tx_buffer,
  366.                  uc4_rx_buffer,
  367.                  TX_USART_BUFF_SIZ,
  368.                  TX_USART_BUFF_SIZ);
  369.  
  370.   EnableSerialRxInterrupt(&uc1);
  371.   EnableSerialRxInterrupt(&uc2);
  372.   EnableSerialRxInterrupt(&uc3);
  373.   EnableSerialRxInterrupt(&uc4);
  374.  
  375.   HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL);
  376.  
  377.   HAL_TIM_Encoder_Start(&htim9, TIM_CHANNEL_ALL);
  378.  
  379.   initModule(&uc3, 38400);
  380.  
  381.   // Initialise UART for 4800 baud NMEA
  382.   setBaud(&uc2, 4800);
  383.  
  384.   // Initialuse UART4 for 4800 baud NMEA.
  385.   setBaud(&uc4, 4800);
  386.  
  387.   cc_init();
  388.  
  389.   for (int i = 0; i < MAX_DISPLAYS; ++i)
  390.   {
  391.     contexts[i] = nullContext; // set the knob position
  392.   }
  393.  
  394.   /* reset the display timeout, latch on power from accessories */
  395.   Latch_Timer = IGNITION_OFF_TIMEOUT;
  396.   HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port, POWER_LATCH_Pin, GPIO_PIN_RESET);
  397.  
  398.   /// @brief Time when the logged data will be sent
  399.  
  400.   setRmcCallback(&rmc_callback);
  401.  
  402.   // used in NMEA style logging
  403.   uint32_t nextTick = 0; ///< time to send next
  404.   nextTickReload = 0;
  405.   uint32_t offsetTicks = 0; ///< time to print as offset in mS for each loop
  406.  
  407.   for (int i = 0; i < INFO_SIZE; ++i)
  408.   {
  409.     Info[i] = nullInfo;
  410.   }
  411.  
  412.   uint32_t resetCounter = 0; // record time at which both reset buttons were first pressed.
  413.  
  414.   resetPLX();
  415.   /* USER CODE END 2 */
  416.  
  417.   /* Infinite loop */
  418.   /* USER CODE BEGIN WHILE */
  419.   while (1)
  420.   {
  421.  
  422.     /* while ignition is on, keep resetting power latch timer */
  423.     if (HAL_GPIO_ReadPin(IGNITION_GPIO_Port, IGNITION_Pin) == GPIO_PIN_RESET)
  424.     {
  425.       Latch_Timer = HAL_GetTick() + IGNITION_OFF_TIMEOUT;
  426.     }
  427.     else
  428.     {
  429.       /* if the ignition has been off for a while, then turn off power */
  430.       if (HAL_GetTick() > Latch_Timer)
  431.       {
  432.         HAL_GPIO_WritePin(POWER_LATCH_GPIO_Port, POWER_LATCH_Pin,
  433.                           GPIO_PIN_RESET);
  434.       }
  435.     }
  436.  
  437.     // Handle the bluetooth pairing / reset function by pressing both buttons.
  438.     if ((push_pos[0] == 1) && (push_pos[1] == 1))
  439.     {
  440.       HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin,
  441.                         GPIO_PIN_RESET);
  442.       if (resetCounter == 0)
  443.         resetCounter = HAL_GetTick();
  444.     }
  445.     else
  446.     {
  447.       HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin,
  448.                         GPIO_PIN_SET);
  449.  
  450.       if (resetCounter != 0)
  451.       {
  452.         // Held down reset button for 10 seconds, clear NVRAM.
  453.         if ((HAL_GetTick() - resetCounter) > 10000)
  454.         {
  455.           for (int i = 0; i < MAX_DISPLAYS; i++)
  456.           {
  457.             contexts[i] = nullContext;
  458.             contexts[i].dial_timer = 1; // timeout immediately when decremented
  459.           }
  460.           erase_nvram();
  461.         }
  462.         resetCounter = 0;
  463.       }
  464.     }
  465.  
  466.     // poll GPS Position/time on UART4
  467.     (void)updateLocation(&loc, &uc4);
  468.     if (loc.valid == 'V')
  469.       memset(loc.time, '-', 6);
  470.  
  471.     // if permitted, log data from RMC packet
  472.     if (btConnected())
  473.     {
  474.       // Timeout for data logging regularly
  475.       if (HAL_GetTick() > nextTick)
  476.       {
  477.         nextTick = nextTickReload;
  478.         nextTickReload += LOGGER_INTERVAL;
  479.  
  480.         // Send items  to BT if it is in connected state
  481.         // print timestamp as a $PLTIM record.
  482.         char linebuff[20];
  483.         strftime(linebuff, sizeof(linebuff), "%H%M%S", &loc.tv);
  484.  
  485.         char outbuff[100];
  486.         int cnt = small_sprintf(outbuff, "$PLTIM,%s.%03lu\n", linebuff, offsetTicks);
  487.         sendString(&uc3, outbuff, cnt);
  488.         offsetTicks += LOGGER_INTERVAL;
  489.  
  490.         // increment timer
  491.         if (offsetTicks >= (1000))
  492.         {
  493.           offsetTicks -= 1000;
  494.           loc.tv.tm_sec++;
  495.           if (loc.tv.tm_sec >= 60)
  496.           {
  497.             loc.tv.tm_sec = 0;
  498.             loc.tv.tm_min++;
  499.             if (loc.tv.tm_min >= 60)
  500.             {
  501.               loc.tv.tm_hour++;
  502.               if (loc.tv.tm_hour >= 24)
  503.                 loc.tv.tm_hour = 0;
  504.             }
  505.           }
  506.         }
  507.  
  508.         for (int i = 0; i < INFO_SIZE; ++i)
  509.         {
  510.           if (!isValid(i))
  511.             continue;
  512.           // format output
  513.           // avoid division by zero for items with no sample data this iteration
  514.           if (Info[i].count == 0)
  515.             continue;
  516.           double average = (double)Info[i].sum / Info[i].count;
  517.           enum PLX_Observations Observation = Info[i].observation.Obs;
  518.  
  519.           double cur_rdg = ConveriMFDRaw2Data((enum PLX_Observations)Observation, DisplayInfo[Observation].Units,
  520.                                               average);
  521.           int cnt;
  522.           int intPart;
  523.           // depending on digits after the decimal point,
  524.           // choose how to format data
  525.           switch (DisplayInfo[Observation].DP)
  526.           {
  527.           default:
  528.           case 0:
  529.             cnt = small_sprintf(outbuff,
  530.                                 "$PLLOG,%s,%d,%d",
  531.                                 DisplayInfo[Info[i].observation.Obs].name,
  532.                                 Info[i].observation.Instance,
  533.                                 (int)cur_rdg);
  534.  
  535.             break;
  536.           case 1:
  537.             intPart = (int)(cur_rdg * 10);
  538.             cnt = small_sprintf(outbuff,
  539.                                 "$PLLOG,%s,%d,%d.%1d",
  540.                                 DisplayInfo[Info[i].observation.Obs].name,
  541.                                 Info[i].observation.Instance,
  542.                                 intPart / 10, abs(intPart) % 10);
  543.  
  544.             break;
  545.           case 2:
  546.             intPart = (int)(cur_rdg * 100);
  547.             cnt = small_sprintf(outbuff,
  548.                                 "$PLLOG,%s,%d,%d.%02d",
  549.                                 DisplayInfo[Info[i].observation.Obs].name,
  550.                                 Info[i].observation.Instance,
  551.                                 intPart / 100, abs(intPart) % 100);
  552.  
  553.             break;
  554.           }
  555.  
  556.           Info[i].count = 0;
  557.           Info[i].sum = 0;
  558.  
  559.           // NMEA style checksum
  560.           int ck;
  561.           int sum = 0;
  562.           for (ck = 1; ck < cnt; ck++)
  563.             sum += outbuff[ck];
  564.           cnt += small_sprintf(outbuff + cnt, "*%02X\n",
  565.                                sum & 0xFF);
  566.           sendString(&uc3, outbuff, cnt);
  567.         }
  568.       }
  569.     }
  570.  
  571.     // poll data into libPLX
  572.     libPLXpollData(&uc1);
  573.  
  574.     // determine if we are getting any data from the interface
  575.  
  576.     dataTimeout++;
  577.     if (btConnected() && (dataTimeout % 1000 == 0))
  578.     {
  579.       const char msg[] = "Timeout\r\n";
  580.       sendString(&uc3, msg, sizeof(msg));
  581.     }
  582.  
  583.     if (dataTimeout > 60000)
  584.     {
  585.  
  586.       // do turn off screen
  587.     }
  588.  
  589.     // handle switch rotation
  590.     for (int i = 0; i < MAX_DIALS; ++i)
  591.     {
  592.       int delta = get_dial_diff(i);
  593.       int pos = contexts[i].knobPos;
  594.       if (pos < 0)
  595.         break; // dont process until we have read NVRAM for the first time .
  596.       int start = pos;
  597.       // move in positive direction
  598.       while (delta > 0)
  599.       {
  600.         // skip invalid items, dont count
  601.         if (pos < INFO_SIZE - 1)
  602.           pos++;
  603.         else
  604.           pos = 0;
  605.  
  606.         if (isValid(pos))
  607.           delta--; // count a valid item
  608.  
  609.         // wrap
  610.         if (pos == start)
  611.           break;
  612.       }
  613.  
  614.       // move in negative direction
  615.       while (delta < 0)
  616.       {
  617.         // skip invalid items, dont count
  618.         if (pos > 0)
  619.           pos--;
  620.         else
  621.           pos = INFO_SIZE - 1;
  622.  
  623.         if (isValid(pos))
  624.           delta++; // count a valid item
  625.  
  626.         // wrap
  627.         if (pos == start)
  628.           break;
  629.       }
  630.  
  631.       contexts[i].knobPos = pos;
  632.       if (pos != start)
  633.         contexts[i].dial_timer = DialTimeout;
  634.     }
  635.  
  636.     int suppress = -1;
  637.     for (int i = 0; i < MAX_DISPLAYS; ++i)
  638.     { // now to display the information
  639.       suppress = DisplayCurrent(i, suppress);
  640.  
  641.       cc_check_nvram(i);
  642.     }
  643.     HAL_Delay(1);
  644.     /* USER CODE END WHILE */
  645.   }
  646.   /* USER CODE BEGIN 3 */
  647.  
  648.   /* USER CODE END 3 */
  649. }
  650.  
  651. /**
  652.  * @brief System Clock Configuration
  653.  * @retval None
  654.  */
  655. void SystemClock_Config(void)
  656. {
  657.   RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  658.   RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  659.  
  660.   /** Configure the main internal regulator output voltage
  661.    */
  662.   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
  663.  
  664.   /** Initializes the RCC Oscillators according to the specified parameters
  665.    * in the RCC_OscInitTypeDef structure.
  666.    */
  667.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  668.   RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  669.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  670.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  671.   RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12;
  672.   RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
  673.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  674.   {
  675.     Error_Handler();
  676.   }
  677.  
  678.   /** Initializes the CPU, AHB and APB buses clocks
  679.    */
  680.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  681.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  682.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  683.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  684.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  685.  
  686.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
  687.   {
  688.     Error_Handler();
  689.   }
  690. }
  691.  
  692. /**
  693.  * @brief I2C1 Initialization Function
  694.  * @param None
  695.  * @retval None
  696.  */
  697. static void MX_I2C1_Init(void)
  698. {
  699.  
  700.   /* USER CODE BEGIN I2C1_Init 0 */
  701.  
  702.   /* USER CODE END I2C1_Init 0 */
  703.  
  704.   /* USER CODE BEGIN I2C1_Init 1 */
  705.  
  706.   /* USER CODE END I2C1_Init 1 */
  707.   hi2c1.Instance = I2C1;
  708.   hi2c1.Init.ClockSpeed = 100000;
  709.   hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  710.   hi2c1.Init.OwnAddress1 = 0;
  711.   hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  712.   hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  713.   hi2c1.Init.OwnAddress2 = 0;
  714.   hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  715.   hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  716.   if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  717.   {
  718.     Error_Handler();
  719.   }
  720.   /* USER CODE BEGIN I2C1_Init 2 */
  721.  
  722.   /* USER CODE END I2C1_Init 2 */
  723. }
  724.  
  725. /**
  726.  * @brief SPI1 Initialization Function
  727.  * @param None
  728.  * @retval None
  729.  */
  730. static void MX_SPI1_Init(void)
  731. {
  732.  
  733.   /* USER CODE BEGIN SPI1_Init 0 */
  734.  
  735.   /* USER CODE END SPI1_Init 0 */
  736.  
  737.   /* USER CODE BEGIN SPI1_Init 1 */
  738.  
  739.   /* USER CODE END SPI1_Init 1 */
  740.   /* SPI1 parameter configuration*/
  741.   hspi1.Instance = SPI1;
  742.   hspi1.Init.Mode = SPI_MODE_MASTER;
  743.   hspi1.Init.Direction = SPI_DIRECTION_1LINE;
  744.   hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  745.   hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
  746.   hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  747.   hspi1.Init.NSS = SPI_NSS_SOFT;
  748.   hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
  749.   hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  750.   hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  751.   hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  752.   hspi1.Init.CRCPolynomial = 10;
  753.   if (HAL_SPI_Init(&hspi1) != HAL_OK)
  754.   {
  755.     Error_Handler();
  756.   }
  757.   /* USER CODE BEGIN SPI1_Init 2 */
  758.  
  759.   /* USER CODE END SPI1_Init 2 */
  760. }
  761.  
  762. /**
  763.  * @brief TIM2 Initialization Function
  764.  * @param None
  765.  * @retval None
  766.  */
  767. static void MX_TIM2_Init(void)
  768. {
  769.  
  770.   /* USER CODE BEGIN TIM2_Init 0 */
  771.  
  772.   /* USER CODE END TIM2_Init 0 */
  773.  
  774.   TIM_ClockConfigTypeDef sClockSourceConfig = {0};
  775.   TIM_MasterConfigTypeDef sMasterConfig = {0};
  776.  
  777.   /* USER CODE BEGIN TIM2_Init 1 */
  778.  
  779.   /* USER CODE END TIM2_Init 1 */
  780.   htim2.Instance = TIM2;
  781.   htim2.Init.Prescaler = 0;
  782.   htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
  783.   htim2.Init.Period = 65535;
  784.   htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  785.   htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  786.   if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
  787.   {
  788.     Error_Handler();
  789.   }
  790.   sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  791.   if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
  792.   {
  793.     Error_Handler();
  794.   }
  795.   sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  796.   sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  797.   if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
  798.   {
  799.     Error_Handler();
  800.   }
  801.   /* USER CODE BEGIN TIM2_Init 2 */
  802.  
  803.   /* USER CODE END TIM2_Init 2 */
  804. }
  805.  
  806. /**
  807.  * @brief TIM3 Initialization Function
  808.  * @param None
  809.  * @retval None
  810.  */
  811. static void MX_TIM3_Init(void)
  812. {
  813.  
  814.   /* USER CODE BEGIN TIM3_Init 0 */
  815.  
  816.   /* USER CODE END TIM3_Init 0 */
  817.  
  818.   TIM_Encoder_InitTypeDef sConfig = {0};
  819.   TIM_MasterConfigTypeDef sMasterConfig = {0};
  820.  
  821.   /* USER CODE BEGIN TIM3_Init 1 */
  822.  
  823.   /* USER CODE END TIM3_Init 1 */
  824.   htim3.Instance = TIM3;
  825.   htim3.Init.Prescaler = 0;
  826.   htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  827.   htim3.Init.Period = 65535;
  828.   htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  829.   htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  830.   sConfig.EncoderMode = TIM_ENCODERMODE_TI1;
  831.   sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
  832.   sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
  833.   sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
  834.   sConfig.IC1Filter = 15;
  835.   sConfig.IC2Polarity = TIM_ICPOLARITY_RISING;
  836.   sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
  837.   sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
  838.   sConfig.IC2Filter = 15;
  839.   if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK)
  840.   {
  841.     Error_Handler();
  842.   }
  843.   sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  844.   sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  845.   if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
  846.   {
  847.     Error_Handler();
  848.   }
  849.   /* USER CODE BEGIN TIM3_Init 2 */
  850.  
  851.   /* USER CODE END TIM3_Init 2 */
  852. }
  853.  
  854. /**
  855.  * @brief TIM9 Initialization Function
  856.  * @param None
  857.  * @retval None
  858.  */
  859. static void MX_TIM9_Init(void)
  860. {
  861.  
  862.   /* USER CODE BEGIN TIM9_Init 0 */
  863.  
  864.   /* USER CODE END TIM9_Init 0 */
  865.  
  866.   TIM_Encoder_InitTypeDef sConfig = {0};
  867.   TIM_MasterConfigTypeDef sMasterConfig = {0};
  868.  
  869.   /* USER CODE BEGIN TIM9_Init 1 */
  870.  
  871.   /* USER CODE END TIM9_Init 1 */
  872.   htim9.Instance = TIM9;
  873.   htim9.Init.Prescaler = 0;
  874.   htim9.Init.CounterMode = TIM_COUNTERMODE_UP;
  875.   htim9.Init.Period = 65535;
  876.   htim9.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  877.   htim9.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  878.   sConfig.EncoderMode = TIM_ENCODERMODE_TI1;
  879.   sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
  880.   sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
  881.   sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
  882.   sConfig.IC1Filter = 15;
  883.   sConfig.IC2Polarity = TIM_ICPOLARITY_RISING;
  884.   sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
  885.   sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
  886.   sConfig.IC2Filter = 0;
  887.   if (HAL_TIM_Encoder_Init(&htim9, &sConfig) != HAL_OK)
  888.   {
  889.     Error_Handler();
  890.   }
  891.   sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  892.   sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  893.   if (HAL_TIMEx_MasterConfigSynchronization(&htim9, &sMasterConfig) != HAL_OK)
  894.   {
  895.     Error_Handler();
  896.   }
  897.   /* USER CODE BEGIN TIM9_Init 2 */
  898.  
  899.   /* USER CODE END TIM9_Init 2 */
  900. }
  901.  
  902. /**
  903.  * @brief UART4 Initialization Function
  904.  * @param None
  905.  * @retval None
  906.  */
  907. static void MX_UART4_Init(void)
  908. {
  909.  
  910.   /* USER CODE BEGIN UART4_Init 0 */
  911.  
  912.   /* USER CODE END UART4_Init 0 */
  913.  
  914.   /* USER CODE BEGIN UART4_Init 1 */
  915.  
  916.   /* USER CODE END UART4_Init 1 */
  917.   huart4.Instance = UART4;
  918.   huart4.Init.BaudRate = 4800;
  919.   huart4.Init.WordLength = UART_WORDLENGTH_8B;
  920.   huart4.Init.StopBits = UART_STOPBITS_1;
  921.   huart4.Init.Parity = UART_PARITY_NONE;
  922.   huart4.Init.Mode = UART_MODE_TX_RX;
  923.   huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  924.   huart4.Init.OverSampling = UART_OVERSAMPLING_16;
  925.   if (HAL_UART_Init(&huart4) != HAL_OK)
  926.   {
  927.     Error_Handler();
  928.   }
  929.   /* USER CODE BEGIN UART4_Init 2 */
  930.  
  931.   /* USER CODE END UART4_Init 2 */
  932. }
  933.  
  934. /**
  935.  * @brief USART1 Initialization Function
  936.  * @param None
  937.  * @retval None
  938.  */
  939. static void MX_USART1_UART_Init(void)
  940. {
  941.  
  942.   /* USER CODE BEGIN USART1_Init 0 */
  943.  
  944.   /* USER CODE END USART1_Init 0 */
  945.  
  946.   /* USER CODE BEGIN USART1_Init 1 */
  947.  
  948.   /* USER CODE END USART1_Init 1 */
  949.   huart1.Instance = USART1;
  950.   huart1.Init.BaudRate = 19200;
  951.   huart1.Init.WordLength = UART_WORDLENGTH_8B;
  952.   huart1.Init.StopBits = UART_STOPBITS_1;
  953.   huart1.Init.Parity = UART_PARITY_NONE;
  954.   huart1.Init.Mode = UART_MODE_TX_RX;
  955.   huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  956.   huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  957.   if (HAL_UART_Init(&huart1) != HAL_OK)
  958.   {
  959.     Error_Handler();
  960.   }
  961.   /* USER CODE BEGIN USART1_Init 2 */
  962.  
  963.   /* USER CODE END USART1_Init 2 */
  964. }
  965.  
  966. /**
  967.  * @brief USART2 Initialization Function
  968.  * @param None
  969.  * @retval None
  970.  */
  971. static void MX_USART2_UART_Init(void)
  972. {
  973.  
  974.   /* USER CODE BEGIN USART2_Init 0 */
  975.  
  976.   /* USER CODE END USART2_Init 0 */
  977.  
  978.   /* USER CODE BEGIN USART2_Init 1 */
  979.  
  980.   /* USER CODE END USART2_Init 1 */
  981.   huart2.Instance = USART2;
  982.   huart2.Init.BaudRate = 115200;
  983.   huart2.Init.WordLength = UART_WORDLENGTH_8B;
  984.   huart2.Init.StopBits = UART_STOPBITS_1;
  985.   huart2.Init.Parity = UART_PARITY_NONE;
  986.   huart2.Init.Mode = UART_MODE_TX_RX;
  987.   huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  988.   huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  989.   if (HAL_UART_Init(&huart2) != HAL_OK)
  990.   {
  991.     Error_Handler();
  992.   }
  993.   /* USER CODE BEGIN USART2_Init 2 */
  994.  
  995.   /* USER CODE END USART2_Init 2 */
  996. }
  997.  
  998. /**
  999.  * @brief USART3 Initialization Function
  1000.  * @param None
  1001.  * @retval None
  1002.  */
  1003. static void MX_USART3_UART_Init(void)
  1004. {
  1005.  
  1006.   /* USER CODE BEGIN USART3_Init 0 */
  1007.  
  1008.   /* USER CODE END USART3_Init 0 */
  1009.  
  1010.   /* USER CODE BEGIN USART3_Init 1 */
  1011.  
  1012.   /* USER CODE END USART3_Init 1 */
  1013.   huart3.Instance = USART3;
  1014.   huart3.Init.BaudRate = 19200;
  1015.   huart3.Init.WordLength = UART_WORDLENGTH_8B;
  1016.   huart3.Init.StopBits = UART_STOPBITS_1;
  1017.   huart3.Init.Parity = UART_PARITY_NONE;
  1018.   huart3.Init.Mode = UART_MODE_TX_RX;
  1019.   huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  1020.   huart3.Init.OverSampling = UART_OVERSAMPLING_16;
  1021.   if (HAL_UART_Init(&huart3) != HAL_OK)
  1022.   {
  1023.     Error_Handler();
  1024.   }
  1025.   /* USER CODE BEGIN USART3_Init 2 */
  1026.  
  1027.   /* USER CODE END USART3_Init 2 */
  1028. }
  1029.  
  1030. /**
  1031.  * @brief GPIO Initialization Function
  1032.  * @param None
  1033.  * @retval None
  1034.  */
  1035. static void MX_GPIO_Init(void)
  1036. {
  1037.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  1038.   /* USER CODE BEGIN MX_GPIO_Init_1 */
  1039.   /* USER CODE END MX_GPIO_Init_1 */
  1040.  
  1041.   /* GPIO Ports Clock Enable */
  1042.   __HAL_RCC_GPIOH_CLK_ENABLE();
  1043.   __HAL_RCC_GPIOA_CLK_ENABLE();
  1044.   __HAL_RCC_GPIOC_CLK_ENABLE();
  1045.   __HAL_RCC_GPIOB_CLK_ENABLE();
  1046.  
  1047.   /*Configure GPIO pin Output Level */
  1048.   HAL_GPIO_WritePin(GPIOA, SPI_NSS1_Pin | BT_BUTTON_Pin | BT_RESET_Pin, GPIO_PIN_SET);
  1049.  
  1050.   /*Configure GPIO pin Output Level */
  1051.   HAL_GPIO_WritePin(SPI_CD_GPIO_Port, SPI_CD_Pin, GPIO_PIN_RESET);
  1052.  
  1053.   /*Configure GPIO pin Output Level */
  1054.   HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin | POWER_LATCH_Pin | USB_PWR_Pin, GPIO_PIN_RESET);
  1055.  
  1056.   /*Configure GPIO pin Output Level */
  1057.   HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET);
  1058.  
  1059.   /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */
  1060.   GPIO_InitStruct.Pin = SPI_NSS1_Pin | SPI_CD_Pin;
  1061.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  1062.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  1063.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  1064.   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  1065.  
  1066.   /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */
  1067.   GPIO_InitStruct.Pin = SPI_RESET_Pin | SPI_NSS2_Pin | POWER_LATCH_Pin | USB_PWR_Pin;
  1068.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  1069.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  1070.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  1071.   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  1072.  
  1073.   /*Configure GPIO pins : BT_STATE_Pin SW1_PUSH_Pin SW2_PUSH_Pin */
  1074.   GPIO_InitStruct.Pin = BT_STATE_Pin | SW1_PUSH_Pin | SW2_PUSH_Pin;
  1075.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  1076.   GPIO_InitStruct.Pull = GPIO_PULLUP;
  1077.   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  1078.  
  1079.   /*Configure GPIO pin : IGNITION_Pin */
  1080.   GPIO_InitStruct.Pin = IGNITION_Pin;
  1081.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  1082.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  1083.   HAL_GPIO_Init(IGNITION_GPIO_Port, &GPIO_InitStruct);
  1084.  
  1085.   /*Configure GPIO pin : BT_BUTTON_Pin */
  1086.   GPIO_InitStruct.Pin = BT_BUTTON_Pin;
  1087.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
  1088.   GPIO_InitStruct.Pull = GPIO_PULLUP;
  1089.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  1090.   HAL_GPIO_Init(BT_BUTTON_GPIO_Port, &GPIO_InitStruct);
  1091.  
  1092.   /*Configure GPIO pin : BT_RESET_Pin */
  1093.   GPIO_InitStruct.Pin = BT_RESET_Pin;
  1094.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  1095.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  1096.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  1097.   HAL_GPIO_Init(BT_RESET_GPIO_Port, &GPIO_InitStruct);
  1098.  
  1099.   /* USER CODE BEGIN MX_GPIO_Init_2 */
  1100.   /* USER CODE END MX_GPIO_Init_2 */
  1101. }
  1102.  
  1103. /* USER CODE BEGIN 4 */
  1104.  
  1105. /* USER CODE END 4 */
  1106.  
  1107. /**
  1108.  * @brief  This function is executed in case of error occurrence.
  1109.  * @retval None
  1110.  */
  1111. void Error_Handler(void)
  1112. {
  1113.   /* USER CODE BEGIN Error_Handler_Debug */
  1114.   /* User can add his own implementation to report the HAL error return state */
  1115.  
  1116.   /* USER CODE END Error_Handler_Debug */
  1117. }
  1118.  
  1119. #ifdef USE_FULL_ASSERT
  1120. /**
  1121.  * @brief  Reports the name of the source file and the source line number
  1122.  *         where the assert_param error has occurred.
  1123.  * @param  file: pointer to the source file name
  1124.  * @param  line: assert_param error line source number
  1125.  * @retval None
  1126.  */
  1127. void assert_failed(uint8_t *file, uint32_t line)
  1128. {
  1129.   /* USER CODE BEGIN 6 */
  1130.   /* User can add his own implementation to report the file name and line number,
  1131.      tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  1132.   /* USER CODE END 6 */
  1133. }
  1134. #endif /* USE_FULL_ASSERT */
  1135.