|
Main /
NeoPixelLEDLibraryWS2812A few problems still exist with this library. It requires an edit in WS2812.cpp file. Instead of using __nop() use __NOP() and then run make. Follow these steps to build the libraries offline. Make sure the libraries are in the $PTII/vendors/mbed/libraries/ folder K64F 1. Go to: https://developer.mbed.org/users/bridadan/code/WS2812/export 2. Click on 'Export to Desktop IDE' 3. Choose the target as 'K64F' and the tool chain as 'GccArm' 4. Unzip the folder in $PTII/vendors/mbed/libraries/K64F/ 5. Go into the folder WS2812 6. Edit the Makefile. It should look like this: #Replace $PTII with the absolute path because Makefiles don't like environment variables
GCC_BIN = $PTII/vendors/mbed/gcc-arm/bin/
PROJECT = WS2812
OBJECTS = ./WS2812.o
SYS_OBJECTS =
INCLUDE_PATHS = -I. -I../../mbed -I../../mbed/TARGET_K64F -I../../mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM -I../../mbed/TARGET_K64F/TARGET_Freescale -I../../mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS -I../../mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F
INCLUDE_PATHS += -I../../mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/TARGET_FRDM -I../../mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/gpio -I../../mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/device -I../../mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/device/device -I../../mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/device/MK64F12
LIBRARY_PATHS =
LIBRARIES =
LINKER_SCRIPT = ../../mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld
7. Also change the .cpp.o section to use gnu++11 instead of gnu++98 .cpp.o:
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++11 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
8. Change the optimizer to use O2 instead of Os, it should look like the following: ifeq ($(DEBUG), 1)
CC_FLAGS += -DDEBUG -O0
else
CC_FLAGS += -DNDEBUG -O2
endif
9. In WS2812.cpp change the function to match the following Note: This is to correct the timing with offline compiler, if this needs to be adjusted, see: here. You might want to try changing the original code, however this led to some hard to get timing since the optimization is not as good on GCC (and over optimization takes out the __NOP()'s all together). void WS2812::write_offsets (int buf[],int r_offset, int g_offset, int b_offset) {
int i;
int totalSize = FRAME_SIZE * __size;
// Load the transmit buffer
__loadBuf(buf, r_offset, g_offset, b_offset);
// Entering timing critical section, so disabling interrupts
__disable_irq();
// Begin bit-banging
for (i = 0; i < totalSize; i++) {
if (__transmitBuf[i]){
//if(testVar++%2){
__gpo = 1;
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__gpo = 0;
__NOP();
__NOP();
} else {
__gpo = 1;
__NOP();
__gpo = 0;
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
}
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
}
// Exiting timing critical section, so enabling interrutps
__enable_irq();
}
10. Run make KL25Z 1. Go to: https://developer.mbed.org/users/bridadan/code/WS2812/export 2. Click on 'Export to Desktop IDE' 3. Choose the target as 'KL25Z' and the tool chain as 'GccArm' 4. Unzip the folder in $PTII/vendors/mbed/libraries/KL25Z/ 5. Go into the folder WS2812 6. Edit the Makefile. It should look like this: #Replace $PTII with the absolute path because Makefiles don't like environment variables
GCC_BIN = $PTII/vendors/mbed/gcc-arm/bin/
PROJECT = WS2812
OBJECTS = ./WS2812.o
SYS_OBJECTS =
INCLUDE_PATHS = -I. -I../../mbed -I../../mbed/TARGET_KL25Z -I../../mbed/TARGET_KL25Z/TARGET_Freescale/TARGET_KLXX -I../../mbed/TARGET_KL25Z/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z
LIBRARY_PATHS =
LIBRARIES =
LINKER_SCRIPT = ../../mbed/TARGET_KL25Z/TOOLCHAIN_GCC_ARM/MKL25Z4.ld
7. Also change the .cpp.o section to use gnu++11 instead of gnu++98 .cpp.o:
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++11 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
8. Run make |