24 #error Pixels_PPI16.h must be included before Pixels_<CONTROLLER>.h
27 #ifndef PIXELS_PPI16_H
28 #define PIXELS_PPI16_H
30 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
31 #define DATAPORTH PORTA // 22-29
32 #define DATAPORTL PORTC // 30-37
37 #define DATAPORTH PORTD // 0-7
38 #define DATAPORTL PORTB // 8-13
63 sbi(registerRST, bitmaskRST);
65 cbi(registerRST, bitmaskRST);
67 sbi(registerRST, bitmaskRST);
73 void writeCmd(uint8_t b) {
74 cbi(registerRS, bitmaskRS);
75 DATAPORTH = 0; DATAPORTL = b; pulse_low(registerWR, bitmaskWR);
78 void writeData(uint8_t data) {
79 sbi(registerRS, bitmaskRS);
80 DATAPORTH = 0; DATAPORTL = data; pulse_low(registerWR, bitmaskWR);
83 void writeData(uint8_t hi, uint8_t lo) {
84 sbi(registerRS, bitmaskRS);
85 DATAPORTH = hi; DATAPORTL = lo; pulse_low(registerWR, bitmaskWR);
88 void writeDataTwice(uint8_t b) {
89 sbi(registerRS, bitmaskRS);
90 DATAPORTH = b; DATAPORTL = b; pulse_low(registerWR, bitmaskWR);
93 void writeCmdData(uint8_t cmd, uint16_t data) {
95 writeData(highByte(data), lowByte(data));
107 inline void setSpiPins(uint8_t scl, uint8_t sda, uint8_t cs, uint8_t rst, uint8_t wr) {
115 inline void setPpiPins(uint8_t rs, uint8_t wr, uint8_t cs, uint8_t rst, uint8_t rd) {
123 inline void registerSelect() {
124 sbi(registerRS, bitmaskRS);
128 void PPI16::initInterface() {
133 registerRS = portOutputRegister(digitalPinToPort(pinRS));
134 registerWR = portOutputRegister(digitalPinToPort(pinWR));
135 registerCS = portOutputRegister(digitalPinToPort(pinCS));
136 registerRST = portOutputRegister(digitalPinToPort(pinRST));
138 registerRD = portOutputRegister(digitalPinToPort(pinRD));
141 bitmaskRS = digitalPinToBitMask(pinRS);
142 bitmaskWR = digitalPinToBitMask(pinWR);
143 bitmaskCS = digitalPinToBitMask(pinCS);
144 bitmaskRST = digitalPinToBitMask(pinRST);
146 bitmaskRD = digitalPinToBitMask(pinRD);
149 pinMode(pinRS,OUTPUT);
150 pinMode(pinWR,OUTPUT);
151 pinMode(pinCS,OUTPUT);
152 pinMode(pinRST,OUTPUT);
void setSpiPins(uint8_t scl, uint8_t sda, uint8_t cs, uint8_t rst, uint8_t wr)
void setPpiPins(uint8_t rs, uint8_t wr, uint8_t cs, uint8_t rst, uint8_t rd)