hi;
i useing emwin for a projcet with
lcd controler ks0108 ,but i can not configiration LCDConf.c file. the
my code in below .
the lcd has been 6 times init then going HardFault_Handler .,please help me.
C
#include "GUI.h"
#include "GUIDRV_SPage.h"
#include "GUIDRV_Dist.h"
/*********************************************************************
*
* Layer configuration
*
**********************************************************************
*/
//
// Physical display size
//
#define XSIZE_PHYS 128
#define YSIZE_PHYS 64
//
// Color conversion
//
#define COLOR_CONVERSION GUICC_1
//
// Display driver
//
#define DISPLAY_DRIVER GUIDRV_SPAGE_1C1
/*********************************************************************
*
* Configuration checking
*
**********************************************************************
*/
#ifndef VXSIZE_PHYS
#define VXSIZE_PHYS XSIZE_PHYS
#endif
#ifndef VYSIZE_PHYS
#define VYSIZE_PHYS YSIZE_PHYS
#endif
/*********************************************************************
*
* Driver Port functions
*
**********************************************************************
*/
extern void LCD_X_Init(void);
extern void LCD_X_Write10(unsigned char c);
extern void LCD_X_Write11(unsigned char c);
extern void LCD_X_WriteM11(unsigned char * pData, int NumBytes);
extern unsigned char LCD_X_Read11(void);
extern unsigned char LCD_X_Read10(void) ;
void LCD_WRITE_COMAND(unsigned char );
extern void LCD_WRITE_DATA(unsigned char data);
extern void LCD_WRITE_MDATA(unsigned char *data,int num);
void InitializeLCD0(void);
void InitializeLCD1(void);
void InitializePorts(void);
/*********************************************************************
*
* Private code
*
**********************************************************************
*/
static void delay (int cnt) {
cnt <<= 15;
while (cnt--);
}
/*********************************************************************
*
* _InitController
*
* Purpose:
* Initializes the display controller
*/
static void _InitController0(void) {
}
static void _InitController1(void) {
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_X_Config
*
* Purpose:
* Called during the initialization process in order to set up the
* display driver configuration.
*
*/
void LCD_X_Config(void) {
GUI_DEVICE * pDevice;
GUI_DEVICE * pDriver0;
GUI_DEVICE * pDriver1;
GUI_RECT Rect0;
GUI_RECT Rect1;
GUI_PORT_API PortAPI0 = {0};
GUI_PORT_API PortAPI1 = {0};
CONFIG_SPAGE Config0 = {0};
CONFIG_SPAGE Config1 = {0};
GUI_DEVICE * pDevice0;
GUI_DEVICE * pDevice1;
//
// Set display driver and color conversion for 1st layer
//
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_DIST , COLOR_CONVERSION, 0,0);
//
// Display size configuration
//
if (LCD_GetSwapXY()) {
LCD_SetSizeEx (0, YSIZE_PHYS, XSIZE_PHYS);
LCD_SetVSizeEx(0, VYSIZE_PHYS, VXSIZE_PHYS);
} else {
LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
}
// Create first display driver 0
//
pDriver0 = GUI_DEVICE_Create(DISPLAY_DRIVER, COLOR_CONVERSION, 0,-1);
Config0.FirstSEG = 0;//256 - 224;
Config0.FirstCOM=0;
GUIDRV_SPage_Config(pDriver0, &Config0);
PortAPI0.pfWrite8_A0 = LCD_X_Write00;
PortAPI0.pfWrite8_A1 = LCD_X_Write01;
PortAPI0.pfWriteM8_A0 = LCD_X_WriteM01;
PortAPI0.pfRead8_A1 = LCD_X_Read01;
GUIDRV_SPage_SetBus8(pDriver0, &PortAPI0);
GUIDRV_SPage_Set1502(pDriver0);
//
// Create second display driver 1
//
pDriver1 = GUI_DEVICE_Create(DISPLAY_DRIVER, COLOR_CONVERSION, 0,-1);
Config1.FirstSEG = 0;//256 - 224;
Config1.FirstCOM=0;
GUIDRV_SPage_Config(pDriver1, &Config1);
PortAPI1.pfWrite8_A0 = LCD_X_Write10;
PortAPI1.pfWrite8_A1 = LCD_X_Write11;
PortAPI1.pfWriteM8_A0 = LCD_X_WriteM11;
PortAPI1.pfRead8_A1 = LCD_X_Read10;
GUIDRV_SPage_SetBus8(pDriver1, &PortAPI1);
GUIDRV_SPage_Set1502(pDriver1);
//Add display drivers to distribution driver
Rect0.x0 = 64;
Rect0.y0 = 0;
Rect0.x1 = 127;
Rect0.y1 = 63;
GUIDRV_Dist_AddDriver(pDevice, pDriver0, &Rect0);
Rect1.x0 = 0;
Rect1.y0 = 0;
Rect1.x1 = 63;
Rect1.y1 = 63;
GUIDRV_Dist_AddDriver(pDevice, pDriver1, &Rect1);
}
/*********************************************************************
*
* LCD_X_DisplayDriver
*
* Purpose:
* This function is called by the display driver for several purposes.
* To support the according task the routine needs to be adapted to
* the display controller. Please note that the commands marked with
* 'optional' are not cogently required and should only be adapted if
* the display controller supports these features.
*
* Parameter:
* LayerIndex - Index of layer to be configured
* Cmd - Please refer to the details in the switch statement below
* pData - Pointer to a LCD_X_DATA structure
*
* Return Value:
* < -1 - Error
* -1 - Command not handled
* 0 - OK
*/
static unsigned char k=1;
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
int r;
switch (Cmd) {
//
// Required
//
case LCD_X_INITCONTROLLER: {
//
// Called during the initialization process in order to set up the
// display controller and put it into operation. If the display
// controller is not initialized by any external routine this needs
// to be adapted by the customer...
//
while(k){
InitializePorts();
k=0;
}
InitializeLCD1();
InitializeLCD0();
return 0;
}
default:
r = -1;
}
return r;
}
/*************************** End of file ****************************/
Display More
tanks
best regard
mr.omidi