From ff0ba8e4dfc9dbdb25acfc43c3e72af8aa098aca Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 30 May 2017 19:32:49 +0200 Subject: fw: Basic dimming working --- olsndot/firmware/main.c | 111 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 10 deletions(-) (limited to 'olsndot') diff --git a/olsndot/firmware/main.c b/olsndot/firmware/main.c index 4e26200..e4b3935 100644 --- a/olsndot/firmware/main.c +++ b/olsndot/firmware/main.c @@ -7,6 +7,11 @@ * Part number: STM32F030F4C6 */ +#define NBITS 12 +void do_transpose(void); +uint32_t brightness[8]; +volatile uint8_t brightness_by_bit[NBITS]; + int main(void) { RCC->CR |= RCC_CR_HSEON; while (!(RCC->CR&RCC_CR_HSERDY)); @@ -74,7 +79,7 @@ int main(void) { TIM1->SMCR = 0; TIM1->DIER = 0; - TIM1->PSC = 4; // debug + TIM1->PSC = 1; // debug /* CH2 - clear/!MR, CH3 - strobe/STCP */ TIM1->CCR2 = 1; TIM1->RCR = 0; @@ -92,16 +97,100 @@ int main(void) { TIM1->EGR |= TIM_EGR_UG; - for (;;) { - GPIOA->ODR ^= GPIO_ODR_6; - LL_mDelay(1); + while (42) { + /* + for (uint8_t i=0; i<8; i++) { + brightness[1] = brightness[5] = i; + brightness[2] = brightness[6] = 0; + brightness[3] = brightness[7] = 0; + do_transpose(); + LL_mDelay(500); + } + for (uint8_t i=0; i<8; i++) { + brightness[1] = brightness[5] = 0; + brightness[2] = brightness[6] = i; + brightness[3] = brightness[7] = 0; + do_transpose(); + LL_mDelay(500); + } + for (uint8_t i=0; i<8; i++) { + brightness[1] = brightness[5] = 0; + brightness[2] = brightness[6] = 0; + brightness[3] = brightness[7] = i; + do_transpose(); + LL_mDelay(500); + } + for (uint8_t i=0; i<8; i++) { + brightness[1] = brightness[5] = i; + brightness[2] = brightness[6] = i; + brightness[3] = brightness[7] = i; + do_transpose(); + LL_mDelay(500); + } + } + { + */ + for (uint32_t i=0; i<6; i++) { + for (uint32_t j=0; j<(1<ODR ^= GPIO_ODR_6; + switch (i) { + case 0: + brightness[1] = brightness[5] = (1<= NBITS) + idx = 0; GPIOA->ODR ^= GPIO_ODR_4; TIM1->CCMR1 = (4<DR = 0x88<<8; + SPI1->DR = brightness_by_bit[idx]<<8; while (SPI1->SR & SPI_SR_BSY); const uint32_t period_base = 4; /* 1us */ -- cgit