Make channel count configurable

This commit is contained in:
jaseg 2018-04-27 13:58:42 +02:00
parent e0eb2d53a9
commit 641ed2a092
3 changed files with 7 additions and 5 deletions

View file

@ -21,7 +21,7 @@
* in main.c. */
#define NBITS 14
#define NCHANNELS 32
#define NCHANNELS 8
#define CHANNEL_SPEC 'H'
#define COLOR_SPEC COLOR_SPEC_RGBW
#define DEVICE_TYPE OLSNDOT_V1

View file

@ -253,7 +253,7 @@ void do_transpose(void) {
for (uint32_t i=0; i<NBITS; i++) {
uint32_t mask = 1<<i<<(MAX_BITS-NBITS); /* Bit mask for this bit value. */
uint32_t bv = 0; /* accumulator thing */
for (uint32_t j=0; j<32; j++)
for (uint32_t j=0; j<NCHANNELS; j++)
if (rx_buf.set_fb_rq.framebuf[j] & mask)
bv |= 1<<j;
brightness_by_bit[i] = bv;
@ -287,10 +287,12 @@ void TIM1_BRK_UP_TRG_COM_IRQHandler(void) {
* capture/compare channel 3 complementary outputs. The dead-time generator is used to sequence the clear and
* strobe edges one after another. Since there may be small variations in IRQ service latency it is critical to
* allow for some leeway between the end of this data transmission and strobe and clear. */
SPI1->DR = (val&0xffff);
while (SPI1->SR & SPI_SR_BSY);
#if NCHANNELS > 16
SPI1->DR = (val>>16);
while (SPI1->SR & SPI_SR_BSY);
#endif
SPI1->DR = (val&0xffff);
while (SPI1->SR & SPI_SR_BSY);
/* Increment the bit index for the next cycle */
idx++;

View file

@ -64,7 +64,7 @@ union rx_buf_union {
* |<----------------NBITS---------------->| |<>|--ignored
* | (MSB) brightness data (LSB) | |<>|--ignored
*/
struct __attribute__((packed)) { uint16_t framebuf[32]; uint8_t end[0]; } set_fb_rq;
struct __attribute__((packed)) { uint16_t framebuf[NCHANNELS]; uint8_t end[0]; } set_fb_rq;
uint8_t byte_data[0];
uint32_t mac_data;
};