Stabilus 322699 wDoublePID
Dependencies: mbed QEI PID DmTftLibraryEx
Peripherals/Timers.cpp@28:443c82750dd9, 2022-03-04 (annotated)
- Committer:
- lex9296
- Date:
- Fri Mar 04 14:03:57 2022 +0000
- Revision:
- 28:443c82750dd9
- Parent:
- 20:626b92b70bf7
- Child:
- 29:7ce8c5779f5e
04 Marzo 2022
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mverdy | 20:626b92b70bf7 | 1 | /* |
mverdy | 20:626b92b70bf7 | 2 | ______ _ |
mverdy | 20:626b92b70bf7 | 3 | / _____) _ | | |
mverdy | 20:626b92b70bf7 | 4 | ( (____ _____ ____ _| |_ _____ ____| |__ |
mverdy | 20:626b92b70bf7 | 5 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
mverdy | 20:626b92b70bf7 | 6 | _____) ) ____| | | || |_| ____( (___| | | | |
mverdy | 20:626b92b70bf7 | 7 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mverdy | 20:626b92b70bf7 | 8 | (C)2016 Semtech |
mverdy | 20:626b92b70bf7 | 9 | |
mverdy | 20:626b92b70bf7 | 10 | Description: Timers |
mverdy | 20:626b92b70bf7 | 11 | |
mverdy | 20:626b92b70bf7 | 12 | Maintainer: Gregory Cristian & Gilbert Menth |
mverdy | 20:626b92b70bf7 | 13 | */ |
mverdy | 20:626b92b70bf7 | 14 | |
mverdy | 20:626b92b70bf7 | 15 | #include "mbed.h" |
mverdy | 20:626b92b70bf7 | 16 | #include "Timers.h" |
mverdy | 20:626b92b70bf7 | 17 | |
mverdy | 20:626b92b70bf7 | 18 | |
mverdy | 20:626b92b70bf7 | 19 | Ticker TickTimer; |
mverdy | 20:626b92b70bf7 | 20 | |
mverdy | 20:626b92b70bf7 | 21 | static uint32_t SoftTimer = 0; |
mverdy | 20:626b92b70bf7 | 22 | static void TimersIncSoftTimer( void ); |
mverdy | 20:626b92b70bf7 | 23 | |
mverdy | 20:626b92b70bf7 | 24 | |
mverdy | 20:626b92b70bf7 | 25 | void TimersInit( void ) |
mverdy | 20:626b92b70bf7 | 26 | { |
lex9296 | 28:443c82750dd9 | 27 | // TickTimer.attach_us( &TimersIncSoftTimer, 1000 ); // Ticks every millisecond |
lex9296 | 28:443c82750dd9 | 28 | TickTimer.attach_us( &TimersIncSoftTimer, 100 ); // LA: 1 Ticks, 0.1ms |
lex9296 | 28:443c82750dd9 | 29 | // TickTimer.attach_us( &TimersIncSoftTimer, 10 ); // LA: 1 Ticks, 0.01ms |
mverdy | 20:626b92b70bf7 | 30 | } |
mverdy | 20:626b92b70bf7 | 31 | |
mverdy | 20:626b92b70bf7 | 32 | static void TimersIncSoftTimer( void ) |
mverdy | 20:626b92b70bf7 | 33 | { |
mverdy | 20:626b92b70bf7 | 34 | SoftTimer++; |
mverdy | 20:626b92b70bf7 | 35 | } |
mverdy | 20:626b92b70bf7 | 36 | |
mverdy | 20:626b92b70bf7 | 37 | void TimersSetTimer( uint32_t *sTimer, uint32_t timeLength ) |
mverdy | 20:626b92b70bf7 | 38 | { |
mverdy | 20:626b92b70bf7 | 39 | if( timeLength > MAX_TIMER_VALUE ) |
mverdy | 20:626b92b70bf7 | 40 | { |
mverdy | 20:626b92b70bf7 | 41 | timeLength = MAX_TIMER_VALUE; |
mverdy | 20:626b92b70bf7 | 42 | } |
mverdy | 20:626b92b70bf7 | 43 | *sTimer = SoftTimer + timeLength; |
mverdy | 20:626b92b70bf7 | 44 | } |
mverdy | 20:626b92b70bf7 | 45 | |
mverdy | 20:626b92b70bf7 | 46 | uint32_t TimersTimerHasExpired ( const uint32_t * sTimer ) |
mverdy | 20:626b92b70bf7 | 47 | { |
mverdy | 20:626b92b70bf7 | 48 | if( ( SoftTimer - *sTimer ) > 0x7fffffff ) |
mverdy | 20:626b92b70bf7 | 49 | { |
mverdy | 20:626b92b70bf7 | 50 | return false; |
mverdy | 20:626b92b70bf7 | 51 | } |
mverdy | 20:626b92b70bf7 | 52 | return true; |
mverdy | 20:626b92b70bf7 | 53 | } |
mverdy | 20:626b92b70bf7 | 54 | |
mverdy | 20:626b92b70bf7 | 55 | uint32_t TimersTimerValue ( void ) |
mverdy | 20:626b92b70bf7 | 56 | { |
mverdy | 20:626b92b70bf7 | 57 | return SoftTimer; |
mverdy | 20:626b92b70bf7 | 58 | } |
mverdy | 20:626b92b70bf7 | 59 |