Skip to content

Commit 1679790

Browse files
committed
Tweaked to run without delays on zero w
1 parent 359a27e commit 1679790

File tree

1 file changed

+10
-0
lines changed
  • ports/broadcom/common-hal/neopixel_write

1 file changed

+10
-0
lines changed

ports/broadcom/common-hal/neopixel_write/__init__.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
9797
COMPLETE_MEMORY_READS;
9898
icnt = 0;
9999
while ((CM_PWM->CS_b.BUSY == 0) & (icnt++ < 1000)) {
100+
COMPLETE_MEMORY_READS;
100101
}
101102
}
102103

@@ -142,19 +143,22 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
142143
icnt = 0;
143144
while ((pwm->STA_b.FULL1 == 1) & (icnt++ < 150)) {
144145
RUN_BACKGROUND_TASKS;
146+
COMPLETE_MEMORY_READS;
145147
}
146148
// Dummy value for the first channel.
147149
pwm->FIF1 = 0x000000;
148150
}
149151
icnt = 0;
150152
while ((pwm->STA_b.FULL1 == 1) & (icnt++ < 150)) {
151153
RUN_BACKGROUND_TASKS;
154+
COMPLETE_MEMORY_READS;
152155
}
153156
pwm->FIF1 = expanded;
154157
if (channel == 0) {
155158
icnt = 0;
156159
while ((pwm->STA_b.FULL1 == 1) & (icnt++ < 150)) {
157160
RUN_BACKGROUND_TASKS;
161+
COMPLETE_MEMORY_READS;
158162
}
159163
// Dummy value for the second channel.
160164
pwm->FIF1 = 0x000000;
@@ -164,17 +168,23 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
164168
icnt = 0;
165169
while ((pwm->STA_b.EMPT1 == 0) & (icnt++ < 2500)) {
166170
RUN_BACKGROUND_TASKS;
171+
COMPLETE_MEMORY_READS;
167172
}
168173
// Wait for transmission to start.
169174
icnt = 0;
170175
while (((pwm->STA_b.STA1 == 0) & (pwm->STA_b.STA2 == 0)) & (icnt++ < 150)) {
171176
RUN_BACKGROUND_TASKS;
177+
COMPLETE_MEMORY_READS;
172178
}
173179
// Wait for transmission to complete.
174180
icnt = 0;
175181
while (((pwm->STA_b.STA1 == 1) | (pwm->STA_b.STA2 == 1)) & (icnt++ < 150)) {
176182
RUN_BACKGROUND_TASKS;
183+
COMPLETE_MEMORY_READS;
177184
}
185+
// Shouldn't be anything left in queue but clear it so the clock doesn't crash if there is
186+
pwm->CTL = PWM0_CTL_CLRF1_Msk;
187+
COMPLETE_MEMORY_READS;
178188

179189
gpio_set_function(digitalinout->pin->number, GPIO_FUNCTION_OUTPUT);
180190

0 commit comments

Comments
 (0)