21 const u16 primerUpic[] =
23 #include "bmp\Open4_EvoPrimer_screen_180x174_RLE256.h"
27 static TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
28 static TIM_OCInitTypeDef TIM_OCInitStructure;
32 const unsigned freqTIM2[ 6 ] = { 136, 136, 182, 273, 364, 546 } ;
52 void LCD_Interface_Init(
void )
56 volatile FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
57 volatile FSMC_NORSRAMTimingInitTypeDef p;
58 GPIO_InitTypeDef GPIO_InitStructure;
63 RCC_APB2PeriphClockCmd( GPIO_LCD_D1_PERIPH, ENABLE );
64 RCC_APB2PeriphClockCmd( GPIO_LCD_D2_PERIPH, ENABLE );
66 GPIO_InitStructure.GPIO_Pin = LCD_D0 | LCD_D1 | LCD_D2 | LCD_D3 ;
67 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
68 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
69 GPIO_Init( GPIOx_D1_LCD, &GPIO_InitStructure );
71 GPIO_InitStructure.GPIO_Pin = LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7 ;
72 GPIO_Init( GPIOx_D2_LCD, &GPIO_InitStructure );
75 RCC_APB2PeriphClockCmd( GPIO_LCD_CTRL_PERIPH, ENABLE );
76 GPIO_InitStructure.GPIO_Pin = CtrlPin_RD | CtrlPin_WR | CtrlPin_RS;
77 GPIO_Init( GPIOx_CTRL_LCD, &GPIO_InitStructure );
80 RCC_APB2PeriphClockCmd( GPIO_LCD_RST_PERIPH, ENABLE );
81 GPIO_InitStructure.GPIO_Pin = CtrlPin_RST;
82 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
83 GPIO_Init( GPIOx_RST_LCD, &GPIO_InitStructure );
86 RCC_APB2PeriphClockCmd( GPIO_LCD_CS_PERIPH, ENABLE );
87 GPIO_InitStructure.GPIO_Pin = CtrlPin_CS;
88 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
89 GPIO_Init( GPIOx_CS_LCD, &GPIO_InitStructure );
91 GPIO_WriteBit( GPIOx_RST_LCD, CtrlPin_RST, Bit_SET );
92 GPIO_WriteBit( GPIOx_CS_LCD, CtrlPin_CS, Bit_RESET );
98 RCC_AHBPeriphClockCmd( RCC_AHBPeriph_FSMC, ENABLE );
100 p.FSMC_AddressSetupTime = 1;
101 p.FSMC_AddressHoldTime = 0;
102 p.FSMC_DataSetupTime = 2;
103 p.FSMC_BusTurnAroundDuration = 0;
104 p.FSMC_CLKDivision = 0;
105 p.FSMC_DataLatency = 0;
106 p.FSMC_AccessMode = FSMC_AccessMode_A;
108 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3;
109 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
110 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
111 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
112 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
113 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
114 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
115 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
116 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
117 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
118 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
119 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
120 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
121 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = (FSMC_NORSRAMTimingInitTypeDef*) &p;
122 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = (FSMC_NORSRAMTimingInitTypeDef*) &p;
123 FSMC_NORSRAMInit( (FSMC_NORSRAMInitTypeDef*) &FSMC_NORSRAMInitStructure );
126 FSMC_NORSRAMCmd( FSMC_Bank1_NORSRAM3, ENABLE );
140 void LCD_BackLightConfig(
void )
142 GPIO_InitTypeDef GPIO_InitStructure;
145 RCC_APB2PeriphClockCmd( GPIO_LCD_BL_PERIPH, ENABLE );
148 GPIO_InitStructure.GPIO_Pin = GPIO_BACKLIGHT_PIN;
149 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
150 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
151 GPIO_Init( GPIOx_BL_LCD, &GPIO_InitStructure );
154 RCC_APB2PeriphClockCmd( RCC_APB2Periph_AFIO, ENABLE );
155 GPIO_PinRemapConfig( AFIO_MAPR_TIM4_REMAP, ENABLE );
161 RCC_APB1PeriphClockCmd( TIM_LCD_BL_PERIPH, ENABLE );
163 TIM_DeInit( TIM_LCD_BL );
164 TIM_TimeBaseStructInit( &TIM_TimeBaseStructure );
165 TIM_OCStructInit( &TIM_OCInitStructure );
168 TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
169 TIM_TimeBaseStructure.TIM_Prescaler = 0x00;
170 TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
171 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
172 TIM_TimeBaseInit( TIM_LCD_BL, &TIM_TimeBaseStructure );
175 TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
176 TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
177 TIM_OCInitStructure.TIM_Pulse = Current_CCR_BackLightStart;
178 TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
179 TIM_OCxInit( TIM_LCD_BL, &TIM_OCInitStructure );
181 TIM_OCxPreloadConfig( TIM_LCD_BL, TIM_OCPreload_Disable );
183 TIM_ARRPreloadConfig( TIM_LCD_BL, ENABLE );
186 TIM_Cmd( TIM_LCD_BL, ENABLE );
201 inline void LCD_Write_Reg( u8 regadd, u16 value )
204 *( u8
volatile* )( LCD_CMD_MODE_ADDR ) = 0;
205 *( u8
volatile* )( LCD_CMD_MODE_ADDR ) = regadd;
208 *( u8
volatile* )( LCD_DATA_MODE_ADDR ) = value >> 8;
209 *( u8
volatile* )( LCD_DATA_MODE_ADDR ) = value & 0xFF;
222 u16 LCD_Read_Reg( u8 regadd )
227 *( u8
volatile* )( LCD_CMD_MODE_ADDR ) = 0;
228 *( u8
volatile* )( LCD_CMD_MODE_ADDR ) = regadd;
231 temp1 = ( *( u8
volatile* )( LCD_DATA_MODE_ADDR ) ) << 8;
232 temp2 = ( *( u8
volatile* )( LCD_DATA_MODE_ADDR ) );
234 return ( temp1 | temp2 );
247 void LCD_Reset(
void )
249 GPIO_WriteBit( GPIOx_RST_LCD, CtrlPin_RST, Bit_RESET );
251 GPIO_WriteBit( GPIOx_RST_LCD, CtrlPin_RST, Bit_SET );
268 void LCD_BackLightChange(
void )
271 TIM_OCInitStructure.TIM_Pulse = Current_CCR_BackLightStart;
273 TIM_OCxInit( TIM_LCD_BL, &TIM_OCInitStructure );
288 void LCD_SetLogoBW(
void )
290 DRAW_SetImage( primerUpic, ( Screen_Width - 180 ) / 2, ( Screen_Height - 174) / 2, 180, 174 ) ;
305 void LCD_Scroll( u8 Ascii, coord_t CurX, coord_t* CurY, coord_t RightMargX, coord_t LeftMargX, coord_t HighMargY, coord_t LowMargY, color_t bGndColor, color_t textColor, mag_t charMagniCoeff )
307 s16 Nblines, width, i, y;
308 extern u16 bmpTmp [LCD_DMA_SIZE];
311 Nblines = ( LowMargY - *CurY ) / DeltaY;
312 width = RightMargX - LeftMargX;
313 for ( i = 0; i < Nblines ; i++ )
315 for ( y = HighMargY - DeltaY; y >= LowMargY; y -= DeltaY )
317 if ( width < PHYS_SCREEN_WIDTH )
319 LCD_RectRead( LeftMargX, y - DeltaY, width, DeltaY, ( u8* ) &bmpTmp );
324 LCD_RectRead( LeftMargX, y - DeltaY, PHYS_SCREEN_WIDTH, DeltaY, ( u8* ) &bmpTmp );
325 DRAW_SetImage( bmpTmp, LeftMargX, y, PHYS_SCREEN_WIDTH, DeltaY );
326 LCD_RectRead( LeftMargX + PHYS_SCREEN_WIDTH, y - DeltaY, width - PHYS_SCREEN_WIDTH, DeltaY, ( u8* ) &bmpTmp );
327 DRAW_SetImage( bmpTmp, LeftMargX + PHYS_SCREEN_WIDTH, y, width - PHYS_SCREEN_WIDTH, DeltaY );
332 LCD_FillRect( LeftMargX, LowMargY, width, DeltaY, bGndColor );
337 LCD_DisplayChar( CurX, *CurY, Ascii, textColor, bGndColor, charMagniCoeff );
353 void LCD_SendLCDCmd_RAM_Access(
void )
369 void LCD_SendLCDCmd_RAM_Access_End(
void )
395 inline void LCD_PixelRead( u8** ptbmp )
397 u8 temp1, temp2, blue, red;
408 blue = ( temp1 & 0xF8 ) >> 3;
410 red = ( temp2 & 0x1F ) << 3;
412 *( *ptbmp ) = ( temp1 & 0x07 ) | red;
413 *( *ptbmp + 1 ) = ( temp2 & 0xE0 ) | blue;
428 void LCD_SendLCDCmd_Rotation_Access(
void )
449 void LCD_SendLCDData16( u8 Data_h, u8 Data_l )
452 *( u8
volatile* )( LCD_DATA_MODE_ADDR ) = Data_h;
453 *( u8
volatile* )( LCD_DATA_MODE_ADDR ) = Data_l;
477 *( u8
volatile* )( LCD_CMD_MODE_ADDR ) = 0;
478 *( u8
volatile* )( LCD_CMD_MODE_ADDR ) = Cmd;
499 *( u8
volatile* )( LCD_DATA_MODE_ADDR ) = Data;
522 tmp = ( ( *( u8
volatile* )( LCD_DATA_MODE_ADDR ) ) );