1dcffeb5b0
uart3 --ok
102 lines
2.3 KiB
C
102 lines
2.3 KiB
C
/*
|
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2023-04-27 RealThread first version
|
|
*/
|
|
|
|
#include <rtthread.h>
|
|
#include <board.h>
|
|
#include <drv_common.h>
|
|
|
|
RT_WEAK void rt_hw_board_init()
|
|
{
|
|
extern void hw_board_init(char *clock_src, int32_t clock_src_freq, int32_t clock_target_freq);
|
|
|
|
/* Heap initialization */
|
|
#if defined(RT_USING_HEAP)
|
|
rt_system_heap_init((void *) HEAP_BEGIN, (void *) HEAP_END);
|
|
#endif
|
|
|
|
hw_board_init(BSP_CLOCK_SOURCE, BSP_CLOCK_SOURCE_FREQ_MHZ, BSP_CLOCK_SYSTEM_FREQ_MHZ);
|
|
|
|
/* Set the shell console output device */
|
|
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
#endif
|
|
|
|
/* Board underlying hardware initialization */
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
rt_components_board_init();
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* @brief SPI MSP Initialization
|
|
* This function configures the hardware resources used in this example
|
|
* @param hspi: SPI handle pointer
|
|
* @retval None
|
|
*/
|
|
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
|
{
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
if(hspi->Instance==SPI1)
|
|
{
|
|
/* USER CODE BEGIN SPI1_MspInit 0 */
|
|
|
|
/* USER CODE END SPI1_MspInit 0 */
|
|
/* Peripheral clock enable */
|
|
__HAL_RCC_SPI1_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
/**SPI1 GPIO Configuration
|
|
PB3 ------> SPI1_SCK
|
|
PB4 ------> SPI1_MISO
|
|
PB5 ------> SPI1_MOSI
|
|
*/
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
/* USER CODE BEGIN SPI1_MspInit 1 */
|
|
|
|
/* USER CODE END SPI1_MspInit 1 */
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief ADC MSP Initialization
|
|
* This function configures the hardware resources used in this example
|
|
* @param hadc: ADC handle pointer
|
|
* @retval None
|
|
*/
|
|
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
|
{
|
|
if(hadc->Instance==ADC1)
|
|
{
|
|
/* USER CODE BEGIN ADC1_MspInit 0 */
|
|
|
|
/* USER CODE END ADC1_MspInit 0 */
|
|
/* Peripheral clock enable */
|
|
__HAL_RCC_ADC1_CLK_ENABLE();
|
|
/* USER CODE BEGIN ADC1_MspInit 1 */
|
|
|
|
/* USER CODE END ADC1_MspInit 1 */
|
|
}
|
|
|
|
}
|
|
|