forked from pimatic/virtualhomeduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwiringx_functions.h
62 lines (48 loc) · 1.34 KB
/
wiringx_functions.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
52
53
54
55
56
57
58
59
60
61
62
#ifndef _WIRING_X_FUNCTIONS_H_
#define _WIRING_X_FUNCTIONS_H_
#include <sys/stat.h>
#include <sys/time.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
extern "C" {
#include "wiringX/wiringX.h"
}
#define MAX_RECORDINGS 1024
extern int _hw_interrupt_pin;
extern void (*_hw_interruptCallback)(void);
static inline int hw_getInterruptPin() {
return _hw_interrupt_pin;
}
static inline void hw_callInterrupt() {
if(_hw_interrupt_pin != -1) {
_hw_interruptCallback();
}
}
static inline void hw_attachInterrupt(uint8_t interrput_pin, void (*ic)(void)) {
_hw_interruptCallback = ic;
wiringXISR(interrput_pin, INT_EDGE_BOTH);
_hw_interrupt_pin = interrput_pin;
}
static inline void hw_detachInterrupt(uint8_t){
_hw_interrupt_pin = -1;
_hw_interruptCallback = 0;
}
static inline unsigned long hw_micros(void) {
struct timeval tv;
gettimeofday(&tv, 0);
return 1000000 * (unsigned int)tv.tv_sec + (unsigned int)tv.tv_usec;
}
static inline void hw_delayMicroseconds(unsigned long time_to_wait) {
return delayMicroseconds(time_to_wait);
}
static inline void hw_pinMode(uint8_t pin, uint8_t mode){
// printf("pin mode %d %d\n", pin, mode);
pinMode((int)pin, (int)mode);
}
static inline void hw_digitalWrite(uint8_t pin, uint8_t value){
// printf("write %d %d\n",pin, value );
digitalWrite((int)pin, (int)value);
}
#endif