added BSP folder content
This commit is contained in:
7
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/CMakeLists.txt
Normal file
7
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
freertos.c
|
||||
hardware_init.c
|
||||
stm32h7xx_hal_timebase_tim.c
|
||||
stm32h7xx_it.c
|
||||
syscalls.c
|
||||
)
|
79
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/freertos.c
Normal file
79
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/freertos.c
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : freertos.c
|
||||
* Description : Code for freertos applications
|
||||
******************************************************************************
|
||||
* This notice applies to any and all portions of this file
|
||||
* that are not between comment pairs USER CODE BEGIN and
|
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools
|
||||
* are owned by their respective copyright owners.
|
||||
*
|
||||
* Copyright (c) 2018 STMicroelectronics International N.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include <portmacro.h>
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
void vRequestContextSwitchFromISR() {
|
||||
portYIELD_FROM_ISR(pdTRUE);
|
||||
}
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Variables -----------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Variables */
|
||||
|
||||
/* USER CODE END Variables */
|
||||
|
||||
/* Function prototypes -------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN FunctionPrototypes */
|
||||
|
||||
/* USER CODE END FunctionPrototypes */
|
||||
|
||||
/* Hook prototypes */
|
||||
|
||||
/* USER CODE BEGIN Application */
|
||||
|
||||
/* USER CODE END Application */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
267
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/hardware_init.c
Normal file
267
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/hardware_init.c
Normal file
@ -0,0 +1,267 @@
|
||||
#include "hardware_init.h"
|
||||
|
||||
#include <stm32h743xx.h>
|
||||
#include <stm32h7xx_hal_rcc_ex.h>
|
||||
#include <stm32h7xx_nucleo.h>
|
||||
|
||||
#include <app_ethernet.h>
|
||||
#include <common/stm32_nucleo/networking/ethernetif.h>
|
||||
#include <lwip/netif.h>
|
||||
#include <lwip/init.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include <netif/ethernet.h>
|
||||
|
||||
#include <boardconfig.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Forward declarations */
|
||||
void MPU_Config(void);
|
||||
void SystemClock_Config(void);
|
||||
void BSP_Config(void);
|
||||
void CPU_CACHE_Enable(void);
|
||||
void MX_USART3_UART_Init(uint32_t baudRate);
|
||||
|
||||
/**
|
||||
* ST-LINK UART3
|
||||
* CN5 pins on board
|
||||
*/
|
||||
UART_HandleTypeDef huart3;
|
||||
GPIO_InitTypeDef gpio_uart_init_struct;
|
||||
struct netif gnetif;
|
||||
bool debugAvailable = false;
|
||||
|
||||
void performHardwareInit() {
|
||||
/* Configure the MPU attributes as Device memory for ETH DMA descriptors */
|
||||
MPU_Config();
|
||||
|
||||
/* Enable the CPU Cache */
|
||||
CPU_CACHE_Enable();
|
||||
|
||||
MX_USART3_UART_Init(DEBUG_UART_BAUDRATE);
|
||||
|
||||
HAL_StatusTypeDef retval = HAL_Init();
|
||||
if(retval != HAL_OK) {
|
||||
printf("Error: HAL initialization failed!\n\r");
|
||||
}
|
||||
|
||||
/* Configure the system clock to 400 MHz */
|
||||
SystemClock_Config();
|
||||
|
||||
BSP_Config();
|
||||
}
|
||||
void MX_USART3_UART_Init(uint32_t baudRate)
|
||||
{
|
||||
__HAL_RCC_USART3_CONFIG(RCC_USART3CLKSOURCE_HSI);
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_USART3_CLK_ENABLE();
|
||||
/*Configure GPIO pins : PD8 PD9 */
|
||||
gpio_uart_init_struct.Pin = GPIO_PIN_8|GPIO_PIN_9;
|
||||
gpio_uart_init_struct.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_uart_init_struct.Pull = GPIO_NOPULL;
|
||||
gpio_uart_init_struct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
gpio_uart_init_struct.Alternate = GPIO_AF7_USART3;
|
||||
HAL_GPIO_Init(GPIOD, &gpio_uart_init_struct);
|
||||
|
||||
int result;
|
||||
huart3.Instance = USART3;
|
||||
huart3.Init.BaudRate = baudRate;
|
||||
huart3.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart3.Init.StopBits = UART_STOPBITS_1;
|
||||
huart3.Init.Parity = UART_PARITY_NONE;
|
||||
huart3.Init.Mode = UART_MODE_TX_RX;
|
||||
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
||||
huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
|
||||
//huart3.Init.FIFOMode = UART_FIFOMODE_DISABLE;
|
||||
//huart3.Init.TXFIFOThreshold = UART_TXFIFO_THRESHOLD_1_8;
|
||||
//huart3.Init.RXFIFOThreshold = UART_RXFIFO_THRESHOLD_1_8;
|
||||
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||
// we can't do error handling (simple print out first) here because UART3 is our print interface
|
||||
result = HAL_UART_Init(&huart3);
|
||||
if(result == HAL_OK) {
|
||||
//print_uart3("\rUART3 configured successfully !\r\n\0");
|
||||
debugAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* The system Clock is configured as follow :
|
||||
* System Clock source = PLL (HSE BYPASS)
|
||||
* SYSCLK(Hz) = 400000000 (CPU Clock)
|
||||
* HCLK(Hz) = 200000000 (AXI and AHBs Clock)
|
||||
* AHB Prescaler = 2
|
||||
* D1 APB3 Prescaler = 2 (APB3 Clock 100MHz)
|
||||
* D2 APB1 Prescaler = 2 (APB1 Clock 100MHz)
|
||||
* D2 APB2 Prescaler = 2 (APB2 Clock 100MHz)
|
||||
* D3 APB4 Prescaler = 2 (APB4 Clock 100MHz)
|
||||
* HSE Frequency(Hz) = 8000000
|
||||
* PLL_M = 4
|
||||
* PLL_N = 400
|
||||
* PLL_P = 2
|
||||
* PLL_Q = 4
|
||||
* PLL_R = 2
|
||||
* VDD(V) = 3.3
|
||||
* Flash Latency(WS) = 4
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
HAL_StatusTypeDef ret = HAL_OK;
|
||||
|
||||
/*!< Supply configuration update enable */
|
||||
MODIFY_REG(PWR->CR3, PWR_CR3_SCUEN, 0); // @suppress("Field cannot be resolved")
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); // @suppress("Field cannot be resolved")
|
||||
|
||||
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} // @suppress("Field cannot be resolved")
|
||||
|
||||
/* Enable D2 domain SRAM3 Clock (0x30040000 AXI)*/
|
||||
__HAL_RCC_D2SRAM3_CLK_ENABLE(); // @suppress("Field cannot be resolved")
|
||||
|
||||
/* Enable HSE Oscillator and activate PLL with HSE as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
|
||||
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
|
||||
RCC_OscInitStruct.PLL.PLLM = 4;
|
||||
RCC_OscInitStruct.PLL.PLLN = 400;
|
||||
RCC_OscInitStruct.PLL.PLLP = 2;
|
||||
RCC_OscInitStruct.PLL.PLLR = 2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 4;
|
||||
|
||||
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
|
||||
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
|
||||
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||
if(ret != HAL_OK)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
/* Select PLL as system clock source and configure bus clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
|
||||
RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 |
|
||||
RCC_CLOCKTYPE_D3PCLK1);
|
||||
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
|
||||
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
|
||||
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
|
||||
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
|
||||
if(ret != HAL_OK)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*Configure the MPU attributes */
|
||||
void MPU_Config(void)
|
||||
{
|
||||
MPU_Region_InitTypeDef MPU_InitStruct;
|
||||
|
||||
/* Disable the MPU */
|
||||
HAL_MPU_Disable();
|
||||
|
||||
/* Configure the MPU attributes as Device not cacheable
|
||||
for ETH DMA descriptors */
|
||||
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
|
||||
MPU_InitStruct.BaseAddress = 0x30040000;
|
||||
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
|
||||
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
|
||||
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
|
||||
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
|
||||
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
|
||||
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
|
||||
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
|
||||
MPU_InitStruct.SubRegionDisable = 0x00;
|
||||
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
|
||||
|
||||
HAL_MPU_ConfigRegion(&MPU_InitStruct);
|
||||
|
||||
/* Configure the MPU attributes as Cacheable write through
|
||||
for LwIP RAM heap which contains the Tx buffers */
|
||||
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
|
||||
MPU_InitStruct.BaseAddress = 0x30044000;
|
||||
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
|
||||
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
|
||||
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
|
||||
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
|
||||
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
|
||||
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
|
||||
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
|
||||
MPU_InitStruct.SubRegionDisable = 0x00;
|
||||
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
|
||||
|
||||
HAL_MPU_ConfigRegion(&MPU_InitStruct);
|
||||
|
||||
/* Enable the MPU */
|
||||
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
|
||||
}
|
||||
|
||||
/*CPU L1-Cache enable*/
|
||||
void CPU_CACHE_Enable(void)
|
||||
{
|
||||
/* Enable I-Cache */
|
||||
SCB_EnableICache();
|
||||
|
||||
/* Enable D-Cache */
|
||||
SCB_EnableDCache();
|
||||
}
|
||||
|
||||
void BSP_Config(void)
|
||||
{
|
||||
BSP_LED_Init(LED1);
|
||||
BSP_LED_Init(LED2);
|
||||
BSP_LED_Init(LED3);
|
||||
}
|
||||
|
||||
|
||||
void Netif_Config(void)
|
||||
{
|
||||
ip_addr_t ipaddr;
|
||||
ip_addr_t netmask;
|
||||
ip_addr_t gw;
|
||||
#if LWIP_DHCP
|
||||
ip_addr_set_zero_ip4(&ipaddr);
|
||||
ip_addr_set_zero_ip4(&netmask);
|
||||
ip_addr_set_zero_ip4(&gw);
|
||||
#else
|
||||
|
||||
/* IP address default setting */
|
||||
set_lwip_addresses(&ipaddr, &netmask, &gw);
|
||||
|
||||
#endif
|
||||
|
||||
/* add the network interface */
|
||||
struct netif* netif_valid = netif_add(&gnetif, (ip4_addr_t*)&ipaddr,
|
||||
(ip4_addr_t*)&netmask, (ip4_addr_t*) &gw, NULL, ðernetif_init,
|
||||
ðernet_input);
|
||||
if(netif_valid == NULL) {
|
||||
printf("Error: netif initialization failed!\n\r");
|
||||
return;
|
||||
}
|
||||
/* Registers the default network interface */
|
||||
netif_set_default(&gnetif);
|
||||
|
||||
ethernet_link_status_updated(&gnetif);
|
||||
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,168 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h7xx_hal_timebase_tim.c
|
||||
* @author MCD Application Team
|
||||
* @brief HAL time base based on the hardware TIM.
|
||||
*
|
||||
* This file overrides the native HAL time base functions (defined as weak)
|
||||
* the TIM time base:
|
||||
* + Intializes the TIM peripheral generate a Period elapsed Event each 1ms
|
||||
* + HAL_IncTick is called inside HAL_TIM_PeriodElapsedCallback ie each 1ms
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
TIM_HandleTypeDef TimHandle;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
void TIM6_DAC_IRQHandler(void);
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief This function configures the TIM6 as a time base source.
|
||||
* The time source is configured to have 1ms time base with a dedicated
|
||||
* Tick interrupt priority.
|
||||
* @note This function is called automatically at the beginning of program after
|
||||
* reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
|
||||
* @param TickPriority: Tick interrupt priority.
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
|
||||
{
|
||||
RCC_ClkInitTypeDef clkconfig;
|
||||
uint32_t uwTimclock, uwAPB1Prescaler = 0U;
|
||||
uint32_t uwPrescalerValue = 0U;
|
||||
uint32_t pFLatency;
|
||||
|
||||
/*Configure the TIM6 IRQ priority */
|
||||
HAL_NVIC_SetPriority(TIM6_DAC_IRQn, TickPriority ,0U);
|
||||
|
||||
/* Enable the TIM6 global Interrupt */
|
||||
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
|
||||
|
||||
/* Enable TIM6 clock */
|
||||
__HAL_RCC_TIM6_CLK_ENABLE();
|
||||
|
||||
/* Get clock configuration */
|
||||
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
|
||||
|
||||
/* Get APB1 prescaler */
|
||||
uwAPB1Prescaler = clkconfig.APB1CLKDivider;
|
||||
|
||||
/* Compute TIM6 clock */
|
||||
if (uwAPB1Prescaler == RCC_HCLK_DIV1)
|
||||
{
|
||||
uwTimclock = HAL_RCC_GetPCLK1Freq();
|
||||
}
|
||||
else
|
||||
{
|
||||
uwTimclock = 2*HAL_RCC_GetPCLK1Freq();
|
||||
}
|
||||
|
||||
/* Compute the prescaler value to have TIM6 counter clock equal to 1MHz */
|
||||
uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
|
||||
|
||||
/* Initialize TIM6 */
|
||||
TimHandle.Instance = TIM6;
|
||||
|
||||
/* Initialize TIMx peripheral as follow:
|
||||
+ Period = [(TIM6CLK/1000) - 1]. to have a (1/1000) s time base.
|
||||
+ Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
|
||||
+ ClockDivision = 0
|
||||
+ Counter direction = Up
|
||||
*/
|
||||
TimHandle.Init.Period = (1000000U / 1000U) - 1U;
|
||||
TimHandle.Init.Prescaler = uwPrescalerValue;
|
||||
TimHandle.Init.ClockDivision = 0;
|
||||
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
if(HAL_TIM_Base_Init(&TimHandle) == HAL_OK)
|
||||
{
|
||||
/* Start the TIM time Base generation in interrupt mode */
|
||||
return HAL_TIM_Base_Start_IT(&TimHandle);
|
||||
}
|
||||
|
||||
/* Return function status */
|
||||
return HAL_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Suspend Tick increment.
|
||||
* @note Disable the tick increment by disabling TIM6 update interrupt.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SuspendTick(void)
|
||||
{
|
||||
/* Disable TIM6 update Interrupt */
|
||||
__HAL_TIM_DISABLE_IT(&TimHandle, TIM_IT_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resume Tick increment.
|
||||
* @note Enable the tick increment by Enabling TIM6 update interrupt.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_ResumeTick(void)
|
||||
{
|
||||
/* Enable TIM6 Update interrupt */
|
||||
__HAL_TIM_ENABLE_IT(&TimHandle, TIM_IT_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @note This function is called when TIM6 interrupt took place, inside
|
||||
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||
* a global variable "uwTick" used as application time base.
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
HAL_IncTick();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void TIM6_DAC_IRQHandler(void)
|
||||
{
|
||||
HAL_TIM_IRQHandler(&TimHandle);
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
162
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/stm32h7xx_it.c
Normal file
162
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/stm32h7xx_it.c
Normal file
@ -0,0 +1,162 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file LwIP/LwIP_HTTP_Server_Netconn_RTOS/Src/stm32h7xx_it.c
|
||||
* @author MCD Application Team
|
||||
* @brief Main Interrupt Service Routines.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h7xx_it.h"
|
||||
|
||||
#include "cmsis_os.h"
|
||||
#include "main.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
extern ETH_HandleTypeDef EthHandle;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
void ETH_IRQHandler(void);
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M7 Processor Exceptions Handlers */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles NMI exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Hard Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Memory Manage exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Memory Manage exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Bus Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Bus Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Usage Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Usage Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug Monitor exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SysTick Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
osSystickHandler();
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32H7xx Peripherals Interrupt Handlers */
|
||||
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
|
||||
/* available peripheral interrupt handler's name please refer to the startup */
|
||||
/* file (startup_stm32h7xx.s). */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Ethernet interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void ETH_IRQHandler(void)
|
||||
{
|
||||
HAL_ETH_IRQHandler(&EthHandle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
154
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/syscalls.c
Normal file
154
bsp_stm32h7_freertos/NUCLEO-H743ZI/Src/syscalls.c
Normal file
@ -0,0 +1,154 @@
|
||||
/*!
|
||||
* @file syscalls.c
|
||||
* Implements some base-level for libc for heap management and printing on
|
||||
* the debug port.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <hardware_init.h>
|
||||
#include <boardconfig.h>
|
||||
|
||||
|
||||
#define AUTO_RETURN_AFTER_NEWLINE 1
|
||||
|
||||
// _write currently adds \n after \r automatically.
|
||||
// If the At91lib\utility\stdio.c printf implementation is not used anymore:
|
||||
// remove if there are spurious newlines!
|
||||
|
||||
//int _read(int file, void *ptr, size_t len) {
|
||||
// (void)len;
|
||||
// if(file <= STDERR_FILENO) {
|
||||
// *(char *) ptr = DBGU_GetChar();
|
||||
//#if AUTO_RETURN_AFTER_NEWLINE
|
||||
// if((*(char *) ptr != '\n') && (*(char *) ptr != '\r')) {
|
||||
// DBGU_PutChar(*(char *) ptr);
|
||||
// }
|
||||
// else if(*(char *) ptr == '\r') {
|
||||
// DBGU_PutChar('\n');
|
||||
// DBGU_PutChar('\r');
|
||||
// }
|
||||
//#endif
|
||||
// return 1;
|
||||
// }
|
||||
// else {
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
int _write(int file, const void *ptr, size_t len) {
|
||||
size_t i;
|
||||
|
||||
if(file <= STDERR_FILENO) {
|
||||
for(i=0; i<len; i++) {
|
||||
#if AUTO_RETURN_AFTER_NEWLINE
|
||||
if(((const char *) ptr)[i] == '\n' &&
|
||||
((const char *) ptr)[i+1] != '\r') {
|
||||
HAL_UART_Transmit(&huart3, (uint8_t*)"\r", 1 ,
|
||||
DEBUG_UART_MS_TIMEOUT);
|
||||
}
|
||||
#endif
|
||||
uint8_t* character = (uint8_t*) ptr;
|
||||
HAL_UART_Transmit(&huart3, (uint8_t*) (character + i),
|
||||
1 , DEBUG_UART_MS_TIMEOUT);
|
||||
}
|
||||
return len;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int _lseek (int file, int ptr, int dir) {
|
||||
(void)file;
|
||||
(void)ptr;
|
||||
(void)dir;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _close(int file) {
|
||||
(void)file;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _open(const char *name, int flags, ...) {
|
||||
(void)name;
|
||||
(void)flags;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _link(const char *oldpath, const char *newpath) {
|
||||
(void)oldpath;
|
||||
(void)newpath;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _rename(const char *oldpath, const char *newpath) {
|
||||
(void)oldpath;
|
||||
(void)newpath;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _unlink(const char *pathname) {
|
||||
(void)pathname;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fsync(int fd) {
|
||||
(void)fd;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _fstat(int fd, struct stat *st) {
|
||||
(void)fd;
|
||||
(void)st;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _stat(const char *path, struct stat *st) {
|
||||
(void)path;
|
||||
(void)st;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _isatty(int fd) {
|
||||
if(fd <= STDERR_FILENO) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void exit(int n) {
|
||||
printf("\n\r EXITING WITH CODE: %u \n\r", n);
|
||||
//restart();
|
||||
while(1);
|
||||
}
|
||||
|
||||
void _exit(int n) {
|
||||
printf("\n\r EXITING WITH CODE: %u \n\r", n);
|
||||
//restart();
|
||||
while(1);
|
||||
}
|
||||
|
||||
int _kill() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _getpid() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _gettimeofday() {
|
||||
return -1;
|
||||
}
|
Reference in New Issue
Block a user