COSA
An Object-Oriented Platform for Arduino Programming
Fai.cpp
Go to the documentation of this file.
1 
21 #include "Fai.hh"
22 
23 static char MAGIC[] = "Cosa::Fai";
24 static const uint8_t MAJOR = 1;
25 static const uint8_t MINOR = 0;
26 
27 void
29 {
30  header_t header;
31  header.magic = MAGIC;
32  header.major = MAJOR;
33  header.minor = MINOR;
34  header.endian = LITTLE_ENDIAN;
36 }
37 
38 #if defined(BOARD_ATTINYX5)
39 
40 void
41 Fai::write(uint32_t mask)
42 {
43  digital_pins_t dgl;
44  dgl.values = (PINB & mask);
46 }
47 
48 #elif defined(BOARD_ATTINYX4) || defined(BOARD_ATTINYX61)
49 
50 void
51 Fai::write(uint32_t mask)
52 {
53  digital_pins_t dgl;
54  dgl.values = ((PINB << 8) | PINA) & mask;
56 }
57 
58 #else
59 
60 void
61 Fai::write(uint32_t mask)
62 {
63  digital_pins_t dgl;
64  dgl.values = ((PINB << 8) | PIND) & mask;
66 }
67 
68 #endif
69 
70 void
72 {
73  digital_pin_t dgl;
74  dgl.pin = pin->pin();
75  dgl.value = pin->is_set();
77 }
78 
79 void
81 {
82  analog_pin_t ang;
83  ang.pin = pin->pin();
84  ang.value = pin->value();
86 }
uint8_t pin
Definition: Fai.hh:61
Board::AnalogPin pin() const
Definition: AnalogPin.hh:69
uint8_t major
Definition: Ciao.hh:124
static char MAGIC[]
Definition: Fai.cpp:23
void begin()
Definition: Fai.cpp:28
uint8_t pin() const
Definition: Pin.hh:103
static const uint8_t MAJOR
Definition: Fai.cpp:24
Definition: Pin.hh:35
void write(char *s)
Definition: Ciao.cpp:87
uint8_t pin
Definition: Fai.hh:69
void write(uint32_t mask)
Definition: Fai.cpp:61
uint16_t value
Definition: Fai.hh:62
uint32_t values
Definition: Fai.hh:77
char * magic
Definition: Ciao.hh:123
bool is_set() const
Definition: Pin.hh:112
uint8_t minor
Definition: Ciao.hh:125
uint8_t value
Definition: Fai.hh:70
uint8_t endian
Definition: Ciao.hh:126
static const Ciao::Descriptor::user_t digital_pin_t
Definition: Fai.hh:50
static const user_t header_t
Definition: Ciao.hh:115
static const Ciao::Descriptor::user_t analog_pin_t
Definition: Fai.hh:49
static const Ciao::Descriptor::user_t digital_pins_t
Definition: Fai.hh:51
static const uint8_t MINOR
Definition: Fai.cpp:25
uint16_t value() const
Definition: AnalogPin.hh:79