Skip to content

Commit b9e562b

Browse files
committed
Fix statusbar with gcc
Prevent a few delay loops from being elided
1 parent 55901f0 commit b9e562b

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

LCM/Code/App/ws2812.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ void WS2812_Left(void)
157157

158158
void delay(uint16_t i)
159159
{
160-
while(i--);
160+
while(i--) {
161+
__ASM volatile("nop");
162+
}
161163
}
162164

163165
void WS2812_Refresh(void)

LCM/Code/Drive/io_ws2812.c

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,25 @@ void IO_WS2812_Init(void)
3939
}
4040
i=250 120us
4141
*/
42+
4243
void WS2812_0_Code(void)
4344
{
44-
GPIOD->BSRR = GPIO_Pin_4;
45-
GPIOD->BSRR = GPIO_Pin_4;
46-
GPIOD->BSRR = GPIO_Pin_4; //250ns
47-
45+
//250ns
46+
for(int i = 0; i != 3; ++i) {
47+
GPIOD->BSRR = GPIO_Pin_4;
48+
__ASM volatile("" ::: "memory");
49+
}
50+
4851
GPIOD->BRR = GPIO_Pin_4;
49-
// GPIOD->BRR = GPIO_Pin_4;
50-
// GPIOD->BRR = GPIO_Pin_4;
51-
// GPIOD->BRR = GPIO_Pin_4;
52-
// GPIOD->BRR = GPIO_Pin_4;
53-
// GPIOD->BRR = GPIO_Pin_4;
54-
// GPIOD->BRR = GPIO_Pin_4;
55-
// GPIOD->BRR = GPIO_Pin_4; //750ns
5652
}
5753

5854
void WS2812_1_Code(void)
5955
{
60-
GPIOD->BSRR = GPIO_Pin_4;
61-
GPIOD->BSRR = GPIO_Pin_4;
62-
GPIOD->BSRR = GPIO_Pin_4;
63-
GPIOD->BSRR = GPIO_Pin_4;
64-
GPIOD->BSRR = GPIO_Pin_4;
65-
GPIOD->BSRR = GPIO_Pin_4;
66-
GPIOD->BSRR = GPIO_Pin_4;
67-
GPIOD->BSRR = GPIO_Pin_4; //750ns
68-
56+
//750ns
57+
for(int i = 0; i != 8; ++i) {
58+
GPIOD->BSRR = GPIO_Pin_4;
59+
__ASM volatile("" ::: "memory");
60+
}
61+
6962
GPIOD->BRR = GPIO_Pin_4;
70-
// GPIOD->BRR = GPIO_Pin_4;
71-
// GPIOD->BRR = GPIO_Pin_4; //250ns
7263
}

0 commit comments

Comments
 (0)