annotate lcd.c @ 3:74e9b3baac1e

Jumbo commit to make things work. Note I have t
author Daniel O'Connor <darius@dons.net.au>
date Sun, 01 Jan 2012 11:01:13 +1030
parents
children 2c87e30c982d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 /*
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2 * Example code (I think)
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 * ~/projects/STM32Strive/奋斗STM32开发板例程/奋斗STM32开发板例程/奋斗STM32开发板MINI/STM32奋斗版ucOS II V2.86 uCGUI 3.9 DEMO-V2/STM32奋斗版ucOS II V2.86 uCGUI 3.9 DEMO
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 *
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 * Schematics
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 * Main board ~/Downloads/Strive\ Mini\ STM32\ Schematic.pdf
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7 * LCD board ~/Downloads/Strive Mini LCD STM32 Schematic.pdf
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8 * MCU reference manual
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 * ~/Downloads/CD00171190.pdf
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10 * MCU Data sheet (pinout)
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11 * ~/Downloads/CD00191185.pdf
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 * LCD data sheet
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13 *
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15 /* LCD board MCU
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16 1 VCC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 2 TC_SCK PA5/SPI1_SCK
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 3 GND
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 4 TC_CS PB7/SPI1_CS3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 5 RST PE1 FSMC_NBL1? (unlikely)
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21 6 TC_DIN PA7/SPI1_MOSI
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 7 nOE PD4/FSMC_nOE
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23 8 TC_DOUT PA6/SPI1_MISO
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 9 nWR PD5/FSMC_nWE
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 10 TC_INT PB6
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 11 CS PD7/FSMC_NE1/FSMC_NCE2
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27 12 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 13 RS PD11/FSMC_A16
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 14 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 15 D7 PE10/FSMC_D7
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31 16 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32 17 D6 PE9/FSMC_D6
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33 18 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 19 D3 PD1/FSMC_D3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 20 D13 PD8/FSMC_D13
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 21 D5 PE8/FSMC_D5
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37 22 D12 PE15/FSMC_D12
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 23 D4 PE7/FSMC_D4
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 24 GND
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40 25 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41 26 D11 PE14/FSMC_D11
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42 27 D2 PD0/FSMC_D2
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43 28 D10 PE13/FSMC_D10
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 29 D1 PD15/FSMC_D1
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45 30 D9 PE12/FSMC_D9
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46 31 D0 PD14/FSMC_D0
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
47 32 D14 PD9/FSMC_D9
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48 33 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49 34 D8 PE11/FSMC_D8
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50 35 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 36 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52 37 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 38 LCD_PWM PD13/TIM4_CH2
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 39 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 40 D15 PD10/FSMC_D15
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
56 */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
58 #include "stm32f10x.h"
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
59 #include "lcd.h"
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
60
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
61 void
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
62 LCD_init(void) {
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
63 GPIO_InitTypeDef GPIO_InitStructure;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
64 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
65 FSMC_NORSRAMTimingInitTypeDef p;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
66
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
67 /* Configures LCD Control lines (FSMC Pins) in alternate function Push-Pull mode.
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
68 *
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
69 * PD0(D2), PD1(D3), PD4(NOE), PD5(NWE), PD7(NE1/CS), PD8(D13), PD9(D14),
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
70 * PD10(D15), PD11(A16/RS) PD14(D0), PD15(D1)
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
71 */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
72 GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7 |
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
73 GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_14 | GPIO_Pin_15);
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
74 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
75 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
76 GPIO_Init(GPIOD, &GPIO_InitStructure);
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
77
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
78 /* PE7(D4), PE8(D5), PE9(D6), PE10(D7), PE11(D8), PE12(D9), PE13(D10),
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
79 * PE14(D11), PE15(D12)
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
80 */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
81 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
82 GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
83 GPIO_Init(GPIOE, &GPIO_InitStructure);
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
84
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
85 /* Configures the Parallel interface (FSMC) for LCD (Parallel mode) */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
86 /* FSMC_Bank1_NORSRAM4 timing configuration */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
87 p.FSMC_AddressSetupTime = 1;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
88 p.FSMC_AddressHoldTime = 0;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
89 p.FSMC_DataSetupTime = 2;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
90 p.FSMC_BusTurnAroundDuration = 0;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
91 p.FSMC_CLKDivision = 0;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
92 p.FSMC_DataLatency = 0;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
93 p.FSMC_AccessMode = FSMC_AccessMode_A;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
94
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
95 /* FSMC_Bank1_NORSRAM4 configured as follows:
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
96 - Data/Address MUX = Disable
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
97 - Memory Type = SRAM
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
98 - Data Width = 16bit
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
99 - Write Operation = Enable
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
100 - Extended Mode = Disable
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
101 - Asynchronous Wait = Disable */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
102 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
103 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
104 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
105 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
106 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
107 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
108 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
109 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
110 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
111 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
112 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
113 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
114 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
115 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
116 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
117
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
118 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
119
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
120 /* Enable FSMC_Bank1_NORSRAM4 */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
121 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
122 }