This is a bitbang library for WS2812. I test it with STM32F411RE (Nucleo 441RE). If you want to use another board, u need to adjust the sum of asm("nop"). In the example program i put some code to measure how many asm("nop") do we need. See more detail about WS2812 timing https://cdn-shop.adafruit.com/datasheets/WS2812.pdf

Dependents:   STM32FC_RGB_WS2812

Revision:
0:f080cb888db6
Child:
1:8910a1fcbdb0
diff -r 000000000000 -r f080cb888db6 WS2812.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WS2812.h	Sat Dec 10 08:18:58 2016 +0000
@@ -0,0 +1,31 @@
+#ifndef WS2812_H
+#define WS2812_H
+#include "mbed.h"
+#include "USBSerial.h"
+
+class WS2812
+{
+  public:
+  
+  uint8_t Red;
+  uint8_t Green;
+  uint8_t Blue;
+  
+  WS2812(PinName pin, int qty);
+  ~WS2812();
+  void writeColor(uint32_t RGB);
+  void send1Color(uint32_t RGB);
+  
+  void sendReset();
+  
+  private:
+  int LED_Qty;
+  PinName dataPin;
+  DigitalOut dataOut;
+  
+  void writeByte(uint8_t data);
+  void send0();
+  void send1();
+};
+
+#endif
\ No newline at end of file