Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Multi_WS2811 by
WS2811.h
00001 // Mbed library to control WS2801-based RGB LED Strips 00002 // some portions (c) 2011 Jelmer Tiete 00003 // This library is ported from the Arduino implementation of Adafruit Industries 00004 // found at: http://github.com/adafruit/LPD8806 00005 // and their strips: http://www.adafruit.com/products/306 00006 // Released under the MIT License: http://mbed.org/license/mit 00007 // 00008 /*****************************************************************************/ 00009 00010 // Heavily modified by Jas Strong, 2012-10-04 00011 // Changed to use a virtual base class and to use software SPI. 00012 // 00013 // Modified by Ned Konz, December 2013. 00014 // Using three-phase DMA ala Paul Stoffegren's version. 00015 00016 #ifndef MBED_WS2811_H 00017 #define MBED_WS2811_H 00018 00019 #include "mbed.h" 00020 #include "LedStrip.h" 00021 00022 #define MAX_LEDS_PER_STRIP 64 00023 00024 extern "C" void DMA0_IRQHandler(); 00025 extern "C" void TPM0_IRQHandler(); 00026 00027 class WS2811 : public LedStrip 00028 { 00029 public: 00030 WS2811(unsigned n, unsigned pinNumber); 00031 00032 virtual void begin(); 00033 virtual void show(); 00034 virtual void blank(); 00035 00036 static void startDMA(); 00037 00038 private: 00039 uint32_t pinMask; 00040 00041 void writePixel(unsigned n, uint8_t *p); 00042 00043 // Class Static: 00044 00045 static bool initialized; 00046 static uint32_t enabledPins; 00047 static volatile bool dma_done; 00048 static void wait_for_dma_done() { while (!dma_done) __WFI(); } 00049 00050 static void writeByte(uint8_t byte, uint32_t mask, uint32_t *dest); 00051 00052 static void hw_init(); 00053 static void io_init(); 00054 static void clock_init(); 00055 static void dma_init(); 00056 static void tpm_init(); 00057 static void dma_data_init(); 00058 00059 friend void TPM0_IRQHandler(); 00060 }; 00061 00062 #endif 00063
Generated on Sun Jul 17 2022 11:35:39 by
1.7.2
