32
32
#include "py/mperrno.h"
33
33
#include "py/runtime.h"
34
34
#include "common-hal/microcontroller/Pin.h"
35
- #include "fsl_gpio.h"
36
35
37
36
uint64_t next_start_tick_ms = 0 ;
38
37
uint32_t next_start_tick_us = 1000 ;
@@ -45,7 +44,7 @@ uint32_t next_start_tick_us = 1000;
45
44
#pragma GCC push_options
46
45
#pragma GCC optimize ("Os")
47
46
48
- void common_hal_neopixel_write (const digitalio_digitalinout_obj_t * digitalinout , uint8_t * pixels ,
47
+ void PLACE_IN_ITCM ( common_hal_neopixel_write ) (const digitalio_digitalinout_obj_t * digitalinout , uint8_t * pixels ,
49
48
uint32_t numBytes ) {
50
49
uint8_t * p = pixels , * end = p + numBytes , pix = * p ++ , mask = 0x80 ;
51
50
uint32_t start = 0 ;
@@ -54,14 +53,10 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
54
53
//assumes 800_000Hz frequency
55
54
//Theoretical values here are 800_000 -> 1.25us, 2500000->0.4us, 1250000->0.8us
56
55
//TODO: try to get dynamic weighting working again
57
- #ifdef MIMXRT1011_SERIES
58
- uint32_t sys_freq = CLOCK_GetCoreFreq ();
59
- #else
60
- uint32_t sys_freq = CLOCK_GetAhbFreq ();
61
- #endif
62
- uint32_t interval = sys_freq /MAGIC_800_INT ;
63
- uint32_t t0 = (sys_freq /MAGIC_800_T0H );
64
- uint32_t t1 = (sys_freq /MAGIC_800_T1H );
56
+ const uint32_t sys_freq = SystemCoreClock ;
57
+ const uint32_t interval = (sys_freq / MAGIC_800_INT );
58
+ const uint32_t t0 = (sys_freq / MAGIC_800_T0H );
59
+ const uint32_t t1 = (sys_freq / MAGIC_800_T1H );
65
60
66
61
// This must be called while interrupts are on in case we're waiting for a
67
62
// future ms tick.
@@ -79,9 +74,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
79
74
for (;;) {
80
75
cyc = (pix & mask ) ? t1 : t0 ;
81
76
start = DWT -> CYCCNT ;
82
- GPIO_PinWrite ( gpio , pin , 1 );
77
+ gpio -> DR |= ( 1U << pin );
83
78
while ((DWT -> CYCCNT - start ) < cyc );
84
- GPIO_PinWrite ( gpio , pin , 0 );
79
+ gpio -> DR &= ~( 1U << pin );
85
80
while ((DWT -> CYCCNT - start ) < interval );
86
81
if (!(mask >>= 1 )) {
87
82
if (p >= end ) break ;
0 commit comments