Allow using 9 columns to enable debugging

This commit is contained in:
fruchti 2020-09-20 16:40:55 +02:00
parent 2a3db7b9fb
commit 1e8da90156
4 changed files with 45 additions and 3 deletions

View file

@ -1 +1 @@
434 442

View file

@ -4,12 +4,21 @@
volatile bool Animation_FrameFlag = false; volatile bool Animation_FrameFlag = false;
#if LED_COLUMNS == 12
const unsigned int Animation_LEDOrder[LED_COUNT] = const unsigned int Animation_LEDOrder[LED_COUNT] =
{ {
19, 27, 21, 13, 0, 4, 24, 8, 12, 15, 6, 5, 28, 19, 27, 21, 13, 0, 4, 24, 8, 12, 15, 6, 5, 28,
29, 17, 3, 18, 26, 22, 10, 16, 20, 30, 1, 29, 17, 3, 18, 26, 22, 10, 16, 20, 30, 1,
25, 2, 14, 31, 7, 11, 9, 23 25, 2, 14, 31, 7, 11, 9, 23
}; };
#elif LED_COLUMNS == 9
const unsigned int Animation_LEDOrder[LED_COUNT] =
{
19, 21, 13, 0, 4, 8, 12, 15, 6, 5,
17, 3, 18, 22, 10, 16, 20, 1,
2, 14, 7, 11, 9, 23
};
#endif
LED_Colour_t Animation_GetColour(unsigned int step, unsigned int brightness) LED_Colour_t Animation_GetColour(unsigned int step, unsigned int brightness)
{ {

View file

@ -6,6 +6,7 @@ volatile bool LED_FrameFlag = false;
volatile bool LED_SuspendFlag = false; volatile bool LED_SuspendFlag = false;
bool LED_Suspended = false; bool LED_Suspended = false;
#if LED_COLUMNS == 12
#define LED_ODR_MASK ((1 << PIN_LED_R_0) | (1 << PIN_LED_G_0) \ #define LED_ODR_MASK ((1 << PIN_LED_R_0) | (1 << PIN_LED_G_0) \
| (1 << PIN_LED_B_0) | (1 << PIN_LED_R_1) \ | (1 << PIN_LED_B_0) | (1 << PIN_LED_R_1) \
| (1 << PIN_LED_G_1) | (1 << PIN_LED_B_1) \ | (1 << PIN_LED_G_1) | (1 << PIN_LED_B_1) \
@ -26,6 +27,27 @@ bool LED_Suspended = false;
| (1 << PIN_LED_R_2 * 2) | (1 << PIN_LED_G_2 * 2) \ | (1 << PIN_LED_R_2 * 2) | (1 << PIN_LED_G_2 * 2) \
| (1 << PIN_LED_B_2 * 2) | (1 << PIN_LED_R_3 * 2) \ | (1 << PIN_LED_B_2 * 2) | (1 << PIN_LED_R_3 * 2) \
| (1 << PIN_LED_G_3 * 2) | (1 << PIN_LED_B_3 * 2)) | (1 << PIN_LED_G_3 * 2) | (1 << PIN_LED_B_3 * 2))
#elif LED_COLUMNS == 9
#define LED_ODR_MASK ((1 << PIN_LED_R_0) | (1 << PIN_LED_G_0) \
| (1 << PIN_LED_B_0) | (1 << PIN_LED_R_1) \
| (1 << PIN_LED_G_1) | (1 << PIN_LED_B_1) \
| (1 << PIN_LED_R_2) | (1 << PIN_LED_G_2) \
| (1 << PIN_LED_B_2))
#define LED_MODER_MASK ((3 << PIN_LED_R_0 * 2) | (3 << PIN_LED_G_0 * 2) \
| (3 << PIN_LED_B_0 * 2) | (3 << PIN_LED_R_1 * 2) \
| (3 << PIN_LED_G_1 * 2) | (3 << PIN_LED_B_1 * 2) \
| (3 << PIN_LED_R_2 * 2) | (3 << PIN_LED_G_2 * 2) \
| (3 << PIN_LED_B_2 * 2))
#define LED_MODER ((1 << PIN_LED_R_0 * 2) | (1 << PIN_LED_G_0 * 2) \
| (1 << PIN_LED_B_0 * 2) | (1 << PIN_LED_R_1 * 2) \
| (1 << PIN_LED_G_1 * 2) | (1 << PIN_LED_B_1 * 2) \
| (1 << PIN_LED_R_2 * 2) | (1 << PIN_LED_G_2 * 2) \
| (1 << PIN_LED_B_2 * 2))
#else
#error Unsupported LED column count
#endif
// TIM3 is clocked by APB1 and thus receives only half the system clock. The 4 // TIM3 is clocked by APB1 and thus receives only half the system clock. The 4
// LSBs have bit lengths 2, 4, 8, and 16 cycles and are generated blocking from // LSBs have bit lengths 2, 4, 8, and 16 cycles and are generated blocking from
@ -35,6 +57,7 @@ static const uint16_t LED_BitLengths[LED_BITS - 4] =
16, 32, 64, 128, 256, 512, 1024, 2048 16, 32, 64, 128, 256, 512, 1024, 2048
}; };
#if LED_COLUMNS == 12
static const int LED_Pins[LED_COLUMNS] = static const int LED_Pins[LED_COLUMNS] =
{ {
PIN_LED_R_0, PIN_LED_G_0, PIN_LED_B_0, PIN_LED_R_0, PIN_LED_G_0, PIN_LED_B_0,
@ -42,6 +65,14 @@ static const int LED_Pins[LED_COLUMNS] =
PIN_LED_R_2, PIN_LED_G_2, PIN_LED_B_2, PIN_LED_R_2, PIN_LED_G_2, PIN_LED_B_2,
PIN_LED_R_3, PIN_LED_G_3, PIN_LED_B_3 PIN_LED_R_3, PIN_LED_G_3, PIN_LED_B_3
}; };
#elif LED_COLUMNS == 9
static const int LED_Pins[LED_COLUMNS] =
{
PIN_LED_R_0, PIN_LED_G_0, PIN_LED_B_0,
PIN_LED_R_1, PIN_LED_G_1, PIN_LED_B_1,
PIN_LED_R_2, PIN_LED_G_2, PIN_LED_B_2
};
#endif
// Number of 16-bit values to be transferred to the GPIO's output register via // Number of 16-bit values to be transferred to the GPIO's output register via
// DMA. Each value contains output values for all columns. For each row, a // DMA. Each value contains output values for all columns. For each row, a

View file

@ -5,9 +5,11 @@
#include "stm32f030x6.h" #include "stm32f030x6.h"
#include "pinning.h" #include "pinning.h"
#define LED_BITS 12 #define LED_BITS 12 // BCM resolution in bits
#define LED_ROWS 8 // Rows are driven by a shift register #define LED_ROWS 8 // Rows are driven by a shift register
#define LED_COLUMNS 12 // Columns are driven by the MCU directly #define LED_COLUMNS 12 // Columns are driven by the MCU directly.
// Set to 9 to free the SWD pins and enable
// debugging.
#define LED_COUNT (LED_ROWS * LED_COLUMNS / 3) #define LED_COUNT (LED_ROWS * LED_COLUMNS / 3)
typedef struct typedef struct