-
Notifications
You must be signed in to change notification settings - Fork 0
/
strobe.h
51 lines (46 loc) · 1.03 KB
/
strobe.h
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
#ifndef STROBE_H
#define STROBE_H
#include <avr/io.h>
#include <avr/interrupt.h>
#define STROBE_PORT PORTB
#define STROBE_DDR DDRB
#define STROBE_PIN 1
#define STROBE_INIT_LENGTH 500
class Strobe
{
public:
Strobe(volatile uint16_t * ptr_T);
void init();
void strobeOn();
void strobeOff();
protected:
private:
volatile uint16_t * ptr_Timer;
__inline__ void setTimer(uint16_t tm = 0)
{
cli();
*ptr_Timer = tm;
sei();
}
__inline__ uint16_t getTimer()
{
uint16_t tmpTime = 0;
cli();
tmpTime = *ptr_Timer;
sei();
return tmpTime;
}
__inline__ void CONFIG_STROBE()
{
STROBE_DDR |= _BV(STROBE_PIN);
}
__inline__ void STROBE_ON()
{
STROBE_PORT |= _BV(STROBE_PIN);
}
__inline__ void STROBE_OFF()
{
STROBE_PORT &= ~_BV(STROBE_PIN);
}
};
#endif // STROBE_H