ws2812b_spi.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef __WS1812B_SPI_H_
  2. #define __WS1812B_SPI_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include "define.h"
  9. #define USER_WS2812B_GPIO_RCC_ENABLE RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB, ENABLE);
  10. #define USER_WS2812B_SPI_RCC_ENABLE RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
  11. #define USER_WS2812B_DMA_RCC_ENABLE RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
  12. #define USER_WS2812B_SPI SPI2
  13. #define USER_WS2812B_DMA_CHANNEL DMA1_Channel5
  14. #define USER_WS2812B_DMA_IRQn DMA1_Channel5_IRQn
  15. #define USER_WS2812B_DMA_IRQHandler DMA1_Channel5_IRQHandler
  16. #define USER_WS2812B_DMA_IT_TC DMA1_IT_TC5
  17. #define USER_WS2812B_SPI_MOSI_GPIO GPIOB
  18. #define USER_WS2812B_SPI_MOSI_PIN GPIO_Pin_15
  19. #define USER_WS2812B_SPI_SCLK_GPIO GPIOB
  20. #define USER_WS2812B_SPI_SCLK_PIN GPIO_Pin_13
  21. void ws2812b_spi_Init(void);
  22. bool bWs2812b_spi_WriteByte(volatile uint8_t *TxData, uint32_t TxSize);
  23. void Ws2812b_spi_dma_init(uint8_t *txData, uint32_t txSize);
  24. #ifdef __cplusplus
  25. }
  26. #endif
  27. #endif /* __WS1812B_SPI_H_ */