WS2812 範例編譯錯誤

我使用 Arduino IDE V1.18.13 及 Realtek Lib V3.1.4

測試 WS2812B_Pattrms 範例會出現編譯錯誤.

以下訊息
Arduino: 1.8.13 (Windows 10), Board: “BW16 (RTL8720DN), Disable, Enable”

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp: In member function ‘void WS2812B::show()’:

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp:87:38: error: no matching function for call to ‘SPIClass::setDataMode(int, int, int)’

     SPI.setDataMode(SPI_SS, 12, 0);

                                  ^

In file included from C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.h:5:0,

             from C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp:1:

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\SPI\src/SPI.h:90:10: note: candidate: void SPIClass::setDataMode(uint8_t, uint8_t)

 void setDataMode(uint8_t _bits, uint8_t _mode);

      ^~~~~~~~~~~

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\SPI\src/SPI.h:90:10: note: candidate expects 2 arguments, 3 provided

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\SPI\src/SPI.h:91:10: note: candidate: void SPIClass::setDataMode(uint8_t)

 void setDataMode(uint8_t _mode);

      ^~~~~~~~~~~

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\SPI\src/SPI.h:91:10: note: candidate expects 1 argument, 3 provided

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp:88:29: error: ‘SPI1_MOSI’ was not declared in this scope

 } else if (_input_pin== SPI1_MOSI) {

                         ^~~~~~~~~

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp:90:9: error: ‘SPI1’ was not declared in this scope

     SPI1.begin();

     ^~~~

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp:92:23: error: ‘SPI1_MISO’ was not declared in this scope

     Pinmux_Config(SPI1_MISO, PINMUX_FUNCTION_GPIO);

                   ^~~~~~~~~

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp:93:23: error: ‘SPI1_SCLK’ was not declared in this scope

     Pinmux_Config(SPI1_SCLK, PINMUX_FUNCTION_GPIO);

                   ^~~~~~~~~

C:\Users\dell\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.4\libraries\WS2812B\src\WS2812B.cpp:94:23: error: ‘SPI1_SS’ was not declared in this scope

     Pinmux_Config(SPI1_SS, PINMUX_FUNCTION_GPIO);

                   ^~~~~~~

exit status 1

Error compiling for board BW16 (RTL8720DN).

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

@Kevin 你好,

謝謝你提出的這個問題,昨天已經驗證並解決了這個問題。 你可以參考以下鏈接的解決方案:

謝謝,已更新及測試OK

1 Like