YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
timer_msp432.h
1/*
2 *
3 * Created on: 27.02.2017
4 * Author: aterstegge
5 */
6
7#ifndef _TIMER_MSP432_H_
8#define _TIMER_MSP432_H_
9
10#include "timer_interface.h"
11#include "msp.h"
12
13extern "C" {
14void T32_INT1_IRQHandler(void);
15void T32_INT2_IRQHandler(void);
16}
17
19public:
20 timer_msp432(Timer32_Type *timer = TIMER32_1);
21
22 virtual ~timer_msp432();
23
24 void setPeriod(uint32_t us, TIMER::timer_mode mode = TIMER::ONE_SHOT);
25 uint32_t getPeriod();
26
27 void setCallback(function<void()> f);
28 void start();
29 void stop();
30 bool isRunning();
31 void reset();
32
33 // Additional methods (not in timer_interface)
34 void setNanoPeriod(uint32_t ns, TIMER::timer_mode mode = TIMER::ONE_SHOT);
35
36 uint32_t getNanoPeriod();
37
38 // IRQ handlers are our best friends
39 friend void T32_INT1_IRQHandler(void);
40 friend void T32_INT2_IRQHandler(void);
41
42private:
43
44 static function<void()> _intHandler1;
45 static function<void()> _intHandler2;
46
47 Timer32_Type *_timer;
48 uint32_t _factor; // count for one us
49 uint32_t _period_us; // load value in us
50 uint32_t _period_ns; // load value in ns
51 uint32_t _period_load;
52};
53
54#endif // _TIMER_MSP432_H_
55