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.
Diff: ws2812B.cpp
- Revision:
- 1:2d0f84d78ca2
- Parent:
- 0:160ed7a225a4
- Child:
- 2:2d4f2cc38f87
--- a/ws2812B.cpp Sat Sep 24 05:52:29 2016 +0000 +++ b/ws2812B.cpp Sat Sep 24 06:24:10 2016 +0000 @@ -13,14 +13,22 @@ { SPI mbedSpi_(pin, NC, NC); // MOSI, MISO, SCK + struct spi123{PinName pin; SPI_TypeDef *spi; }; +// ピンと SPI 番号の関係 #ifdef STM32F401xE - spi123 const *f4xx = f401; + static const spi123 f4xx[] = + {{ D4, SPI1}, { D11, SPI1}, {PB_15, SPI2}, + { PC_3, SPI2}, {PC_12, SPI3}, { NC, NULL}}; #else - spi123 const *f4xx = f446; -#endif + static const spi123 f4xx[] = + {{ D11, SPI1}, { A4, SPI2}, {PB_15, SPI2}, + { PC_3, SPI2}, { A3, SPI3}, { D4, SPI3}, + {PC_12, SPI3}, { NC, NULL}}; +#endif // STM32F401xE + for (int n=0; n<8; n++) { - if (f4xx[n].pin == D4) + if (f4xx[n].pin == pin) { mySpi_ = f4xx[n].spi; break; @@ -54,7 +62,7 @@ Dummy(); wait_us(50); } - + void WS2812B::Clear(int k) { Reset(); @@ -80,16 +88,4 @@ while ((mySpi_->SR & SPI_SR_TXE) != SPI_SR_TXE) {} mySpi_->DR = ~x; } - -// ピンと SPI 番号の関係 -#ifdef STM32F401xE - const WS2812B::spi123 WS2812B::f401[] = - {{ D4, SPI1}, { D11, SPI1}, {PB_15, SPI2}, - { PC_3, SPI2}, {PC_12, SPI3}, { NC, NULL}}; -#else - const WS2812B::spi123 WS2812B::f446[] = - {{ D11, SPI1}, { A4, SPI2}, {PB_15, SPI2}, - { PC_3, SPI2}, { A3, SPI3}, { D4, SPI3}, - {PC_12, SPI3}, { NC, NULL}}; -#endif // STM32F401xE }