Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move board specific cmake out of LFC and into user-provided cmake files #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 37 additions & 53 deletions STM_sdk/Core/Src/stm32f4xx_hal_msp.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_hal_msp.c
* @brief This file provides code for the MSP Initialization
* and de-Initialization codes.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
******************************************************************************
* @file stm32f4xx_hal_msp.c
* @brief This file provides code for the MSP Initialization
* and de-Initialization codes.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "main.h"
// #include "STM_main.h"
// #include "../../Main/include/Main/main.h"
// #include "../../Main/include/Main/main.h"
#include "stm32f4xx_hal.h"

/* USER CODE BEGIN Includes */

Expand Down Expand Up @@ -62,10 +59,9 @@

/* USER CODE END 0 */
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
{
* Initializes the Global MSP.
*/
void HAL_MspInit(void) {
/* USER CODE BEGIN MspInit 0 */

/* USER CODE END MspInit 0 */
Expand All @@ -86,11 +82,9 @@ void HAL_MspInit(void)
* @param hdac: DAC handle pointer
* @retval None
*/
void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac)
{
void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac) {
GPIO_InitTypeDef GPIO_InitStruct = {0};
if (hdac->Instance == DAC)
{
if (hdac->Instance == DAC) {
/* USER CODE BEGIN DAC_MspInit 0 */

/* USER CODE END DAC_MspInit 0 */
Expand Down Expand Up @@ -118,10 +112,8 @@ void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac)
* @param hdac: DAC handle pointer
* @retval None
*/
void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac)
{
if (hdac->Instance == DAC)
{
void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac) {
if (hdac->Instance == DAC) {
/* USER CODE BEGIN DAC_MspDeInit 0 */

/* USER CODE END DAC_MspDeInit 0 */
Expand All @@ -140,16 +132,14 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac)
}

/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspInit(UART_HandleTypeDef *huart) {
GPIO_InitTypeDef GPIO_InitStruct = {0};
if (huart->Instance == USART2)
{
if (huart->Instance == USART2) {
/* USER CODE BEGIN USART2_MspInit 0 */

/* USER CODE END USART2_MspInit 0 */
Expand Down Expand Up @@ -183,10 +173,8 @@ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART2)
{
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) {
if (huart->Instance == USART2) {
/* USER CODE BEGIN USART2_MspDeInit 0 */

/* USER CODE END USART2_MspDeInit 0 */
Expand All @@ -213,11 +201,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
* @param htim_encoder: TIM_Encoder handle pointer
* @retval None
*/
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim_encoder)
{
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim_encoder) {
GPIO_InitTypeDef GPIO_InitStruct = {0};
if (htim_encoder->Instance == TIM2)
{
if (htim_encoder->Instance == TIM2) {
/* USER CODE BEGIN TIM2_MspInit 0 */

/* USER CODE END TIM2_MspInit 0 */
Expand Down Expand Up @@ -248,10 +234,8 @@ void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim_encoder)
* @param htim_encoder: TIM_Encoder handle pointer
* @retval None
*/
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim_encoder)
{
if (htim_encoder->Instance == TIM2)
{
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim_encoder) {
if (htim_encoder->Instance == TIM2) {
/* USER CODE BEGIN TIM2_MspDeInit 0 */

/* USER CODE END TIM2_MspDeInit 0 */
Expand Down
116 changes: 49 additions & 67 deletions STM_sdk/Core/Src/stm32f4xx_it.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
******************************************************************************
* @file stm32f4xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "main.h"
// #include "STM_main.h"
// #include "../../Main/include/Main/Main.h"
// #include "../../Main/include/Main/main.h"
#include "stm32f4xx_hal.h"
#include "stm32f4xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
Expand Down Expand Up @@ -68,85 +65,74 @@ extern UART_HandleTypeDef huart2;
/* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void) {
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */

/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
while (1)
{
while (1) {
}
/* USER CODE END NonMaskableInt_IRQn 1 */
}

/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void) {
/* USER CODE BEGIN HardFault_IRQn 0 */

/* USER CODE END HardFault_IRQn 0 */
while (1)
{
while (1) {
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}

/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void) {
/* USER CODE BEGIN MemoryManagement_IRQn 0 */

/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
while (1) {
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}

/**
* @brief This function handles Pre-fetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
* @brief This function handles Pre-fetch fault, memory access fault.
*/
void BusFault_Handler(void) {
/* USER CODE BEGIN BusFault_IRQn 0 */

/* USER CODE END BusFault_IRQn 0 */
while (1)
{
while (1) {
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}

/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void) {
/* USER CODE BEGIN UsageFault_IRQn 0 */

/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
while (1) {
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}

/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void) {
/* USER CODE BEGIN SVCall_IRQn 0 */

/* USER CODE END SVCall_IRQn 0 */
Expand All @@ -156,10 +142,9 @@ void SVC_Handler(void)
}

/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void) {
/* USER CODE BEGIN DebugMonitor_IRQn 0 */

/* USER CODE END DebugMonitor_IRQn 0 */
Expand All @@ -169,10 +154,9 @@ void DebugMon_Handler(void)
}

/**
* @brief This function handles Pendable request for system service.
*/
void PendSV_Handler(void)
{
* @brief This function handles Pendable request for system service.
*/
void PendSV_Handler(void) {
/* USER CODE BEGIN PendSV_IRQn 0 */

/* USER CODE END PendSV_IRQn 0 */
Expand All @@ -182,10 +166,9 @@ void PendSV_Handler(void)
}

/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void) {
/* USER CODE BEGIN SysTick_IRQn 0 */

/* USER CODE END SysTick_IRQn 0 */
Expand All @@ -205,8 +188,7 @@ void SysTick_Handler(void)
/**
* @brief This function handles USART2 global interrupt.
*/
void USART2_IRQHandler(void)
{
void USART2_IRQHandler(void) {
/* USER CODE BEGIN USART2_IRQn 0 */

/* USER CODE END USART2_IRQn 0 */
Expand Down
7 changes: 3 additions & 4 deletions src/Main.lf
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
target C {
single-threaded: true,
platform: {
name: "STM32",
board: "F446RE"
}
platform: "STM32F4",
cmake-include: "cmake/stm.cmake",
cmake-init-include: "cmake/stm-init.cmake",
}

preamble {=
Expand Down
23 changes: 23 additions & 0 deletions src/cmake/arm-none-eabi-gcc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)

# Some default GCC settings
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(FLAGS
"-fdata-sections -ffunction-sections \
--specs=nano.specs -Wl,--gc-sections")
set(CPP_FLAGS
"-fno-rtti -fno-exceptions \
-fno-threadsafe-statics")

set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc ${FLAGS})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ ${FLAGS} ${CPP_FLAGS})
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)

set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
Loading