SHARE
TWEET

Untitled

a guest Jan 28th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   ******************************************************************************
  3.   * File Name          : main.c
  4.   * Description        : Main program body
  5.   ******************************************************************************
  6.   *
  7.   * COPYRIGHT(c) 2017 STMicroelectronics
  8.   *
  9.   * Redistribution and use in source and binary forms, with or without modification,
  10.   * are permitted provided that the following conditions are met:
  11.   *   1. Redistributions of source code must retain the above copyright notice,
  12.   *      this list of conditions and the following disclaimer.
  13.   *   2. Redistributions in binary form must reproduce the above copyright notice,
  14.   *      this list of conditions and the following disclaimer in the documentation
  15.   *      and/or other materials provided with the distribution.
  16.   *   3. Neither the name of STMicroelectronics nor the names of its contributors
  17.   *      may be used to endorse or promote products derived from this software
  18.   *      without specific prior written permission.
  19.   *
  20.   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23.   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24.   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25.   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26.   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27.   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28.   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29.   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30.   *
  31.   ******************************************************************************
  32.   */
  33. /* Includes ------------------------------------------------------------------*/
  34. #include "stm32xxx_hal.h"
  35.  
  36. /* USER CODE BEGIN Includes */
  37. #include "main.h"
  38. #include "vl53l1_api.h"
  39. #include "X-NUCLEO-53L1A1.h"
  40. /* USER CODE END Includes */
  41. /* Private variables ---------------------------------------------------------*/
  42. /* USER CODE BEGIN PV */
  43. /* Private variables ---------------------------------------------------------*/
  44. I2C_HandleTypeDef hi2c1;
  45. UART_HandleTypeDef huart2;
  46. VL53L1_Dev_t                   devCenter;
  47. VL53L1_Dev_t                   devLeft;
  48. VL53L1_Dev_t                   devRight;
  49. VL53L1_DEV                     Dev = &devCenter;
  50. uint32_t status;
  51. volatile int IntCount;
  52. #define isAutonomousExample 1  /* Allow to select either autonomous ranging or fast ranging example */
  53. #define isInterrupt 0 /* If isInterrupt = 1 then device working in interrupt mode, else device working in polling mode */
  54. uint32_t tabResults [3];
  55. /* USER CODE END PV */
  56.  
  57. /* Private function prototypes -----------------------------------------------*/
  58. /* USER CODE BEGIN PFP */
  59. /* Private function prototypes -----------------------------------------------*/
  60. void SystemClock_Config(void);
  61. void Error_Handler(void);
  62. static void MX_GPIO_Init(void);
  63. static void MX_USART2_UART_Init(void);
  64. static void MX_I2C1_Init(void);
  65. void AutonomousLowPowerRangingTest(void); /* see Autonomous ranging example implementation in USER CODE BEGIN 4 section */
  66. /* USER CODE END PFP */
  67.  
  68. /* USER CODE BEGIN 0 */
  69. #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
  70.  
  71. PUTCHAR_PROTOTYPE
  72. {
  73.     HAL_UART_Transmit(&huart2, (uint8_t*)&ch, 1, 0xFFFF);
  74.   return ch;
  75. }
  76.  
  77. void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
  78. {
  79.         if (GPIO_Pin==VL53L1X_INT_Pin)
  80.         {
  81.             IntCount++;
  82.         }
  83. }
  84.  
  85. /* USER CODE END 0 */
  86.  
  87. int main(void)
  88. {
  89.   /* USER CODE BEGIN 1 */
  90.  
  91.     uint16_t wordData;
  92.   uint8_t ToFSensor = 1; // 0=Left, 1=Center(default), 2=Right
  93.     static VL53L1_RangingMeasurementData_t RangingData;
  94.     uint8_t newI2C = 0x52;
  95.  
  96.   /* MCU Configuration----------------------------------------------------------*/
  97.  
  98.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  99.   HAL_Init();
  100.  
  101.   /* Configure the system clock */
  102.   SystemClock_Config();
  103.  
  104.   /* Initialize all configured peripherals */
  105.   MX_GPIO_Init();
  106.  
  107.   MX_USART2_UART_Init();
  108.  
  109.     MX_I2C1_Init();
  110.  
  111.   XNUCLEO53L1A1_Init();
  112.    
  113.     /* USER CODE END 1 */
  114.  
  115.     /* USER CODE BEGIN 2 */
  116.  
  117. /* An example here below shows how to manage multi-sensor operation.
  118. In this example the sensors range sequentially. Several sensors range simultanously is also possible */
  119.  
  120. /* Reset the 3 ToF sensors on the expansion board */
  121.     for (ToFSensor=0;ToFSensor<3;ToFSensor++){
  122.         status = XNUCLEO53L1A1_ResetId(ToFSensor, 0);
  123.     }
  124.  
  125. /* Bring the sensors out of the reset stage one by one and set the new I2C address */
  126.     for (ToFSensor=0;ToFSensor<3;ToFSensor++){
  127.         switch(ToFSensor){
  128.             case 0:
  129.                 Dev=&devLeft;
  130.                 break;
  131.             case 1:
  132.                 Dev=&devCenter;
  133.                 break;
  134.             case 2:
  135.                 Dev=&devRight;
  136.                 break;     
  137.         }
  138.         status = XNUCLEO53L1A1_ResetId(ToFSensor, 1);
  139.         Dev->comms_speed_khz = 400;
  140.         Dev->I2cHandle = &hi2c1;
  141.         Dev->comms_type = 1;
  142.         Dev->I2cDevAddr=0x52; /* default ToF sensor I2C address*/
  143.         VL53L1_RdWord(Dev, 0x010F, &wordData);
  144.         printf("VL53L1X: %02X\n\r", wordData);
  145.         newI2C = Dev->I2cDevAddr + (ToFSensor+1)*2;
  146.         status = VL53L1_SetDeviceAddress(Dev, newI2C);
  147.         Dev->I2cDevAddr=newI2C;
  148.         VL53L1_RdWord(Dev, 0x010F, &wordData);
  149.         printf("VL53L1X: %02X\n\r", wordData);
  150. /* Device Initialization and setting */
  151.         status = VL53L1_WaitDeviceBooted(Dev); 
  152.         status = VL53L1_DataInit(Dev);
  153.         status = VL53L1_StaticInit(Dev);
  154.         status = VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);
  155.         status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 50000);
  156.         status = VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 100);
  157.     }
  158. /* Sequential ranging loop */
  159.     while(1){
  160.         for (ToFSensor=0;ToFSensor<3;ToFSensor++){
  161.             switch(ToFSensor){
  162.                 case 0:
  163.                     Dev=&devLeft;
  164.                     break;
  165.                 case 1:
  166.                     Dev=&devCenter;
  167.                     break;
  168.                 case 2:
  169.                     Dev=&devRight;
  170.                     break;
  171.             }
  172.             status = VL53L1_StartMeasurement(Dev);
  173.           status = VL53L1_WaitMeasurementDataReady(Dev);
  174.             if(!status)
  175.             {
  176.                 status = VL53L1_GetRangingMeasurementData(Dev, &RangingData);
  177.  
  178.             }
  179.             tabResults[ToFSensor] = RangingData.RangeMilliMeter;
  180.             status = VL53L1_ClearInterruptAndStartMeasurement(Dev);
  181.         }
  182.         printf("%u\t%u\t%u\n", tabResults[0], tabResults[1], tabResults[2]);
  183.     }
  184.   /* USER CODE END 2 */
  185.  
  186.   /* Infinite loop */
  187.   /* USER CODE BEGIN WHILE */
  188.   /* USER CODE END 3 */
  189.  
  190. }
  191.  
  192. /** System Clock Configuration
  193. */
  194. #ifdef STM32F401xE
  195.  
  196. void SystemClock_Config(void)
  197. {
  198.  
  199.   RCC_OscInitTypeDef RCC_OscInitStruct;
  200.   RCC_ClkInitTypeDef RCC_ClkInitStruct;
  201.  
  202.     /**Configure the main internal regulator output voltage
  203.     */
  204.   __HAL_RCC_PWR_CLK_ENABLE();
  205.  
  206.   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
  207.  
  208.     /**Initializes the CPU, AHB and APB busses clocks
  209.     */
  210.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  211.   RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  212.   RCC_OscInitStruct.HSICalibrationValue = 16;
  213.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  214.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  215.   RCC_OscInitStruct.PLL.PLLM = 16;
  216.   RCC_OscInitStruct.PLL.PLLN = 336;
  217.   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
  218.   RCC_OscInitStruct.PLL.PLLQ = 7;
  219.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  220.   {
  221.     Error_Handler();
  222.   }
  223.  
  224.     /**Initializes the CPU, AHB and APB busses clocks
  225.     */
  226.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  227.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  228.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  229.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  230.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  231.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  232.  
  233.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  234.   {
  235.     Error_Handler();
  236.   }
  237.  
  238.     /**Configure the Systick interrupt time
  239.     */
  240.   HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
  241.  
  242.     /**Configure the Systick
  243.     */
  244.   HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
  245.  
  246.   /* SysTick_IRQn interrupt configuration */
  247.   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  248. }
  249. #endif
  250.  
  251. #ifdef STM32L476xx
  252. void SystemClock_Config(void)
  253. {
  254.  
  255.   RCC_OscInitTypeDef RCC_OscInitStruct;
  256.   RCC_ClkInitTypeDef RCC_ClkInitStruct;
  257.   RCC_PeriphCLKInitTypeDef PeriphClkInit;
  258.  
  259.     /**Initializes the CPU, AHB and APB busses clocks
  260.     */
  261.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  262.   RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  263.   RCC_OscInitStruct.HSICalibrationValue = 16;
  264.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  265.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  266.   RCC_OscInitStruct.PLL.PLLM = 1;
  267.   RCC_OscInitStruct.PLL.PLLN = 10;
  268.   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
  269.   RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
  270.   RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  271.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  272.   {
  273.     Error_Handler();
  274.   }
  275.  
  276.     /**Initializes the CPU, AHB and APB busses clocks
  277.     */
  278.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  279.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  280.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  281.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  282.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  283.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  284.  
  285.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
  286.   {
  287.     Error_Handler();
  288.   }
  289.  
  290.   PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_I2C1;
  291.   PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
  292.   PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
  293.   if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  294.   {
  295.     Error_Handler();
  296.   }
  297.  
  298.     /**Configure the main internal regulator output voltage
  299.     */
  300.   if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
  301.   {
  302.     Error_Handler();
  303.   }
  304.  
  305.     /**Configure the Systick interrupt time
  306.     */
  307.   HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
  308.  
  309.     /**Configure the Systick
  310.     */
  311.   HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
  312.  
  313.   /* SysTick_IRQn interrupt configuration */
  314.   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  315. }
  316. #endif
  317. #ifdef STM32F401xE
  318.  
  319. /* I2C1 init function */
  320. static void MX_I2C1_Init(void)
  321. {
  322.  
  323.   hi2c1.Instance = I2C1;
  324.   hi2c1.Init.ClockSpeed = 100000;
  325.   hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  326.   hi2c1.Init.OwnAddress1 = 0;
  327.   hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  328.   hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  329.   hi2c1.Init.OwnAddress2 = 0;
  330.   hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  331.   hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  332.   if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  333.   {
  334.     Error_Handler();
  335.   }
  336.  
  337. }
  338. #endif
  339. #ifdef STM32L476xx
  340. /* I2C1 init function */
  341. static void MX_I2C1_Init(void)
  342. {
  343.  
  344.   hi2c1.Instance = I2C1;
  345.   hi2c1.Init.Timing = 0x10909CEC;
  346.   hi2c1.Init.OwnAddress1 = 0;
  347.   hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  348.   hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  349.   hi2c1.Init.OwnAddress2 = 0;
  350.   hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
  351.   hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  352.   hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  353.   if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  354.   {
  355.     Error_Handler();
  356.   }
  357.  
  358.     /**Configure Analogue filter
  359.     */
  360.   if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
  361.   {
  362.     Error_Handler();
  363.   }
  364.  
  365.     /**Configure Digital filter
  366.     */
  367.   if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
  368.   {
  369.     Error_Handler();
  370.   }
  371.  
  372. }
  373. #endif
  374. /* USART2 init function */
  375. static void MX_USART2_UART_Init(void)
  376. {
  377.  
  378.   huart2.Instance = USART2;
  379.   huart2.Init.BaudRate = 115200;
  380.   huart2.Init.WordLength = UART_WORDLENGTH_8B;
  381.   huart2.Init.StopBits = UART_STOPBITS_1;
  382.   huart2.Init.Parity = UART_PARITY_NONE;
  383.   huart2.Init.Mode = UART_MODE_TX_RX;
  384.   huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  385.   huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  386.   if (HAL_UART_Init(&huart2) != HAL_OK)
  387.   {
  388.     Error_Handler();
  389.   }
  390.  
  391. }
  392.  
  393. /** Configure pins as
  394.         * Analog
  395.         * Input
  396.         * Output
  397.         * EVENT_OUT
  398.         * EXTI
  399. */
  400. static void MX_GPIO_Init(void)
  401. {
  402.  
  403.   GPIO_InitTypeDef GPIO_InitStruct;
  404.  
  405.   /* GPIO Ports Clock Enable */
  406.   __HAL_RCC_GPIOC_CLK_ENABLE();
  407.   __HAL_RCC_GPIOH_CLK_ENABLE();
  408.   __HAL_RCC_GPIOA_CLK_ENABLE();
  409.   __HAL_RCC_GPIOB_CLK_ENABLE();
  410.  
  411.   /*Configure GPIO pin Output Level */
  412.   HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
  413.  
  414.   /*Configure GPIO pin : B1_Pin */
  415.   GPIO_InitStruct.Pin = B1_Pin;
  416.   GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
  417.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  418.   HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
  419.  
  420.   /*Configure GPIO pin : VL53L1X_INT_Pin */
  421.   GPIO_InitStruct.Pin = VL53L1X_INT_Pin;
  422.   GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
  423.   GPIO_InitStruct.Pull = GPIO_PULLUP;
  424.   HAL_GPIO_Init(VL53L1X_INT_GPIO_Port, &GPIO_InitStruct);
  425.  
  426.   /*Configure GPIO pin : LD2_Pin */
  427.   GPIO_InitStruct.Pin = LD2_Pin;
  428.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  429.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  430.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  431.   HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
  432.  
  433.   /* EXTI interrupt init*/
  434.   HAL_NVIC_SetPriority(EXTI4_IRQn, 0, 0);
  435.   HAL_NVIC_EnableIRQ(EXTI4_IRQn);
  436.  
  437. }
  438.  
  439. /* USER CODE BEGIN 4 */
  440.  
  441. /* Autonomous ranging loop*/
  442. void AutonomousLowPowerRangingTest(void)
  443. {
  444.   static VL53L1_RangingMeasurementData_t RangingData;
  445.   status = VL53L1_WaitDeviceBooted(Dev);
  446.   status = VL53L1_DataInit(Dev);
  447.   status = VL53L1_StaticInit(Dev);
  448.   status = VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);
  449.   status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 50000);
  450.   status = VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 500);
  451.   status = VL53L1_StartMeasurement(Dev);
  452.  
  453.     if(status){
  454.         printf("VL53L1_StartMeasurement failed \n");
  455.         while(1);
  456.     }  
  457.     if (isInterrupt){
  458.         do // interrupt mode
  459.         {
  460.          __WFI();
  461.          if(IntCount !=0 ){
  462.                 IntCount=0;
  463.                 status = VL53L1_GetRangingMeasurementData(Dev, &RangingData);
  464.                 if(status==0){
  465.                     printf("%d,%d,%.2f,%.2f\n", RangingData.RangeStatus,RangingData.RangeMilliMeter,
  466.                                     RangingData.SignalRateRtnMegaCps/65536.0,RangingData.AmbientRateRtnMegaCps/65336.0);
  467.                 }
  468.                 status = VL53L1_ClearInterruptAndStartMeasurement(Dev);
  469.             }
  470.         }
  471.         while(1);
  472.     }
  473.     else{
  474.         do // polling mode
  475.         {
  476.           status = VL53L1_WaitMeasurementDataReady(Dev);
  477.             if(!status)
  478.             {
  479.                 status = VL53L1_GetRangingMeasurementData(Dev, &RangingData);
  480.                 if(status==0){
  481.                     printf("%d,%d,%.2f,%.2f\n", RangingData.RangeStatus,RangingData.RangeMilliMeter,
  482.                                     (RangingData.SignalRateRtnMegaCps/65536.0),RangingData.AmbientRateRtnMegaCps/65336.0);
  483.                 }
  484.                 status = VL53L1_ClearInterruptAndStartMeasurement(Dev);
  485.             }
  486.         }
  487.         while (1);
  488.     }
  489. //  return status;
  490. }
  491.  
  492. /* USER CODE END 4 */
  493.  
  494. /**
  495.   * @brief  This function is executed in case of error occurrence.
  496.   * @param  None
  497.   * @retval None
  498.   */
  499. void Error_Handler(void)
  500. {
  501.   /* USER CODE BEGIN Error_Handler */
  502.   /* User can add his own implementation to report the HAL error return state */
  503.   while(1)
  504.   {
  505.   }
  506.   /* USER CODE END Error_Handler */
  507. }
  508.  
  509. #ifdef USE_FULL_ASSERT
  510.  
  511. /**
  512.    * @brief Reports the name of the source file and the source line number
  513.    * where the assert_param error has occurred.
  514.    * @param file: pointer to the source file name
  515.    * @param line: assert_param error line source number
  516.    * @retval None
  517.    */
  518. void assert_failed(uint8_t* file, uint32_t line)
  519. {
  520.   /* USER CODE BEGIN 6 */
  521.   /* User can add his own implementation to report the file name and line number,
  522.     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  523.   /* USER CODE END 6 */
  524.  
  525. }
  526.  
  527. #endif
  528.  
  529. /**
  530.   * @}
  531.   */
  532.  
  533. /**
  534.   * @}
  535. */
  536.  
  537. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top