24 #error Pixels_SPIsw.h must be included before Pixels_<CONTROLLER>.h
27 #ifndef PIXELS_SPISW_H
28 #define PIXELS_SPISW_H
47 void busWrite(uint8_t data);
51 digitalWrite(pinRST,LOW);
53 digitalWrite(pinRST,HIGH);
57 void writeCmd(uint8_t b);
58 void writeData(uint8_t data);
60 void writeData(uint8_t hi, uint8_t lo) {
65 void writeDataTwice(uint8_t b) {
70 void writeCmdData(uint8_t cmd, uint16_t data) {
72 writeData(highByte(data));
73 writeData(lowByte(data));
91 inline void setSpiPins(uint8_t scl, uint8_t sda, uint8_t cs, uint8_t rst, uint8_t wr = 255) {
104 inline void setPpiPins(uint8_t rs, uint8_t wr, uint8_t cs, uint8_t rst, uint8_t rd) {
107 inline void registerSelect() {
111 void SPIsw::initInterface() {
112 registerSCL = portOutputRegister(digitalPinToPort(pinSCL));
113 bitmaskSCL = digitalPinToBitMask(pinSCL);
114 registerSDA = portOutputRegister(digitalPinToPort(pinSDA));
115 bitmaskSDA = digitalPinToBitMask(pinSDA);
116 registerWR = portOutputRegister(digitalPinToPort(pinWR));
117 bitmaskWR = digitalPinToBitMask(pinWR);
118 registerCS = portOutputRegister(digitalPinToPort(pinCS));
119 bitmaskCS = digitalPinToBitMask(pinCS);
121 pinMode(pinSCL,OUTPUT);
122 pinMode(pinSDA,OUTPUT);
123 pinMode(pinWR,OUTPUT);
124 pinMode(pinRST,OUTPUT);
125 pinMode(pinCS,OUTPUT);
130 void SPIsw::busWrite(uint8_t data) {
134 *registerSDA |= bitmaskSDA;
136 *registerSDA &= ~bitmaskSDA;
139 *registerSCL &= ~bitmaskSCL;
141 *registerSCL |= bitmaskSCL;
145 void SPIsw::writeCmd(uint8_t cmd) {
147 *registerWR &= ~bitmaskWR;
149 cbi(registerSDA, bitmaskSDA);
150 cbi(registerSCL, bitmaskSCL);
151 sbi(registerSCL, bitmaskSCL);
156 void SPIsw::writeData(uint8_t data) {
158 *registerWR |= bitmaskWR;
160 sbi(registerSDA, bitmaskSDA);
161 cbi(registerSCL, bitmaskSCL);
162 sbi(registerSCL, bitmaskSCL);
void setPpiPins(uint8_t rs, uint8_t wr, uint8_t cs, uint8_t rst, uint8_t rd)
void setSpiPins(uint8_t scl, uint8_t sda, uint8_t cs, uint8_t rst, uint8_t wr=255)