@@ -177,19 +177,33 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt
177
177
Future: To accommodate write pin numbers >= 32, will need to update to choose a different register
178
178
for set/reset (out1_w1tc and out1_w1ts) */
179
179
180
+ // **** Bit shifting trial
181
+ // uint32_t* output_register = self->bus;
182
+ // const uint8_t bit_shift=self->data0_pin;
183
+
180
184
uint32_t * clear_write = (uint32_t * ) & self -> write_group -> out_w1tc ;
181
185
uint32_t * set_write = (uint32_t * ) & self -> write_group -> out_w1ts ;
182
- uint32_t mask = self -> write_mask ;
186
+
187
+ const uint32_t mask = self -> write_mask ;
188
+
183
189
184
190
/* Setup structures for data writing. The ESP32-S2 port differs from the SAMD and NRF ports
185
191
because I have not found a way to write a single byte into the ESP32-S2 registers.
186
192
For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes. */
187
193
188
194
* clear_write = mask ; // Clear the write pin to prepare the registers before storing register settings into data_buffer
189
- uint32_t data_buffer = * self -> bus ; // store the initial output register values into the data output buffer
195
+
196
+ const uint32_t data_buffer = * self -> bus ; // store the initial output register values into the data output buffer
190
197
uint8_t * data_address = ((uint8_t * ) & data_buffer ) + (self -> data0_pin / 8 ); /* address inside data_buffer where
191
198
each data byte will be written (as offset by (data0_pin/8) number of bytes) */
192
199
200
+ // *** Bit shifting trial
201
+ // *data_address = 0; //clear the 8 data bits
202
+
203
+ //mp_printf(&mp_plat_print, "\n\ndata_buffer: %x\n", data_buffer);
204
+ //mp_printf(&mp_plat_print, "data[0]: %x\n", data[0]);
205
+ //mp_printf(&mp_plat_print, "data_buffer[0]: %x\n\n", (data_buffer | (((uint32_t) data[0]) << self->data0_pin)));
206
+
193
207
for (uint32_t i = 0 ; i < data_length ; i ++ ) {
194
208
195
209
/* Question: Is there a faster way of stuffing the data byte into the data_buffer, is bit arithmetic
@@ -200,9 +214,17 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt
200
214
latches the data on the rising or falling edge of the write pin. Remember: This method
201
215
will require the write pin to be controlled by the same GPIO register as the data pins. */
202
216
203
- * clear_write = mask ; // clear the write pin (See comment above, this may not be necessary).
217
+ // Can ignore this line if the write pin is in the same register as the data pins
218
+ // *clear_write = mask; // clear the write pin (See comment above, this may not be necessary).
219
+
220
+ // *** Original code
204
221
* (data_address ) = data [i ]; // stuff the data byte into the data_buffer at the correct offset byte location
205
222
* self -> bus = data_buffer ; // write the data to the output register
223
+
224
+ // *** Bit shifting trial - didn't have much improvement in performance
225
+ // *output_register = (data_buffer | (((uint32_t) data[i]) << bit_shift));
226
+
227
+
206
228
* set_write = mask ; // set the write pin
207
229
}
208
230
0 commit comments