diff --git a/build-number.txt b/build-number.txt index 1cf253f..a700e79 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -238 +257 diff --git a/src/led.c b/src/led.c index 6be8b46..d5308ed 100644 --- a/src/led.c +++ b/src/led.c @@ -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; diff --git a/src/led.h b/src/led.h index 0b5cd9c..44874cf 100644 --- a/src/led.h +++ b/src/led.h @@ -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 diff --git a/src/main.c b/src/main.c index 356ebc1..af7dc5a 100644 --- a/src/main.c +++ b/src/main.c @@ -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)