some adjustments that didn't work
This commit is contained in:
parent
75f1181ad6
commit
309bb38c7e
@ -8,20 +8,20 @@
|
||||
#include "ws2812.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
static uint8_t *fb;
|
||||
static uint32_t *fb;
|
||||
static int sLeds;
|
||||
static stm32_gpio_t *sPort;
|
||||
static uint32_t sMask;
|
||||
uint8_t* dma_source;
|
||||
uint32_t * dma_source;
|
||||
|
||||
void setColor(uint8_t color, uint8_t *buf,uint32_t mask){
|
||||
void setColor(uint8_t color, uint32_t *buf,uint32_t mask){
|
||||
int i;
|
||||
for (i=0;i<8;i++){
|
||||
buf[i]=((color<<i)&0b10000000?0x0:mask);
|
||||
}
|
||||
}
|
||||
|
||||
void setColorRGB(Color c, uint8_t *buf, uint32_t mask){
|
||||
void setColorRGB(Color c, uint32_t *buf, uint32_t mask){
|
||||
setColor(c.G,buf, mask);
|
||||
setColor(c.R,buf+8, mask);
|
||||
setColor(c.B,buf+16, mask);
|
||||
@ -43,7 +43,7 @@ void setColorRGB(Color c, uint8_t *buf, uint32_t mask){
|
||||
* @param[out] o_fb initialized frame buffer
|
||||
*
|
||||
*/
|
||||
void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb) {
|
||||
void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint32_t **o_fb) {
|
||||
sLeds=leds;
|
||||
sPort=port;
|
||||
sMask=mask;
|
||||
@ -72,7 +72,7 @@ void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb)
|
||||
0,
|
||||
0,
|
||||
};
|
||||
dma_source = chHeapAlloc(NULL, 1);
|
||||
dma_source = chHeapAlloc(NULL, 4);
|
||||
fb = chHeapAlloc(NULL, ((sLeds) * 24)+10);
|
||||
*o_fb=fb;
|
||||
int j;
|
||||
@ -85,8 +85,8 @@ void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb)
|
||||
dmaStreamSetTransactionSize(STM32_DMA1_STREAM2, (sLeds) * 24);
|
||||
dmaStreamSetMode(
|
||||
STM32_DMA1_STREAM2,
|
||||
STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_MINC | STM32_DMA_CR_PSIZE_BYTE
|
||||
| STM32_DMA_CR_MSIZE_BYTE | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(2));
|
||||
STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_MINC | STM32_DMA_CR_PSIZE_WORD
|
||||
| STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(2));
|
||||
// DMA stream 3, triggered by pwm update event. output high at beginning of signal
|
||||
dmaStreamAllocate(STM32_DMA1_STREAM3, 10, NULL, NULL);
|
||||
dmaStreamSetPeripheral(STM32_DMA1_STREAM3, &(sPort->BSRR.H.set));
|
||||
@ -94,7 +94,7 @@ void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb)
|
||||
dmaStreamSetTransactionSize(STM32_DMA1_STREAM3, 1);
|
||||
dmaStreamSetMode(
|
||||
STM32_DMA1_STREAM3, STM32_DMA_CR_TEIE |
|
||||
STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE
|
||||
STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD
|
||||
| STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
|
||||
// DMA stream 6, triggered by channel1 update event. reset output value late to indicate "1" bit to ws2812.
|
||||
// always triggers but no affect if dma stream 2 already change output value to 0
|
||||
@ -104,7 +104,7 @@ void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb)
|
||||
dmaStreamSetTransactionSize(STM32_DMA1_STREAM6, 1);
|
||||
dmaStreamSetMode(
|
||||
STM32_DMA1_STREAM6,
|
||||
STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE
|
||||
STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD
|
||||
| STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
|
||||
pwmStart(&PWMD2, &pwmc2);
|
||||
pwmStart(&PWMD3, &pwmc3);
|
||||
@ -137,7 +137,7 @@ void ledDriverWaitCycle(void){
|
||||
while (PWMD2.tim->CNT < 90 * sLeds * 24 / 90){chThdSleepMicroseconds(1);};
|
||||
}
|
||||
|
||||
void testPatternFB(uint8_t *fb){
|
||||
void testPatternFB(uint32_t *fb){
|
||||
int i;
|
||||
Color tmpC = {rand()%256, rand()%256, rand()%256};
|
||||
for (i=0;i<sLeds;i++){
|
||||
|
@ -20,9 +20,9 @@ struct Color {
|
||||
uint8_t B;
|
||||
};
|
||||
|
||||
void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb);
|
||||
void setColorRGB(Color c, uint8_t *buf, uint32_t mask);
|
||||
void testPatternFB(uint8_t *fb);
|
||||
void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint32_t **o_fb);
|
||||
void setColorRGB(Color c, uint32_t *buf, uint32_t mask);
|
||||
void testPatternFB(uint32_t *fb);
|
||||
void ledDriverWaitCycle(void);
|
||||
|
||||
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
#include "qwiic_hub.h"
|
||||
|
||||
uint8_t *o_fb;
|
||||
uint32_t *o_fb;
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
ledDriverInit(1, GPIOB, 0b100000000, &o_fb);
|
||||
ledDriverInit(1, GPIOB, (1UL<<8), &o_fb);
|
||||
testPatternFB(o_fb);
|
||||
|
||||
matrix_init_user();
|
||||
|
Loading…
Reference in New Issue
Block a user