不韋 呂 / UIT_WS2812B

Dependents:   Demo_WS2812B_SPI

Revision:
4:874beb47b375
Parent:
3:e09aafc9cabe
--- a/ws2812B.cpp	Mon Sep 26 02:05:50 2016 +0000
+++ b/ws2812B.cpp	Mon Nov 21 09:28:49 2016 +0000
@@ -2,21 +2,23 @@
 //  SPI を使って WS2812B を点灯するためのクラス
 //      サポートするボード: Nucleo-F401RE, Nucleo-F446RE
 //
-//  2016/09/26, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/11/21, Copyright (c) 2016 MIKAMI, Naoki
 //--------------------------------------------------------
 
 #include "ws2812B.hpp"
+#include "PeripheralPins.h"     // for pinmap_peripheral()
 
 namespace Mikami
 {
     WS2812B::WS2812B(PinName pin, bool inv)
-        : SPI(pin, NC, NC), mySpi_((SPI_TypeDef *)_spi.spi)
+        : spi_(pin, NC, NC),
+          mySpi_((SPI_TypeDef *)pinmap_peripheral(pin, PinMap_SPI_MOSI))
     {
-        format(8, 0);
+        spi_.format(8, 0);
         // クロックを 23 MHz 以下で最大の値に設定
         //      F401RE: 21.0 MHz
         //      F446RE: 22.5 MHz
-        frequency(23000000);
+        spi_.frequency(23000000);
 
         if (!inv) fp = &WS2812B::SendByteNorm;
         else      fp = &WS2812B::SendByteInv;