Invert LED outputs, set to open drain

This commit is contained in:
fruchti 2019-12-22 19:05:46 +01:00
parent fe7a2f1869
commit 8891670bb7
2 changed files with 7 additions and 6 deletions

View file

@ -1 +1 @@
80 82

View file

@ -42,11 +42,11 @@ static void LED_RefreshDMABuffer(void)
{ {
if(gamma_corrected & (1 << j)) if(gamma_corrected & (1 << j))
{ {
LED_DMABuffer[j] |= 1 << i; LED_DMABuffer[j] &= ~(1 << i);
} }
else else
{ {
LED_DMABuffer[j] &= ~(1 << i); LED_DMABuffer[j] |= 1 << i;
} }
} }
} }
@ -118,14 +118,14 @@ static void LED_StartBCM(void)
"nop;" "nop;"
"nop;" "nop;"
"nop;" "nop;"
"str %[zero], [%[odr]];" "str %[off], [%[odr]];"
: :
: [odr] "l" ((uint32_t)&(GPIOA->ODR)), : [odr] "l" ((uint32_t)&(GPIOA->ODR)),
[d0] "r" (LED_DMABuffer[0]), [d0] "r" (LED_DMABuffer[0]),
[d1] "r" (LED_DMABuffer[1]), [d1] "r" (LED_DMABuffer[1]),
[d2] "r" (LED_DMABuffer[2]), [d2] "r" (LED_DMABuffer[2]),
[d3] "r" (LED_DMABuffer[3]), [d3] "r" (LED_DMABuffer[3]),
[zero] "r" (0) [off] "r" (LED_ODR_MASK)
:); :);
// Enable TIM3 for the rest of the bits // Enable TIM3 for the rest of the bits
@ -138,7 +138,8 @@ void LED_Init(void)
RCC->AHBENR |= RCC_AHBENR_DMA1EN; RCC->AHBENR |= RCC_AHBENR_DMA1EN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
GPIOA->ODR &= ~LED_ODR_MASK; GPIOA->ODR |= LED_ODR_MASK;
GPIOA->OTYPER |= LED_ODR_MASK;
GPIOA->MODER = (GPIOA->MODER & ~LED_MODER_MASK) | LED_MODER; GPIOA->MODER = (GPIOA->MODER & ~LED_MODER_MASK) | LED_MODER;
TIM3->CR1 = 0x0000; TIM3->CR1 = 0x0000;