![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Hardware testing for M24SR-DISCOVERY demo PCB. as help to others
Set up to use MB1138 M24SR-DISCOVERY PCB http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/st25-nfc-rfid-eval-boards/st25-nfc-rfid-eval-boards/m24sr-discovery.html with MBED system. based on https://developer.mbed.org/users/hudakz/code/STM32F103C8T6_Hello/ code and https://developer.mbed.org/users/wim/notebook/m24sr64-nfcrfid-tag-with-i2c-interface/ Which lead me to look at Peter Drescher's work on ILI9341 LCD controller
https://developer.mbed.org/users/dreschpe/code/SPI_TFT_ILI9341/
Diff: mbed-STM32F103RGT6/SysClockConf.cpp
- Revision:
- 2:2033db202017
- Parent:
- 0:ce5a25daadce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-STM32F103RGT6/SysClockConf.cpp Thu Sep 29 11:07:41 2016 +0000 @@ -0,0 +1,79 @@ +/* + ****************************************************************************** + * @file SysClockConf.c + * @author Zoltan Hudak + * @version + * @date 05-July-2016 + * @brief System Clock configuration for STM32F103C8T6 + ****************************************************************************** + * @attention + * + * <h2><center>© COPYRIGHT(c) 2016 Zoltan Hudak <hudakz@inbox.com> + * + * All rights reserved. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "SysClockConf.h" +#include "mbed.h" + +bool HSE_SystemClock_Config(void) { + RCC_OscInitTypeDef RCC_OscInitStruct; + + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; + + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return false; + } + + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + return false; + } + + RCC_PeriphCLKInitTypeDef PeriphClkInit; + + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB; + PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; + PeriphClkInit.UsbClockSelection = RCC_USBPLLCLK_DIV1_5; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { + return false; + } + return true; +} + +bool confSysClock(void) { + HAL_RCC_DeInit(); + if (!HSE_SystemClock_Config()) { + return false; + } + SystemCoreClockUpdate(); + return true; +} + + +