Mercurial > ~darius > hgwebdir.cgi > stm32temp
diff hw.c @ 62:bb52e6dad784
The LCD works better when the GPIO clocks are enabled before frobbing them.
PWM doesn't work for some reason, just hard on for now.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Tue, 09 Apr 2013 00:28:29 +0930 |
parents | ace431a0d0f5 |
children | 345a42f6151b |
line wrap: on
line diff
--- a/hw.c Mon Apr 08 23:11:55 2013 +0930 +++ b/hw.c Tue Apr 09 00:28:29 2013 +0930 @@ -27,13 +27,18 @@ USART_InitTypeDef USART_InitStructure; /* Enable clocks */ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP | RCC_APB1Periph_TIM4 | RCC_APB1Periph_I2C1, + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP | + RCC_APB1Periph_TIM4 | RCC_APB1Periph_I2C1, ENABLE); - RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOB | + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | + RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOB | + RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_SPI1, ENABLE); - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC | RCC_AHBPeriph_CRC, ENABLE); + RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC | RCC_AHBPeriph_CRC | + RCC_AHBPeriph_SDIO | RCC_AHBPeriph_DMA2, ENABLE); + /* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE); @@ -141,9 +146,12 @@ */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + // XXX: PWM not working + //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOD, &GPIO_InitStructure); - + GPIO_SetBits(GPIOD, GPIO_Pin_13); + /* Remap TIM4_CH2 to PD13 */ GPIO_PinRemapConfig(GPIO_Remap_TIM4, ENABLE); @@ -302,9 +310,6 @@ * See SD_LowLevelInit from libs/STM32F10x_StdPeriph_Lib_V3.5.0/Utilities/STM32_EVAL/STM3210E_EVAL/stm3210e_eval.c */ - /* GPIOC and GPIOD Periph clock enable */ - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); - /* Configure SDIO pins for AF PC8 -> SD0 PC9 -> SD1 @@ -319,11 +324,5 @@ /* Configure PD2 -> CMD SDIO pin for AF */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* Enable the SDIO AHB Clock */ - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, ENABLE); - - /* Enable the DMA2 Clock */ - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); + GPIO_Init(GPIOD, &GPIO_InitStructure); }