1 Reply Latest reply on Jan 11, 2017 1:32 PM by LeonardoR_Intel

    KS0108 display driver porting from STM32

    mark_kram

      Hi all,

          As in subjest I have graphic display ABG128064H05-YHY-R-01 based on KS0108 driver. I found driver on STM32 for this display but I want to port it into D2000 platform. I want to ask about two functions GLCD_ReadStatus and GLCD_WriteCommand because I'm not sure how they should looks like in D2000. Maybe someone have any idea ?

       

      link to lbr for STM32: http://en.radzio.dxp.pl/ks0108/ks0108-stm32.rar

       

      Oryginal function body looks as below:

       

      //-------------------------------------------------------------------------------------------------

      // Read Status byte from specified controller (0-2)

      //-------------------------------------------------------------------------------------------------

      unsigned char GLCD_ReadStatus(unsigned char controller)

      {

      unsigned char status;

       

       

      //GPIO_StructInit(&GPIO_InitStructure);

      //GPIO_InitStructure.GPIO_Pin = 0xFF << KS0108_D0; //pin

      //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //pullup

      qm_pmux_input_en (const qm_pin_id_t pin, const bool enable); //Enable input for a pin in the pin mux controller.

      qm_pmux_pullup_en (const qm_pin_id_t pin, const bool enable); //Enable pullup for a pin in the pin mux controller.

      //GPIO_Init(KS0108_PORT, &GPIO_InitStructure);

      qm_gpio_set_config(&GPIO_InitStructure);

       

       

      GPIO_SetBits(KS0108_PORT, KS0108_RW);

      GPIO_ResetBits(KS0108_PORT, KS0108_RS);

      GLCD_EnableController(controller);

      GLCD_Delay();

      GPIO_SetBits(KS0108_PORT, KS0108_EN);

      GLCD_Delay();

      status = ((GPIO_ReadInputData(KS0108_PORT) >> KS0108_D0) & 0xFF);

      GPIO_ResetBits(KS0108_PORT, KS0108_EN);

      GLCD_DisableController(controller);

      return status;

      }

      //-------------------------------------------------------------------------------------------------

      // Write command to specified controller

      //-------------------------------------------------------------------------------------------------

      void GLCD_WriteCommand(unsigned char commandToWrite, unsigned char controller)

      {

      while(GLCD_ReadStatus(controller)&DISPLAY_STATUS_BUSY);

      GPIO_StructInit(&GPIO_InitStructure);

      GPIO_InitStructure.GPIO_Pin  = (0xFF << KS0108_D0);

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

      GPIO_Init(KS0108_PORT, &GPIO_InitStructure);

       

       

      GPIO_ResetBits(KS0108_PORT, KS0108_RS | KS0108_RW);

      GLCD_Delay();

      GLCD_EnableController(controller);

      GLCD_Delay();

      GPIO_SetBits(KS0108_PORT, (commandToWrite << KS0108_D0));

      commandToWrite ^= 0xFF;

      GPIO_ResetBits(KS0108_PORT, (commandToWrite << KS0108_D0));

      GLCD_Delay();

      GPIO_SetBits(KS0108_PORT, KS0108_EN);

      GLCD_Delay();

      GPIO_ResetBits(KS0108_PORT, KS0108_EN);

      GLCD_Delay();

      GLCD_DisableController(controller);

      }

       

      I connect it into D2000 board as below:

       

      #include "qm_pinmux.h"

      //Data bus - lines

      #define LCD_DB0 QM_PIN_ID_6

      #define LCD_DB1 QM_PIN_ID_7

      #define LCD_DB2 QM_PIN_ID_2

      #define LCD_DB3 QM_PIN_ID_5

      #define LCD_DB4 QM_PIN_ID_10

      #define LCD_DB5 QM_PIN_ID_11

      #define LCD_DB6 QM_PIN_ID_12

      #define LCD_DB7 QM_PIN_ID_13

      //Data port

      #define KS0108_PORT QM_GPIO_0

      //Control Lines

      #define KS0108_CS1 QM_PIN_ID_16

      #define KS0108_CS2 QM_PIN_ID_18

      #define KS0108_RST QM_PIN_ID_17

      #define KS0108_RW QM_PIN_ID_0

      #define KS0108_RS QM_PIN_ID_24

      #define KS0108_EN QM_PIN_ID_9

       

      #define KS0108_D0    0

       

      #define DISPLAY_STATUS_BUSY 0x80

       

      //User button

      #define USER_BUTTON_IN QM_PIN_ID_2

       

      extern unsigned char screen_x;

      extern unsigned char screen_y;

       

      extern int qm_gpio_clear_pin();

      extern int qm_gpio_set_pin();