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
|
#include <stdlib.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "mcu/mcu_def.h"
#ifndef _IOE_IOPORT_H_
#define _IOE_IOPORT_H_
#ifdef CONFIG_IOPORTS
enum ioInResistor {
IO_PULLUP,
IO_PULLDOWN
};
static inline void io_setout(uint8_t group, uint8_t mask) {
IO_DDR(group) |= mask;
}
static inline void io_high(uint8_t group, uint8_t mask) {
IO_PORT(group) |= mask;
}
static inline void io_low(uint8_t group, uint8_t mask) {
IO_PORT(group) &= ~mask;
}
static inline void io_set(uint8_t group, uint8_t mask, int8_t val) {
if (val)
io_high(group, mask);
else
io_low(group, mask);
}
static inline void io_setin(uint8_t group, uint8_t mask,
enum ioInResistor resistor) {
IO_DDR(group) &= ~mask;
if (resistor == IO_PULLUP)
IO_PORT(group) |= mask;
else
IO_PORT(group) &= ~mask;
}
static inline int8_t io_get(uint8_t group, uint8_t mask) {
return (int8_t) IO_PIN(group) & mask;
}
#ifdef CONFIG_PCINT
#define IO_RISING (1 << 0)
#define IO_FALLING (1 << 1)
void io_change_sethook(uint8_t group, uint8_t mask, uint8_t edge,
void (*change) (uint8_t group, uint8_t mask));
void io_change_remhook(void (*change) (uint8_t group, uint8_t mask));
void io_change_clearhooks(void);
#endif /* CONFIG_PCINT */
#endif /* CONFIG_IOPORTS */
#endif /* _IOE_IOPORT_H_ */
|