@@ -41,12 +41,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4141**/
4242void MicroOLED::spiSetup ()
4343{
44- // Gather the CS pin's PORT, PIN, and DDR registers. Writing
45- // these directly will make things much faster.
46- ssport = portOutputRegister (digitalPinToPort (csPin));
47- sspinmask = digitalPinToBitMask (csPin);
48- ssreg = portModeRegister (digitalPinToPort (csPin));
49-
5044 // Initialize the pins:
5145 pinMode (MOSI, OUTPUT); // MOSI is an OUTPUT
5246 pinMode (SCK, OUTPUT); // SCK is an OUTPUT
@@ -67,7 +61,9 @@ void MicroOLED::spiSetup()
6761**/
6862void MicroOLED::spiTransfer (byte data)
6963{
64+ digitalWrite (csPin, LOW);
7065 SPI.transfer (data);
66+ digitalWrite (csPin, HIGH);
7167}
7268
7369/* * \brief Initialize the I2C Interface
@@ -79,9 +75,6 @@ void MicroOLED::i2cSetup()
7975{
8076 // Initialize Wire library (I2C)
8177 Wire.begin ();
82-
83- // SCL frequency = (F_CPU) / (16 + 2(TWBR) * (prescalar))
84- TWBR = ((F_CPU / I2C_FREQ) - 16 ) / 2 ;
8578}
8679
8780/* * \brief Write a byte over I2C
@@ -105,21 +98,6 @@ void MicroOLED::i2cWrite(byte address, byte dc, byte data)
10598**/
10699void MicroOLED::parallelSetup ()
107100{
108- // Gather the CS pin's PORT, PIN and DDR registers.
109- ssport = portOutputRegister (digitalPinToPort (csPin));
110- sspinmask = digitalPinToBitMask (csPin);
111- ssreg = portModeRegister (digitalPinToPort (csPin));
112-
113- // Gather the WR pin's PORT, PIN and DDR registers.
114- wrport = portOutputRegister (digitalPinToPort (wrPin));
115- wrpinmask = digitalPinToBitMask (wrPin);
116- wrreg = portModeRegister (digitalPinToPort (wrPin));
117-
118- // Gather the RD pin's PORT, PIN and DDR registers.
119- rdport = portOutputRegister (digitalPinToPort (rdPin));
120- rdpinmask = digitalPinToBitMask (rdPin);
121- rdreg = portModeRegister (digitalPinToPort (rdPin));
122-
123101 // Initialize WR, RD, CS and data pins as outputs.
124102 pinMode (wrPin, OUTPUT);
125103 digitalWrite (wrPin, HIGH);
@@ -146,18 +124,12 @@ void MicroOLED::parallelWrite(byte data, byte dc)
146124
147125 // chip select high->low
148126 digitalWrite (csPin, LOW);
149- // *ssport &= ~sspinmask; // SS LOW
150127
151128 // dc high or low
152129 digitalWrite (dcPin, dc);
153- /* if (dc)
154- *dcport |= dcpinmask; // DC HIGH
155- else
156- *dcport &= ~dcpinmask; // DC pin LOW*/
157130
158131 // wr high->low
159132 digitalWrite (wrPin, LOW);
160- // *wrport &= ~wrpinmask; // SS LOW
161133
162134 // set data pins
163135 for (int i=0 ; i<8 ; i++)
@@ -167,13 +139,11 @@ void MicroOLED::parallelWrite(byte data, byte dc)
167139 else
168140 digitalWrite (dPins[i], LOW);
169141 }
170- // PORTD = data;
171142
172143 // wr low->high
173144 digitalWrite (wrPin, HIGH);
174- // *wrport |= wrpinmask; // SS HIGH
175145
176146 // cs high
177147 digitalWrite (csPin, HIGH);
178- // *ssport |= sspinmask; // SS HIGH
179- }
148+ }
149+
0 commit comments