AnsweredAssumed Answered

stm32f411 nucleo GUI app

Question asked by aihua.zhang on Jan 28, 2015
Latest reply on Feb 2, 2015 by Amel N
Hi,Sir
   I have a STM32F411 Nucleo board and an adafruit 1.8 TFT shield(LCD controller ST7735R),I want do the STemWin application on it.
  based on STM32Cube_FW_F4_V1.3.0\Projects\STM32F411RE-Nucleo\Demonstrations project,add the GUI config and enable the CRC module,while debuging ,LCD_X_DisplayDriver()->LCD_LL_Init()->st7735_init()-> st7735_WriteReg(LCD_REG_179, 0x01);then the system blocked with a hardfault exception, 
the LCD_Conf.c files:
#include "GUI.h"
#include "GUIDRV_FlexColor.h"
#include  "main.h"
#include  "st7735\st7735.h"
#include  "stm32f4xx_nucleo.h"


/*********************************************************************
*
*       Layer configuration (to be modified)
*
**********************************************************************
*/


//
// Physical display size
//
#define XSIZE_PHYS  128 // To be adapted to x-screen size
#define YSIZE_PHYS  160 // To be adapted to y-screen size


/*********************************************************************
*
*       Configuration checking
*
**********************************************************************
*/
#ifndef   VXSIZE_PHYS
  #define VXSIZE_PHYS XSIZE_PHYS
#endif
#ifndef   VYSIZE_PHYS
  #define VYSIZE_PHYS YSIZE_PHYS
#endif
#ifndef   XSIZE_PHYS
  #error Physical X size of display is not defined!
#endif
#ifndef   YSIZE_PHYS
  #error Physical Y size of display is not defined!
#endif
#ifndef   GUICC_565
  #error Color conversion not defined!
#endif
#ifndef   GUIDRV_FLEXCOLOR
  #error No display driver defined!
#endif
/*********************************************************************
*
*       Defines, sfrs
*
**********************************************************************
*/
//
// COG interface register addr.
//


typedef struct
{
  __IO uint8_t REG;
  __IO uint8_t RAM;


}LCD_CONTROLLER_TypeDef;
/*********************************************************************
*
*       Local functions
*
**********************************************************************
*/


static void   LCD_LL_Init(void);
/********************************************************************
*
*       LcdWriteReg
*
* Function description:
*   Sets display register
*/
static void LcdWriteReg(U8 Data) {
  // ... TBD by user
   LCD_IO_WriteReg((uint8_t)Data);
}


/********************************************************************
*
*       LcdWriteData
*
* Function description:
*   Writes a value to a display register
*/
static void LcdWriteData(U8 Data) {
  // ... TBD by user
   LCD_IO_WriteData((uint8_t)Data);
}


/********************************************************************
*
*       LcdWriteDataMultiple
*
* Function description:
*   Writes multiple values to a display register.
*/
static void LcdWriteDataMultiple(U8 * pData, int NumItems) {
  while (NumItems--) {
  LCD_IO_WriteData((uint8_t )&pData);
  }
}




/********************************************************************
*
*       LcdReadDataMultiple
*
* Function description:
*   Reads multiple values from a display register.
*/
static void LcdReadDataMultiple(U8 * pData, int NumItems) {
  while (NumItems--) {
   //*pData++ = LcdReadData();
    while(1);
  }
}


/*********************************************************************
*
*       Public functions
*
**********************************************************************
*/
/**
  * @brief  Initializes the LCD.
  * @param  None
  * @retval LCD state
  */
void LCD_LL_Init(void)

  /* LCD Init */
  st7735_Init();
}




/*********************************************************************
*
*       LCD_X_Config
*
* Function description:
*   Called during the initialization process in order to set up the
*   display driver configuration.
*
*/
void LCD_X_Config(void) {
  GUI_DEVICE * pDevice;
  CONFIG_FLEXCOLOR Config = {0};
  GUI_PORT_API PortAPI = {0};
  //
  // Set display driver and color conversion
  //
  pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_555, 0, 0);
  //
  // Display driver configuration, required for Lin-driver
  //
  LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
  LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
  //
  // Orientation
  //
 // Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
  GUIDRV_FlexColor_Config(pDevice, &Config);
  //
  // Set controller and operation mode
  //
  PortAPI.pfWrite8_A0  = LcdWriteReg;
  PortAPI.pfWrite8_A1  = LcdWriteData;
  PortAPI.pfWriteM8_A1 = LcdWriteDataMultiple;
  PortAPI.pfReadM8_A1  = LcdReadDataMultiple; 
  
  //LCD_IO_Init();
  
  GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B8);
}


/*********************************************************************
*
*       LCD_X_DisplayDriver
*
* Function description:
*   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) {
  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...
    //
    // ...
    LCD_LL_Init();
    return 0;
  }
  default:
    r = -1;
  }
  return r;
}


/*************************** End of file ****************************/

could you please give some advice about this problem? thank you.

Outcomes