Skip to content

Commit 16bdb65

Browse files
committed
platform: move clock enable from light driver to platform.c
Might as well keep all clock config in one place until we have a good reason to do otherwise.
1 parent a78a4c9 commit 16bdb65

File tree

6 files changed

+5
-11
lines changed

6 files changed

+5
-11
lines changed

lib/pbio/drv/city_hub/light.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
// setup LED PWMs and pins
1616
void _pbdrv_light_init(void) {
17-
RCC->APB2ENR |= RCC_APB2ENR_TIM16EN | RCC_APB2ENR_TIM15EN;
18-
1917
// RGB values are 0-255, so multiplying by 5 here to limit brightness to
2018
// 1/5 of max possible without having to do division later. It should also
2119
// give use smoother steps than the official LEGO firmware since we aren't

lib/pbio/drv/debug/light.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
// setup LED PWMs and pins
1616
void _pbdrv_light_init(void) {
17-
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN | RCC_APB1ENR_TIM4EN | RCC_APB1ENR_TIM12EN;
18-
1917
// RGB values are 0-255, so setup timer to allow using those values
2018
// directly in TIMx->CCRx
2119
TIM12->PSC = 187;

lib/pbio/drv/move_hub/light.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
// setup LED PWMs and pins
1616
void _pbdrv_light_init(void) {
17-
RCC->APB2ENR |= RCC_APB2ENR_TIM16EN | RCC_APB2ENR_TIM15EN;
18-
1917
// RGB values are 0-255, so multiplying by 5 here to limit brightness to
2018
// 1/5 of max possible without having to do division later. It should also
2119
// give use smoother steps than the official LEGO firmware since we aren't

lib/pbio/platform/city_hub/platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void SystemInit(void) {
101101
RCC->AHBENR |= RCC_AHBENR_DMAEN | RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN
102102
| RCC_AHBENR_GPIOCEN | RCC_AHBENR_GPIODEN | RCC_AHBENR_GPIOFEN;
103103
RCC->APB1ENR |= RCC_APB1ENR_SPI2EN | RCC_APB1ENR_USART3EN | RCC_APB1ENR_USART4EN;
104-
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN;
104+
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_TIM16EN | RCC_APB2ENR_TIM15EN;
105105

106106

107107
// Keep main power on

lib/pbio/platform/debug/platform.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,12 @@ void SystemInit(void) {
214214
// dpgeorge: enable 8-byte stack alignment for IRQ handlers, in accord with EABI
215215
SCB->CCR |= SCB_CCR_STKALIGN_Msk;
216216

217-
// enable GPIO clocks
217+
// enable all of the hardware modules we are using
218218
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN | RCC_AHB1ENR_GPIOCEN |
219219
RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOEEN | RCC_AHB1ENR_GPIOFEN |
220220
RCC_AHB1ENR_GPIOGEN | RCC_AHB1ENR_DMA2EN;
221-
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN | RCC_APB1ENR_USART2EN;
221+
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN | RCC_APB1ENR_TIM3EN | RCC_APB1ENR_TIM4EN |
222+
RCC_APB1ENR_TIM12EN | RCC_APB1ENR_USART2EN;
222223
RCC->APB2ENR |= RCC_APB2ENR_ADC3EN | RCC_APB2ENR_USART6EN;
223224

224225
// UART for terminal

lib/pbio/platform/move_hub/platform.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ void SystemInit(void) {
124124
RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOCEN
125125
| RCC_AHBENR_GPIODEN | RCC_AHBENR_GPIOFEN;
126126
RCC->APB1ENR |= RCC_APB1ENR_USART3EN | RCC_APB1ENR_USART4EN;
127-
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN;
128-
127+
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_TIM16EN | RCC_APB2ENR_TIM15EN;
129128

130129
// Keep BOOST alive
131130
GPIOB->BSRR = GPIO_BSRR_BS_11;

0 commit comments

Comments
 (0)