38 #define TM_GENERAL_H 110
91 #include "stm32fxxx_hal.h"
93 #include "attributes.h"
214 #define TM_GENERAL_IsIRQMode() (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk)
229 #define TM_GENERAL_GetSystemClockMHz() ((uint16_t)(SystemCoreClock * (float)0.000001))
250 #if !defined(STM32F0xx)
251 #define TM_GENERAL_DWTCounterDisable() (DWT->CTRL &= ~0x00000001)
261 #define TM_GENERAL_DWTCounterGetValue() (DWT->CYCCNT)
269 #define TM_GENERAL_DWTCounterSetValue(x) (DWT->CYCCNT = (x))
281 micros *= (SystemCoreClock / 1000000);
298 millis *= (SystemCoreClock / 1000);
313 #define TM_GENERAL_IsNumberEven(number) ((number & 1) == 0)
346 #define TM_GENERAL_IsNumberPowerOfTwo(number) (number && !(number & (number - 1)))
uint8_t TM_GENERAL_DWTCounterEnable(void)
Enables DWT counter in Cortex-M4 core.
uint32_t TM_GENERAL_NextPowerOf2(uint32_t number)
Calculates next power of 2 from given number.
static __INLINE void TM_GENERAL_DWTCounterDelayus(uint32_t micros)
Delays for amount of microseconds using DWT counter.
Definition: tm_stm32_general.h:277
Definition: tm_stm32_general.h:147
Definition: tm_stm32_general.h:142
static __INLINE void TM_GENERAL_DWTCounterDelayms(uint32_t millis)
Delays for amount of milliseconds using DWT counter.
Definition: tm_stm32_general.h:294
Definition: tm_stm32_general.h:146
void TM_GENERAL_DisableInterrupts(void)
Disables all interrupts in system.
TM_GENERAL_ResetSource_t TM_GENERAL_GetResetSource(uint8_t reset_flags)
Gets reset source why system was reset.
void TM_GENERAL_SystemResetCallback(void)
System reset callback.
Definition: tm_stm32_general.h:130
uint16_t GENERAL_SystemSpeedInMHz
System speed in MHz.
Definition: tm_stm32_general.h:149
uint8_t TM_GENERAL_EnableInterrupts(void)
Enables interrupts in system.
Definition: tm_stm32_general.h:132
uint32_t Decimal
Definition: tm_stm32_general.h:157
void TM_GENERAL_ForceHardFaultError(void)
Forces processor to jump to Hard-fault handler.
Definition: tm_stm32_general.h:148
Definition: tm_stm32_general.h:143
Definition: tm_stm32_general.h:145
Definition: tm_stm32_general.h:144
uint32_t TM_GENERAL_GetClockSpeed(TM_GENERAL_Clock_t clock)
Gets specific clock speed value from STM32F4xx device.
Definition: tm_stm32_general.h:135
void TM_GENERAL_SystemReset(void)
Performs a system reset.
Definition: tm_stm32_general.h:134
float TM_GENERAL_RoundFloat(float Number, uint8_t decimals)
Round float number to nearest number with custom number of decimal places.
Float number operation structure.
Definition: tm_stm32_general.h:155
void TM_GENERAL_ConvertFloat(TM_GENERAL_Float_t *Float_Struct, float Number, uint8_t decimals)
Converts float coded number into integer and decimal part.
TM_GENERAL_Clock_t
Clock speed enumeration.
Definition: tm_stm32_general.h:129
#define TM_GENERAL_DWTCounterGetValue()
Gets current DWT counter value.
Definition: tm_stm32_general.h:261
Definition: tm_stm32_general.h:133
int32_t Integer
Definition: tm_stm32_general.h:156
TM_GENERAL_ResetSource_t
All possible reset sources.
Definition: tm_stm32_general.h:141
Definition: tm_stm32_general.h:131