code for read VL53l0x sensor with CAN

Dependencies:   mbed

Committer:
pablo_bmxrp
Date:
Mon Mar 18 22:36:03 2019 +0000
Revision:
0:44429c0a71d4
adicionado CAN

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pablo_bmxrp 0:44429c0a71d4 1 /*
pablo_bmxrp 0:44429c0a71d4 2 ******************************************************************************
pablo_bmxrp 0:44429c0a71d4 3 * @file SysClockConf.c
pablo_bmxrp 0:44429c0a71d4 4 * @author Zoltan Hudak
pablo_bmxrp 0:44429c0a71d4 5 * @version
pablo_bmxrp 0:44429c0a71d4 6 * @date 05-July-2016
pablo_bmxrp 0:44429c0a71d4 7 * @brief System Clock configuration for STM32F103C8T6
pablo_bmxrp 0:44429c0a71d4 8 ******************************************************************************
pablo_bmxrp 0:44429c0a71d4 9 * @attention
pablo_bmxrp 0:44429c0a71d4 10 *
pablo_bmxrp 0:44429c0a71d4 11 * <h2><center>&copy; COPYRIGHT(c) 2016 Zoltan Hudak <hudakz@outlook.com>
pablo_bmxrp 0:44429c0a71d4 12 *
pablo_bmxrp 0:44429c0a71d4 13 * All rights reserved.
pablo_bmxrp 0:44429c0a71d4 14
pablo_bmxrp 0:44429c0a71d4 15 This program is free software: you can redistribute it and/or modify
pablo_bmxrp 0:44429c0a71d4 16 it under the terms of the GNU General Public License as published by
pablo_bmxrp 0:44429c0a71d4 17 the Free Software Foundation, either version 3 of the License, or
pablo_bmxrp 0:44429c0a71d4 18 (at your option) any later version.
pablo_bmxrp 0:44429c0a71d4 19
pablo_bmxrp 0:44429c0a71d4 20 This program is distributed in the hope that it will be useful,
pablo_bmxrp 0:44429c0a71d4 21 but WITHOUT ANY WARRANTY; without even the implied warranty of
pablo_bmxrp 0:44429c0a71d4 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pablo_bmxrp 0:44429c0a71d4 23 GNU General Public License for more details.
pablo_bmxrp 0:44429c0a71d4 24
pablo_bmxrp 0:44429c0a71d4 25 You should have received a copy of the GNU General Public License
pablo_bmxrp 0:44429c0a71d4 26 along with this program. If not, see <http://www.gnu.org/licenses/>.
pablo_bmxrp 0:44429c0a71d4 27 */
pablo_bmxrp 0:44429c0a71d4 28
pablo_bmxrp 0:44429c0a71d4 29 #include "SysClockConf.h"
pablo_bmxrp 0:44429c0a71d4 30 #include "mbed.h"
pablo_bmxrp 0:44429c0a71d4 31
pablo_bmxrp 0:44429c0a71d4 32 void HSE_SystemClock_Config(void) {
pablo_bmxrp 0:44429c0a71d4 33 RCC_OscInitTypeDef RCC_OscInitStruct;
pablo_bmxrp 0:44429c0a71d4 34 RCC_ClkInitTypeDef RCC_ClkInitStruct;
pablo_bmxrp 0:44429c0a71d4 35 RCC_PeriphCLKInitTypeDef PeriphClkInit;
pablo_bmxrp 0:44429c0a71d4 36
pablo_bmxrp 0:44429c0a71d4 37 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
pablo_bmxrp 0:44429c0a71d4 38 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
pablo_bmxrp 0:44429c0a71d4 39 RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
pablo_bmxrp 0:44429c0a71d4 40 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
pablo_bmxrp 0:44429c0a71d4 41 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
pablo_bmxrp 0:44429c0a71d4 42 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
pablo_bmxrp 0:44429c0a71d4 43 HAL_RCC_OscConfig(&RCC_OscInitStruct);
pablo_bmxrp 0:44429c0a71d4 44 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
pablo_bmxrp 0:44429c0a71d4 45 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
pablo_bmxrp 0:44429c0a71d4 46 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
pablo_bmxrp 0:44429c0a71d4 47 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
pablo_bmxrp 0:44429c0a71d4 48 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
pablo_bmxrp 0:44429c0a71d4 49 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
pablo_bmxrp 0:44429c0a71d4 50 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB;
pablo_bmxrp 0:44429c0a71d4 51 PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
pablo_bmxrp 0:44429c0a71d4 52 PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
pablo_bmxrp 0:44429c0a71d4 53 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
pablo_bmxrp 0:44429c0a71d4 54 }
pablo_bmxrp 0:44429c0a71d4 55
pablo_bmxrp 0:44429c0a71d4 56 void confSysClock(void) {
pablo_bmxrp 0:44429c0a71d4 57 HAL_RCC_DeInit();
pablo_bmxrp 0:44429c0a71d4 58 HSE_SystemClock_Config();
pablo_bmxrp 0:44429c0a71d4 59 SystemCoreClockUpdate();
pablo_bmxrp 0:44429c0a71d4 60 }