Reset row shift register immediately after reset

This commit is contained in:
fruchti 2020-07-15 15:05:09 +02:00
parent 75d280c8ea
commit d2557e969d
4 changed files with 19 additions and 11 deletions

View file

@ -1 +1 @@
238
257

View file

@ -188,18 +188,9 @@ static inline void LED_PageFlip(void)
LED_QueuePageFlip = false;
}
void LED_Init(void)
void LED_InitShiftRegister(void)
{
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
RCC->AHBENR |= RCC_AHBENR_GPIOFEN;
RCC->AHBENR |= RCC_AHBENR_DMA1EN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
// Fill both DMA buffers
LED_Commit();
LED_PageFlip();
LED_Commit();
LED_PageFlip();
GPIOF->ODR &= ~(1 << PIN_ROW_SCK) & ~(1 << PIN_ROW_DATA);
GPIOF->MODER = (GPIOF->MODER
@ -215,6 +206,19 @@ void LED_Init(void)
}
// All shift register outputs are now '1'. Because the rows are driven with
// external transistors, this means all rows are off.
}
void LED_Init(void)
{
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
RCC->AHBENR |= RCC_AHBENR_DMA1EN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
// Fill both DMA buffers
LED_Commit();
LED_PageFlip();
LED_Commit();
LED_PageFlip();
GPIOA->ODR |= LED_ODR_MASK;
GPIOA->PUPDR &= ~LED_MODER_MASK;

View file

@ -23,6 +23,7 @@ extern LED_Colour_t LED_PixelData[LED_ROWS * LED_COLUMNS / 3];
// externally. Will not be set to false within led.c.
extern volatile bool LED_FrameFlag;
void LED_InitShiftRegister(void);
void LED_Init(void);
// Display LED_PixelData, starting with the next frame

View file

@ -2,6 +2,8 @@
int main(void)
{
LED_InitShiftRegister();
// Delay a bit to make programming easier
for(unsigned int i = 0; i < 10000000; i++)
{
@ -15,6 +17,7 @@ int main(void)
uint8_t *data = (uint8_t*)LED_PixelData;
while(1)
{
__WFI();
LightSensor_Poll();
uint8_t brightness = LightSensor_RelativeBrightness * 255;
if(LED_FrameFlag)