aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stm32f091/main.c21
-rw-r--r--stm32f091/makefile28
-rw-r--r--stm32f091/stm32f0xx_hal_conf.h100
-rw-r--r--stm32f091/stm32f0xx_hal_msp.c32
-rw-r--r--stm32f091/stm32f0xx_hal_msp.h9
5 files changed, 154 insertions, 36 deletions
diff --git a/stm32f091/main.c b/stm32f091/main.c
index 5e5071e..3ada476 100644
--- a/stm32f091/main.c
+++ b/stm32f091/main.c
@@ -2,25 +2,28 @@
#include <task.h>
#include <stm32f0xx.h>
#include <stdint.h>
-#include <stm32f0xx_hal_gpio.h>
+#include <stm32f0xx_hal.h>
void task_1() {
- uint8_t led = 1;
+ // uint8_t led = 1;
while (1) {
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, led);
- led ^= 1;
+ // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, led);
+ // led ^= 1;
+ HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
vTaskDelay(1000 / portTICK_RATE_MS);
}
}
int main() {
- HAL_GPIO_Init(GPIOA, &(GPIO_InitTypeDef) {
- .Mode = GPIO_MODE_OUTPUT_PP,
- .Pull = GPIO_NOPULL,
- .Pin = GPIO_PIN_5
- });
+ HAL_Init();
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Pin = GPIO_PIN_5;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
xTaskCreate(task_1, "task1", 128, NULL, 1, NULL);
vTaskStartScheduler();
diff --git a/stm32f091/makefile b/stm32f091/makefile
index bba85f4..5a185de 100644
--- a/stm32f091/makefile
+++ b/stm32f091/makefile
@@ -20,8 +20,10 @@ SHARED_FLAGS += -I./lib/STM32-base/startup
SHARED_FLAGS += -I./lib/FreeRTOS-Kernel/include
SHARED_FLAGS += -I./lib/FreeRTOS-Kernel/portable/GCC/ARM_CM0/
SHARED_FLAGS += -I.
+SHARED_FLAGS += -O1
SHARED_FLAGS += -ffunction-sections
SHARED_FLAGS += -fdata-sections
+SHARED_FLAGS += -Wl,--gc-sections
SHARED_FLAGS += -mlittle-endian
SHARED_FLAGS += -mthumb
SHARED_FLAGS += -specs=nosys.specs
@@ -47,16 +49,22 @@ OBJS += lib/FreeRTOS-Kernel/croutine.o \
lib/FreeRTOS-Kernel/timers.o \
lib/FreeRTOS-Kernel/portable/GCC/ARM_CM0/port.o \
lib/FreeRTOS-Kernel/portable/MemMang/heap_4.o
-OBJS += lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_gpio.o
-# OBJS += lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_gpio.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_cortex.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2c.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2s.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rtc.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_uart.o \
-# lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_usart.o
+OBJS += lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rcc.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rcc_ex.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2c.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2c_ex.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_gpio.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_dma.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_cortex.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr_ex.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash_ex.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_tim.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_tim_ex.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_uart.o \
+ lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_uart_ex.o
.PHONY: flash clean
diff --git a/stm32f091/stm32f0xx_hal_conf.h b/stm32f091/stm32f0xx_hal_conf.h
index 48ec387..fc27221 100644
--- a/stm32f091/stm32f0xx_hal_conf.h
+++ b/stm32f091/stm32f0xx_hal_conf.h
@@ -19,29 +19,95 @@
#define DATA_CACHE_ENABLE 0U
#define USE_SPI_CRC 0U
+#define HAL_RCC_MODULE_ENABLED
#define HAL_MODULE_ENABLED
-#define HAL_UART_MODULE_ENABLED
-#define HAL_CORTEX_MODULE_ENABLED
-#define HAL_DMA_MODULE_ENABLED
-#define HAL_FLASH_MODULE_ENABLED
+#define HAL_I2C_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
-#define HAL_EXTI_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
-#define HAL_RCC_MODULE_ENABLED
-#define HAL_I2C_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_TIM_MODULE_ENABLED
+#define HAL_UART_MODULE_ENABLED
-#include <stm32f0xx_hal.h>
+#ifdef HAL_RCC_MODULE_ENABLED
#include <stm32f0xx_hal_rcc.h>
-// #include <stm32f0xx_hal_dma.h>
+#endif
+#ifdef HAL_GPIO_MODULE_ENABLED
#include <stm32f0xx_hal_gpio.h>
-// #include <stm32f0xx_hal_cortex.h>
-// #include <stm32f0xx_hal_flash.h>
-// #include <stm32f0xx_hal_i2c.h>
-// #include <stm32f0xx_hal_i2s.h>
-// #include <stm32f0xx_hal_pwr.h>
-// #include <stm32f0xx_hal_rtc.h>
-// #include <stm32f0xx_hal_uart.h>
-// #include <stm32f0xx_hal_usart.h>
+#endif
+#ifdef HAL_DMA_MODULE_ENABLED
+#include <stm32f0xx_hal_dma.h>
+#endif
+#ifdef HAL_CORTEX_MODULE_ENABLED
+#include <stm32f0xx_hal_cortex.h>
+#endif
+#ifdef HAL_ADC_MODULE_ENABLED
+#include <stm32f0xx_hal_adc.h>
+#endif
+#ifdef HAL_CAN_MODULE_ENABLED
+#include <stm32f0xx_hal_can.h>
+#endif
+#ifdef HAL_CEC_MODULE_ENABLED
+#include <stm32f0xx_hal_cec.h>
+#endif
+#ifdef HAL_COMP_MODULE_ENABLED
+#include <stm32f0xx_hal_comp.h>
+#endif
+#ifdef HAL_CRC_MODULE_ENABLED
+#include <stm32f0xx_hal_crc.h>
+#endif
+#ifdef HAL_DAC_MODULE_ENABLED
+#include <stm32f0xx_hal_dac.h>
+#endif
+#ifdef HAL_FLASH_MODULE_ENABLED
+#include <stm32f0xx_hal_flash.h>
+#endif
+#ifdef HAL_I2C_MODULE_ENABLED
+#include <stm32f0xx_hal_i2c.h>
+#endif
+#ifdef HAL_I2S_MODULE_ENABLED
+#include <stm32f0xx_hal_i2s.h>
+#endif
+#ifdef HAL_IRDA_MODULE_ENABLED
+#include <stm32f0xx_hal_irda.h>
+#endif
+#ifdef HAL_IWDG_MODULE_ENABLED
+#include <stm32f0xx_hal_iwdg.h>
+#endif
+#ifdef HAL_PCD_MODULE_ENABLED
+#include <stm32f0xx_hal_pcd.h>
+#endif
+#ifdef HAL_PWR_MODULE_ENABLED
+#include <stm32f0xx_hal_pwr.h>
+#endif
+#ifdef HAL_RTC_MODULE_ENABLED
+#include <stm32f0xx_hal_rtc.h>
+#endif
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+#include <stm32f0xx_hal_smartcard.h>
+#endif
+#ifdef HAL_SMBUS_MODULE_ENABLED
+#include <stm32f0xx_hal_smbus.h>
+#endif
+#ifdef HAL_SPI_MODULE_ENABLED
+#include <stm32f0xx_hal_spi.h>
+#endif
+#ifdef HAL_TIM_MODULE_ENABLED
+#include <stm32f0xx_hal_tim.h>
+#endif
+#ifdef HAL_TSC_MODULE_ENABLED
+#include <stm32f0xx_hal_tsc.h>
+#endif
+#ifdef HAL_UART_MODULE_ENABLED
+#include <stm32f0xx_hal_uart.h>
+#endif
+#ifdef HAL_USART_MODULE_ENABLED
+#include <stm32f0xx_hal_usart.h>
+#endif
+#ifdef HAL_WWDG_MODULE_ENABLED
+#include <stm32f0xx_hal_wwdg.h>
+#endif
#ifdef USE_FULL_ASSERT
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__))
diff --git a/stm32f091/stm32f0xx_hal_msp.c b/stm32f091/stm32f0xx_hal_msp.c
new file mode 100644
index 0000000..8fd7330
--- /dev/null
+++ b/stm32f091/stm32f0xx_hal_msp.c
@@ -0,0 +1,32 @@
+#include "stm32f0xx_hal_msp.h"
+
+void HAL_MspInit(void) {
+ return;
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
+ __HAL_RCC_PWR_CLK_ENABLE();
+ HAL_NVIC_SetPriority(PendSV_IRQn, 3, 0);
+}
+
+void HAL_UART_MspInit(UART_HandleTypeDef* huart) {
+ return;
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(huart->Instance==USART2) {
+ __HAL_RCC_USART2_CLK_ENABLE();
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF1_USART2;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+ }
+}
+
+void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) {
+ return;
+ if(huart->Instance==USART2) {
+ __HAL_RCC_USART2_CLK_DISABLE();
+ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
+ }
+}
+
diff --git a/stm32f091/stm32f0xx_hal_msp.h b/stm32f091/stm32f0xx_hal_msp.h
new file mode 100644
index 0000000..3ffdf48
--- /dev/null
+++ b/stm32f091/stm32f0xx_hal_msp.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <stm32f0xx_hal.h>
+#include <stm32f0xx_hal_uart.h>
+
+void HAL_MspInit(void);
+void HAL_UART_MspInit(UART_HandleTypeDef* huart);
+void HAL_UART_MspDeInit(UART_HandleTypeDef* huart);
+