changeset 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 9c5db7fee912
children 7e5916574d5e
files hw.c lcd.c
diffstat 2 files changed, 17 insertions(+), 18 deletions(-) [+]
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);  
 }
--- a/lcd.c	Mon Apr 08 23:11:55 2013 +0930
+++ b/lcd.c	Tue Apr 09 00:28:29 2013 +0930
@@ -131,11 +131,11 @@
     /* Initialise LCD panel */
 
     /* Pull reset pin low */
-    delay(1);
+    delay(10);
     GPIO_ResetBits(GPIOE, GPIO_Pin_1);
-    delay(10);
+    delay(500);
     GPIO_SetBits(GPIOE, GPIO_Pin_1);
-    delay(50);
+    delay(500);
 
     id = lcd_readreg(0x00);
     if (id != 0x9325) {