8000 Delete unnecessary comments · kmatch98/circuitpython@10965e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10965e5

Browse files
committed
Delete unnecessary comments
1 parent 34aa01c commit 10965e5

File tree

1 file changed

+39
-51
lines changed

1 file changed

+39
-51
lines changed

ports/esp32s2/common-hal/displayio/ParallelBus.c

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,18 @@
3434
#include "shared-bindings/microcontroller/__init__.h"
3535

3636
/*
37-
* Current pin limitations:
38-
* data0 pin must be byte aligned and use pin numbers < 32 (data0 options: 0, 8, 16 or 24)
39-
* write pin must be pin number < 32.
40-
*
41-
* Future extensions:
42-
* 1. Allow data0 pin numbers >= 32.
43-
* 2. Allow write pin numbers >= 32.
44-
*/
37+
*
38+
* Current pin limitations for ESP32-S2 ParallelBus:
39+
* 1. data0 pin must be byte aligned (data0 pin options: 0, 8, 16 or 24)
40+
* 2. The 8 data lines must use pin numbers < 32
41+
* 3. The write pin must be pin number < 32.
42+
*
43+
*/
4544

4645
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
4746
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
4847
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
4948

50-
5149
uint8_t data_pin = data0->number;
5250
if ( (data_pin % 8 != 0) && (data_pin >= 32) ) {
5351
mp_raise_ValueError(translate("Data 0 pin must be byte aligned and < 32"));
@@ -63,21 +61,22 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel
6361
mp_raise_ValueError(translate("Write pin must be < 32"));
6462
}
6563

66-
gpio_dev_t *g = &GPIO; /* this is the GPIO registers, see "extern gpio_dev_t GPIO" from file:gpio_struct.h */
64+
gpio_dev_t *g = &GPIO; // this is the GPIO registers, see "extern gpio_dev_t GPIO" from file:gpio_struct.h
6765

68-
/* Setup the pins as "Simple GPIO outputs" see section 19.3.3 of the ESP32-S2 Reference Manual */
69-
/* Enable pins with "enable_w1ts" */
66+
// Setup the pins as "Simple GPIO outputs" see section 19.3.3 of the ESP32-S2 Reference Manual
67+
// Enable pins with "enable_w1ts"
7068

7169
for (uint8_t i = 0; i < 8; i++) {
7270
g->enable_w1ts = (0x1 << (data_pin + i));
7371
g->func_out_sel_cfg[data_pin + i].val= 256; /* setup output pin for simple GPIO Output, (0x100 = 256) */
7472

7573
}
7674

77-
/* I think there is a limitation of the ESP32-S2 that does not allow single-byte writes into
78-
the GPIO registers. See section 10.3.3 regarding "non-aligned writes" into the registers.
79-
If a method for writing single-byte writes is uncovered, this code can be modified to provide
80-
single-byte access into the output register */
75+
/* From my understanding, there is a limitation of the ESP32-S2 that does not allow single-byte writes
76+
* into the GPIO registers. See section 10.3.3 regarding "non-aligned writes" into the registers.
77+
* If a method for writing single-byte writes is uncovered, this code can be modified to provide
78+
* single-byte access into the output register
79+
*/
8180

8281
self->bus = (uint32_t*) &g->out; //pointer to GPIO output register (for pins 0-31)
8382

@@ -100,14 +99,16 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel
10099

101100
self->data0_pin = data_pin;
102101
self->write_group = &GPIO;
103-
/* Should modify the .h structure definitions if want to allow a write pin >= 32.
104-
If so, consider putting separate "clear_write" and "set_write" pointers into the .h in place of "write_group"
105-
to select between out_w1tc/out1_w1tc (clear) and out_w1ts/out1_w1ts (set) registers. */
102+
/* If we want to allow a write pin >= 32, should consider putting separate "clear_write" and
103+
* "set_write" pointers into the .h in place of "write_group"
104+
* to select between out_w1tc/out1_w1tc (clear) and out_w1ts/out1_w1ts (set) registers.
105+
*/
106106

