From edc39d217ccf56f2539ebd11f289b7065189e00e Mon Sep 17 00:00:00 2001 From: Patrick Felix Date: Thu, 1 Jun 2017 19:57:28 +0200 Subject: [PATCH] Cleaned up sources --- HAL/STM32/stm32f4xx_it.c | 32 -------------------------------- HAL/STM32/stm32f4xx_it.h | 4 ---- HAL/System32.c | 33 ++++++++++++++++++++++++++++++++- HAL/System32.h | 6 ++++++ HAL/USART/FIFO_USART.c | 20 +++++++++++++++++++- HAL/USART/FIFO_USART.h | 17 +++++++++++++++++ HAL/USART/USART.c | 2 +- HAL/USART/USART.h | 2 +- 8 files changed, 76 insertions(+), 40 deletions(-) diff --git a/HAL/STM32/stm32f4xx_it.c b/HAL/STM32/stm32f4xx_it.c index 54212d0..59b4fdd 100644 --- a/HAL/STM32/stm32f4xx_it.c +++ b/HAL/STM32/stm32f4xx_it.c @@ -54,38 +54,6 @@ extern void Limit_PinChangeISR(void); extern void System_PinChangeISR(void); -void SysTick_Init(void) -{ - RCC_ClocksTypeDef RCC_Clocks; - - /* SysTick end of count event each 1ms */ - RCC_GetClocksFreq(&RCC_Clocks); - SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000); - - NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 5)); -} - - -// for 100 MHz STM32F411 -#define COUNTS_PER_MICROSECOND 33 -void Delay_us(volatile uint32_t us) -{ - volatile uint32_t count = us * COUNTS_PER_MICROSECOND - 2; - __asm volatile(" mov r0, %[count] \n\t" - "1: subs r0, #1 \n\t" - " bhi 1b \n\t" - : - : [count] "r" (count) - : "r0"); -} - - -void Delay_ms(volatile uint32_t ms) -{ - while(ms--) - Delay_us(999); -} - /******************************************************************************/ /* Cortex-M4 Processor Exceptions Handlers */ diff --git a/HAL/STM32/stm32f4xx_it.h b/HAL/STM32/stm32f4xx_it.h index c3eca1e..a8e8c2a 100644 --- a/HAL/STM32/stm32f4xx_it.h +++ b/HAL/STM32/stm32f4xx_it.h @@ -42,10 +42,6 @@ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ -void SysTick_Init(void); -void Delay_us(volatile uint32_t us); -void Delay_ms(volatile uint32_t ms); - void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); diff --git a/HAL/System32.c b/HAL/System32.c index f1f4e13..1f277c1 100644 --- a/HAL/System32.c +++ b/HAL/System32.c @@ -15,6 +15,37 @@ You should have received a copy of the GNU General Public License along with STM32F4_HAL. If not, see . */ -#include "system.h" +#include "System32.h" +void SysTick_Init(void) +{ + RCC_ClocksTypeDef RCC_Clocks; + + /* SysTick end of count event each 1ms */ + RCC_GetClocksFreq(&RCC_Clocks); + SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000); + + NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 5, 5)); +} + + +// for 100 MHz STM32F411 +#define COUNTS_PER_MICROSECOND 33 +void Delay_us(volatile uint32_t us) +{ + volatile uint32_t count = us * COUNTS_PER_MICROSECOND - 2; + __asm volatile(" mov r0, %[count] \n\t" + "1: subs r0, #1 \n\t" + " bhi 1b \n\t" + : + : [count] "r" (count) + : "r0"); +} + + +void Delay_ms(volatile uint32_t ms) +{ + while(ms--) + Delay_us(999); +} diff --git a/HAL/System32.h b/HAL/System32.h index 226e8db..87b0238 100644 --- a/HAL/System32.h +++ b/HAL/System32.h @@ -40,6 +40,12 @@ typedef struct { } Date_t; + +void SysTick_Init(void); +void Delay_us(volatile uint32_t us); +void Delay_ms(volatile uint32_t ms); + + #ifdef __cplusplus } #endif diff --git a/HAL/USART/FIFO_USART.c b/HAL/USART/FIFO_USART.c index 1a8668b..32f2e5f 100644 --- a/HAL/USART/FIFO_USART.c +++ b/HAL/USART/FIFO_USART.c @@ -1,3 +1,21 @@ +/* + FIFO_USART.c - FIFO USART Implementation + Part of STM32F4_HAL + + Copyright (c) 2016-2017 Patrick F. + + STM32F4_HAL 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. + STM32F4_HAL 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 STM32F4_HAL. If not, see . +*/ + /* Very simple queue * These are FIFO queues which discard the new data when full. * @@ -8,7 +26,7 @@ * Queue is full when in == (out-1 + QUEUE_SIZE) % QUEUE_SIZE; * * The queue will hold QUEUE_ELEMENTS number of items before the - * calls to QueuePut fail. + * calls to FifoUsart_Insert fail. */ #include #include "FIFO_USART.h" diff --git a/HAL/USART/FIFO_USART.h b/HAL/USART/FIFO_USART.h index 556c52e..0125d8f 100644 --- a/HAL/USART/FIFO_USART.h +++ b/HAL/USART/FIFO_USART.h @@ -1,3 +1,20 @@ +/* + FIFO_USART.h - FIFO USART Header + Part of STM32F4_HAL + + Copyright (c) 2016-2017 Patrick F. + + STM32F4_HAL 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. + STM32F4_HAL 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 STM32F4_HAL. If not, see . +*/ #ifndef FIFO_H_INCLUDED #define FIFO_H_INCLUDED diff --git a/HAL/USART/USART.c b/HAL/USART/USART.c index 9ff3215..685f665 100644 --- a/HAL/USART/USART.c +++ b/HAL/USART/USART.c @@ -1,5 +1,5 @@ /* - Usart.c - Usart implementation + USART.c - USART implementation Part of STM32F4_HAL Copyright (c) 2017 Patrick F. diff --git a/HAL/USART/USART.h b/HAL/USART/USART.h index e655515..fc829b2 100644 --- a/HAL/USART/USART.h +++ b/HAL/USART/USART.h @@ -1,5 +1,5 @@ /* - Usart.h - Usart Header + USART.h - USART Header Part of STM32F4_HAL Copyright (c) 2017 Patrick F.