Hello Folks,
I am working on MCU and LCD interafacing, I have interfaced MIDAS LCD using SPI. The LCD has ST7735s controller.
Now I am able to make manual patterns of check box, circle and screen colour randomly but I need GUI to be implemented so I have chosen emWin library ,after reading guides i found that I can go with "GUIDRV_FlexColor" drivers.
I have done configurations in LCDconf.c (I have attached here). In GUIconf.c my configurations are as per below.
#define GUI_NUMBYTES (1024) * 15<br>//<br>// Define the average block size<br>//<br>#define GUI_BLOCKSIZE 0x128<br>
I have initialised LCD controller before GUI_INIT().
But unfortunately after returning from "LCD_X_DisplayDriver()" function I am getting Hard fault so I need to understand why I am getting hard-fault and is there any issue in my configurations ?
Please let me know if I can provide you more details ?
Any Help on this issue would be great appreciable.
Thanks & Regards,
Rutvij
/*
----------------------------------------------------------------------
File : LCDConf.c
Purpose : Display driver configuration file
----------------------------------------------------------------------
*/
#include <string.h>
/* GUI main init as per emWin */
#include "GUI.h"
/* As per emWin 5 doc ST7735 Contoler IC's driver config */
#include "GUIDRV_FlexColor.h"
/* For callback registers of LCD */
#include "MCT0144C6W128128PML_App.h"
/*********************************************************************
*
* LCD_X_Config
*w
* Purpose:
* Called during the initialization process in order to set up the
* display driver configuration.
*
*/
static void LcdWriteReg(U16 Data) {
// ... TBD by user
SPI_sendCommand(Data);
}
static void LcdWriteData(U16 Data) {
// ... TBD by user
SPI_sendData(Data);
}
static void LcdWriteDataMultiple(U16 * pData, int NumItems) {
while (NumItems--) {
// ... TBD by user
SPI_sendData((uint8_t)*pData++);
}
}
static void LcdReadDataMultiple(U16 * pData, int NumItems) {
while (NumItems--) {
// ... TBD by user
*pData++=SPI_sendData(0x00);
}
}
void LCD_X_Config(void)
{
GUI_DEVICE *pDevice = NULL;
CONFIG_FLEXCOLOR Config = {0};
GUI_PORT_API PortAPI = {0};
/* Set display driver and color conversion */
/* 16 BPP configuration for st7735s */
/* from specificaly LCD side configure LCD to work on the same BPP
This can be done by cofiguring LCD internal register go into
"ST7735_COLMOD" in "MCT0144C6W128128PML_App.c" file
*/
/* for RGB - GUICC_M565 , for BGR - GUICC_565*/
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
//
LCD_SetSizeEx (0, LCD_WIDTH , LCD_HEIGHT);
LCD_SetVSizeEx(0, LCD_WIDTH, LCD_HEIGHT);
//
// Orientation
//
Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
GUIDRV_FlexColor_Config(pDevice, &Config);
// Set controller and operation mode
//
PortAPI.pfWrite16_A0 = LcdWriteReg;
PortAPI.pfWrite16_A1 = LcdWriteData;
PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
/* GUIDRV_FLEXCOLOR_F66709 - for st7735 */
/* GUIDRV_FLEXCOLOR_M16C0B8 16bpp, no cache, 8 bit bus - SPI data bus */
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B8);
}
/*********************************************************************
*
* 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
*/
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData)
{
int r;
(void) LayerIndex;
(void) pData;
switch (Cmd)
{
/*
* Called during the initialization process in order to set up the
* display controller and put it into operation.
*/
case LCD_X_INITCONTROLLER:
{
return 0;
}
default:
{
r = -1;
}
}
return r;
}
/*************************** End of file ****************************/
I am working on MCU and LCD interafacing, I have interfaced MIDAS LCD using SPI. The LCD has ST7735s controller.
Now I am able to make manual patterns of check box, circle and screen colour randomly but I need GUI to be implemented so I have chosen emWin library ,after reading guides i found that I can go with "GUIDRV_FlexColor" drivers.
I have done configurations in LCDconf.c (I have attached here). In GUIconf.c my configurations are as per below.
#define GUI_NUMBYTES (1024) * 15<br>//<br>// Define the average block size<br>//<br>#define GUI_BLOCKSIZE 0x128<br>
I have initialised LCD controller before GUI_INIT().
But unfortunately after returning from "LCD_X_DisplayDriver()" function I am getting Hard fault so I need to understand why I am getting hard-fault and is there any issue in my configurations ?
Please let me know if I can provide you more details ?
Any Help on this issue would be great appreciable.
Thanks & Regards,
Rutvij
/*
----------------------------------------------------------------------
File : LCDConf.c
Purpose : Display driver configuration file
----------------------------------------------------------------------
*/
#include <string.h>
/* GUI main init as per emWin */
#include "GUI.h"
/* As per emWin 5 doc ST7735 Contoler IC's driver config */
#include "GUIDRV_FlexColor.h"
/* For callback registers of LCD */
#include "MCT0144C6W128128PML_App.h"
/*********************************************************************
*
* LCD_X_Config
*w
* Purpose:
* Called during the initialization process in order to set up the
* display driver configuration.
*
*/
static void LcdWriteReg(U16 Data) {
// ... TBD by user
SPI_sendCommand(Data);
}
static void LcdWriteData(U16 Data) {
// ... TBD by user
SPI_sendData(Data);
}
static void LcdWriteDataMultiple(U16 * pData, int NumItems) {
while (NumItems--) {
// ... TBD by user
SPI_sendData((uint8_t)*pData++);
}
}
static void LcdReadDataMultiple(U16 * pData, int NumItems) {
while (NumItems--) {
// ... TBD by user
*pData++=SPI_sendData(0x00);
}
}
void LCD_X_Config(void)
{
GUI_DEVICE *pDevice = NULL;
CONFIG_FLEXCOLOR Config = {0};
GUI_PORT_API PortAPI = {0};
/* Set display driver and color conversion */
/* 16 BPP configuration for st7735s */
/* from specificaly LCD side configure LCD to work on the same BPP
This can be done by cofiguring LCD internal register go into
"ST7735_COLMOD" in "MCT0144C6W128128PML_App.c" file
*/
/* for RGB - GUICC_M565 , for BGR - GUICC_565*/
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
//
LCD_SetSizeEx (0, LCD_WIDTH , LCD_HEIGHT);
LCD_SetVSizeEx(0, LCD_WIDTH, LCD_HEIGHT);
//
// Orientation
//
Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
GUIDRV_FlexColor_Config(pDevice, &Config);
// Set controller and operation mode
//
PortAPI.pfWrite16_A0 = LcdWriteReg;
PortAPI.pfWrite16_A1 = LcdWriteData;
PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
/* GUIDRV_FLEXCOLOR_F66709 - for st7735 */
/* GUIDRV_FLEXCOLOR_M16C0B8 16bpp, no cache, 8 bit bus - SPI data bus */
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B8);
}
/*********************************************************************
*
* 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
*/
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData)
{
int r;
(void) LayerIndex;
(void) pData;
switch (Cmd)
{
/*
* Called during the initialization process in order to set up the
* display controller and put it into operation.
*/
case LCD_X_INITCONTROLLER:
{
return 0;
}
default:
{
r = -1;
}
}
return r;
}
/*************************** End of file ****************************/