107107
self->write_mask = 1 << (write->number % 32); /* the write pin triggers the LCD to latch the data */
108108
/* Note: As currently written for the ESP32-S2 port, the write pin must be a pin number less than 32
109-
This could be updated to accommodate 32 and higher by using the different construction of the
110-
address for writing to output pins >= 32, see related note above for 'self->write_group' */
109+
* This could be updated to accommodate 32 and higher by using the different construction of the
110+
* address for writing to output pins >= 32, see related note above for 'self->write_group'
111+
*/
111112

112113
/* SNIP - common setup of the reset pin, same as from SAMD and NRF ports */
113114
self->reset.base.type = &mp_type_NoneType;
@@ -174,57 +175,44 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt
174175
common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA);
175176

176177
/* Currently the write pin number must be < 32.
177-
Future: To accommodate write pin numbers >= 32, will need to update to choose a different register
178-
for set/reset (out1_w1tc and out1_w1ts) */
179-
180-
// **** Bit shifting trial
181-
// uint32_t* output_register = self->bus;
182-
// const uint8_t bit_shift=self->data0_pin;
178+
* Future: To accommodate write pin numbers >= 32, will need to update to choose the correct register
179+
* for the write pin set/clear (out_w1ts/out1_w1ts and out_w1tc/out1_w1tc)
180+
*/
183181

184182
uint32_t* clear_write = (uint32_t*) &self->write_group->out_w1tc;
185183
uint32_t* set_write = (uint32_t*) &self->write_group->out_w1ts;
186184

187185
const uint32_t mask = self->write_mask;
188186

189-
190187
/* Setup structures for data writing. The ESP32-S2 port differs from the SAMD and NRF ports
191-
because I have not found a way to write a single byte into the ESP32-S2 registers.
192-
For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes. */
188+
* because I have not found a way to write a single byte into the ESP32-S2 registers.
189+
* For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes.
190+
*/
193191

194-
*clear_write = mask; // Clear the write pin to prepare the registers before storing register settings into data_buffer
192+
*clear_write = mask; // Clear the write pin to prepare the registers before storing the
193+
// register value into data_buffer
195194

196195
const uint32_t data_buffer = *self->bus; // store the initial output register values into the data output buffer
197196
uint8_t* data_address = ((uint8_t*) &data_buffer) + (self->data0_pin / 8); /* address inside data_buffer where
198-
each data byte will be written (as offset by (data0_pin/8) number of bytes) */
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)));
197+
* each data byte will be written to the data pin registers
198+
*/
206199

207200
for (uint32_t i = 0; i < data_length; i++) {
208201

209202
/* Question: Is there a faster way of stuffing the data byte into the data_buffer, is bit arithmetic
210-
faster than writing to the byte address? */
203+
* faster than writing to the byte address?
204+
*/
211205

212-
/* Note: May be able to eliminate either the clear_write or set_write since the data buffer
213-
can be written with the write pin cleared or set already, and depending upon whether the display
214-
latches the data on the rising or falling edge of the write pin. Remember: This method
215-
will require the write pin to be controlled by the same GPIO register as the data pins. */
206+
/* Note: If the write pin and data pins are controlled by the same GPIO register, we can eliminate
207+
* the "clear_write" step below, since the write pin is cleared when the data_buffer is written
208+
* to the bus.
209+
* Remember: This method requires the write pin to be controlled by the same GPIO register as the data pins.
210+
*/
216211

217-
// Can ignore this line if the write pin is in the same register as the data pins
218212
// *clear_write = mask; // clear the write pin (See comment above, this may not be necessary).
219213

220-
// *** Original code
221214
*(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location
222215
*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-
228216
*set_write = mask; // set the write pin
229217
}
230218

0 commit comments

Comments
 (0)
0