Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
f71f37e4
Commit
f71f37e4
authored
Aug 07, 2016
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
esp8266/esp_mphal.h: Add mp_hal_ticks_cpu() for reuse.
parent
c2070d77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
esp8266/esp_mphal.h
esp8266/esp_mphal.h
+6
-0
esp8266/espneopixel.c
esp8266/espneopixel.c
+4
-10
No files found.
esp8266/esp_mphal.h
View file @
f71f37e4
...
...
@@ -47,6 +47,12 @@ void mp_hal_init(void);
void
mp_hal_rtc_init
(
void
);
uint32_t
mp_hal_ticks_us
(
void
);
__attribute__
((
always_inline
))
static
inline
uint32_t
mp_hal_ticks_cpu
(
void
)
{
uint32_t
ccount
;
__asm__
__volatile__
(
"rsr %0,ccount"
:
"=a"
(
ccount
));
return
ccount
;
}
void
mp_hal_delay_us
(
uint32_t
);
void
mp_hal_set_interrupt_char
(
int
c
);
uint32_t
mp_hal_get_cpu_freq
(
void
);
...
...
esp8266/espneopixel.c
View file @
f71f37e4
...
...
@@ -9,16 +9,10 @@
#include "eagle_soc.h"
#include "user_interface.h"
#include "espneopixel.h"
#include "esp_mphal.h"
#define NEO_KHZ400 (1)
static
uint32_t
_getCycleCount
(
void
)
__attribute__
((
always_inline
));
static
inline
uint32_t
_getCycleCount
(
void
)
{
uint32_t
ccount
;
__asm__
__volatile__
(
"rsr %0,ccount"
:
"=a"
(
ccount
));
return
ccount
;
}
void
/*ICACHE_RAM_ATTR*/
esp_neopixel_write
(
uint8_t
pin
,
uint8_t
*
pixels
,
uint32_t
numBytes
,
bool
is800KHz
)
{
uint8_t
*
p
,
*
end
,
pix
,
mask
;
...
...
@@ -49,10 +43,10 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32
for
(
t
=
time0
;;
t
=
time0
)
{
if
(
pix
&
mask
)
t
=
time1
;
// Bit high duration
while
(((
c
=
_getCycleCount
())
-
startTime
)
<
period
);
// Wait for bit start
while
(((
c
=
mp_hal_ticks_cpu
())
-
startTime
)
<
period
);
// Wait for bit start
GPIO_REG_WRITE
(
GPIO_OUT_W1TS_ADDRESS
,
pinMask
);
// Set high
startTime
=
c
;
// Save start time
while
(((
c
=
_getCycleCount
())
-
startTime
)
<
t
);
// Wait high duration
while
(((
c
=
mp_hal_ticks_cpu
())
-
startTime
)
<
t
);
// Wait high duration
GPIO_REG_WRITE
(
GPIO_OUT_W1TC_ADDRESS
,
pinMask
);
// Set low
if
(
!
(
mask
>>=
1
))
{
// Next bit/byte
if
(
p
>=
end
)
break
;
...
...
@@ -60,5 +54,5 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32
mask
=
0x80
;
}
}
while
((
_getCycleCount
()
-
startTime
)
<
period
);
// Wait for last bit
while
((
mp_hal_ticks_cpu
()
-
startTime
)
<
period
);
// Wait for last bit
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment