summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-04-27 13:58:42 +0200
committerjaseg <git@jaseg.net>2018-04-27 13:58:42 +0200
commit641ed2a092df959f478390c52f90837b30a5332c (patch)
tree594f5d043af7f6acb2b90d397ea57b47ff5a3b68
parente0eb2d53a9d93ed3e968f9d40b89df970045dfe1 (diff)
downloadolsndot-641ed2a092df959f478390c52f90837b30a5332c.tar.gz
olsndot-641ed2a092df959f478390c52f90837b30a5332c.tar.bz2
olsndot-641ed2a092df959f478390c52f90837b30a5332c.zip
Make channel count configurable
-rw-r--r--firmware/global.h2
-rw-r--r--firmware/main.c8
-rw-r--r--firmware/serial.h2
3 files changed, 7 insertions, 5 deletions
diff --git a/firmware/global.h b/firmware/global.h
index 3e585f6..0098d38 100644
--- a/firmware/global.h
+++ b/firmware/global.h
@@ -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
diff --git a/firmware/main.c b/firmware/main.c
index ec56767..c6a4ac9 100644
--- a/firmware/main.c
+++ b/firmware/main.c
@@ -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++;
diff --git a/firmware/serial.h b/firmware/serial.h
index 94cfd57..96d0e70 100644
--- a/firmware/serial.h
+++ b/firmware/serial.h
@@ -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;
};