-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer_timeout.h
More file actions
60 lines (50 loc) · 1.93 KB
/
timer_timeout.h
File metadata and controls
60 lines (50 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
* Timer Timeout library for MSP43x V01 - timer_timeout.h
*
* - Use a timer and interrupt to tick a 32bit unsigned variable
* - period selected by user, between 1us and 1ms
* - enable to use timer interruption with less then 1MHz, very useful for
* small microcontrollers (tested at 100us - 10kHz)
*
* Author: Haroldo Luiz Moretti do Amaral - agaelema@gmail.com
* https://www.embarcados.com.br/author/agaelema/
* https://www.github.com/agaelema
*
* Based on idea presented by: Felipe de Andrade Neves Lavratti
* - generic delay and timeout library
* https://www.embarcados.com.br/biblioteca-de-timer-delay-timeout/
*
********************************************************************************
* Changes:
* - Separate setup of timer in different file ("timer_timeout_setup")
* - remove unused code
*
* v0.3 - 2017/08/10
*******************************************************************************/
#ifndef _TIMER_TIMEOUT_H_
#define _TIMER_TIMEOUT_H_
#include <stdint.h>
#include <msp430.h>
#include "driverlib.h"
#include "timer_timeout_setup.h"
/* Set timer compare value */
uint32_t setCompareValue(uint32_t timerFreq, uint32_t timerCLK);
/* Initilize the Timer library */
void delayInit(void);
/* Delay Functions, argument in milisecs and microsecs */
void delayMs(uint32_t delayInMs);
void delayUs(uint32_t delayInUs);
/*
* Timeout functions
*/
/* Return a Timeout seed used by the timeoutCheck functions */
uint32_t timeoutInit(void);
/* Check if timeouted a initilized seed */
//uint32_t timeoutCheck_ms(uint32_t delayInMs, uint32_t seed);
uint_fast8_t timeoutCheck_ms(uint32_t delayInMs, uint32_t seed);
//uint32_t timeoutCheck_us(uint32_t delayInUs, uint32_t seed);
uint_fast8_t timeoutCheck_us(uint32_t delayInUs, uint32_t seed);
/* Get the system time */
uint32_t getTime_ms(void);
uint32_t getTime_us(void);
#endif //_TIMER_H_