Hot!Guide to create a GFX driver in Harmony 2.04

Page: 12 > Showing page 1 of 2
Author
epareja
Super Member
  • Total Posts : 357
  • Reward points : 0
  • Joined: 2003/11/07 12:53:08
  • Location: Colombia
  • Status: offline
2017/11/06 21:51:51 (permalink)
4.67 (3)

Guide to create a GFX driver in Harmony 2.04

Hello,
I finally could introduce the ILI9325 driver into Harmony 2.04 and I want to share the experience with anyone who needs it.
I'm attaching a PDF with step by step instructions on how to integrate with  harmony, and I'm uploading also the ili9325 driver templates.
 
Change the TXT extension to PDF.
 
Comments and improvements would be appreciated.
 


Ernesto Pareja J
www.dcctrains.netne.net

#1

20 Replies Related Threads

    obberer
    Starting Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2012/09/04 10:19:26
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/07 00:12:04 (permalink)
    0
    Thumbs up! Very useful. Thanks for sharing.
    #2
    TimH
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2017/09/07 12:19:01
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/07 02:17:08 (permalink)
    0
    Very useful! I'll use this as a template for the ILI6122 driver the display I'll be using :D
    #3
    Skaptor
    n00b member
    • Total Posts : 239
    • Reward points : 0
    • Joined: 2012/07/25 11:18:48
    • Location: Tilted Towers
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/09 13:32:06 (permalink)
    0
    Thanks!

    Porsche 718 Cayman GTS
    #4
    fgsantos7
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2012/08/03 09:43:45
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/24 05:28:28 (permalink)
    0
    Where does the function GFX_Result ILI9325_initialize(GFX_Context* context) is called?
    I've recompiled the project but the driver isn't called anywere. the GFX lib should call the ILI driver somewere.
    #5
    epareja
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/24 05:59:59 (permalink)
    0
    Hello, this function pointer is passed to the driver in the GFX_initialize routine, but is actually called inside the libaria_initialize routine.
     
    Look in the document the point 13th that shows how to configure the function pointer initialization code block that is inserted in the gfx_driver_def.c
     

    <#macro DRV_GFX_ILI9325_DRIVER_DECLARATION IDX>
    GFX_Result ILI9325_InfoGet(GFX_DriverInfo* info);
    GFX_Result ILI9325_ContextInitialize(GFX_Context* context);
    </#macro>
     
    <#macro DRV_GFX_ILI9325_DRIVER_DEFINITION ID IDX>
    GFX_DriverInterfaces[${ID}].infoGet = &ILI9325_InfoGet;
    GFX_DriverInterfaces[${ID}].contextInitialize = &ILI9325_ContextInitialize;
    </#macro>

     
     


    Ernesto Pareja J
    www.dcctrains.netne.net

    #6
    fgsantos7
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2012/08/03 09:43:45
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/24 07:57:06 (permalink)
    0
    I used you're files as a template for my controller (ILI9341), but it seems that the controller never gets initialized.
    In my libaria_initialize routine I only have this code:
     

    int32_t libaria_initialize(void)
    {
    laScreen* screen;
    laScheme_Initialize(&base, GFX_COLOR_MODE_RGB_565);
    base.base = 0xC67A;
    base.highlight = 0xC67A;
    base.highlightLight = 0xFFFF;
    base.shadow = 0x8410;
    base.shadowDark = 0x4208;
    base.foreground = 0x0;
    base.foregroundInactive = 0xD71C;
    base.foregroundDisabled = 0x8410;
    base.background = 0x0;
    base.backgroundInactive = 0xD71C;
    base.backgroundDisabled = 0xC67A;
    base.text = 0x0;
    base.textHighlight = 0x1F;
    base.textHighlightText = 0xFFFF;
    base.textInactive = 0xD71C;
    base.textDisabled = 0x8C92;
    screen = laScreen_New(LA_FALSE, LA_FALSE, &ScreenCreate_boasVindas);
    laContext_AddScreen(screen);
    GFX_Set(GFXF_DRAW_PIPELINE_MODE, GFX_PIPELINE_GCUGPU);
    laContext_SetStringTable(&stringTable);
    laContext_SetActiveScreen(0);
    return 0;
    }

    #7
    epareja
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/24 11:06:55 (permalink)
    0
    My Libaria_initialize is quite different
     
    int32_t LibAria_Initialize(void) 
    {
     if(laInitialize() == LA_FAILURE)
      return -1;
      
     libariaObj.context = laContext_Create(0, 0, 0, GFX_COLOR_MODE_RGB_565, NULL);
     
     if(libariaObj.context == NULL)
      return -1;
     
     laContext_SetActive(libariaObj.context);
     
     libaria_initialize(); // use auto-generated initialization functions

     libariaState = LIBARIA_STATE_INIT;
     
     return 0;
    }

     
    in file gfx.c you find this 
    GFX_Result GFX_Initialize(void) 
    {
        if(GFX_DriverIntfInitialize() == GFX_FAILURE)
            return GFX_FAILURE;

        return GFX_SUCCESS;
    }

     
    And the driverIntfInitialize is in file gfx_driver_interface.c
    This code assigns the local ILI9325 context Initialize function
     
    GFX_Result GFX_DriverIntfGet(GFX_Driver idx, GFX_DriverIntf* intf)
    {
        if(idx >= GFX_DRIVER_COUNT || intf == NULL)
            return GFX_FAILURE;
            
        intf->infoGet = GFX_DriverInterfaces[idx].infoGet;
        intf->contextInitialize = GFX_DriverInterfaces[idx].contextInitialize;
            
        return GFX_SUCCESS;
    }

     
    The hardware initialize is called into the drv_gfx_ili9325.c
     
    static GFX_Result ILI9325_initialize(GFX_Context* context) {
      uint32_t i;

      GFX_Result resultBufferCreate;

      // initialize all layers
      for(i = 0; i < context->layer.count; i++) {
        context->layer.layers[i].enabled = GFX_TRUE;
        context->layer.layers[i].visible = GFX_TRUE;

        context->layer.layers[i].vsync = GFX_FALSE;
        context->layer.layers[i].swap = GFX_FALSE;

        context->layer.layers[i].rect.local.x = 0;
        context->layer.layers[i].rect.local.y = 0;
        context->layer.layers[i].rect.local.width = context->display_info->rect.width;
        context->layer.layers[i].rect.local.height = context->display_info->rect.height;

        context->layer.layers[i].rect.display = context->layer.layers[i].rect.local;

        context->layer.layers[i].alphaEnable = GFX_FALSE;
        context->layer.layers[i].alphaAmount = 255;

        context->layer.layers[i].maskEnable = GFX_FALSE;
        context->layer.layers[i].maskColor = 0;

        context->layer.layers[i].buffer_count = 1;
        context->layer.layers[i].buffer_read_idx = 0;
        context->layer.layers[i].buffer_write_idx = 0;

        resultBufferCreate =
          GFX_PixelBufferCreate(context->display_info->rect.width,
                                context->display_info->rect.height,
                                GFX_COLOR_MODE_RGB_565,
                                NULL,
                                &context->layer.layers[i].buffers[0].pb);
        assert(resultBufferCreate == GFX_SUCCESS);

        context->layer.layers[i].buffers[0].state = GFX_BS_MANAGED;
      }

      ILI9325_InitHardware(context); // THis is the hardware initialization routine
      return GFX_SUCCESS;
    }



    Ernesto Pareja J
    www.dcctrains.netne.net

    #8
    fgsantos7
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2012/08/03 09:43:45
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/27 02:13:43 (permalink)
    0
    I have the functions exactly like you. But I think the function of the driver:
    GFX_Result ILI9341_ContextInitialize(GFX_Context* context) 
    should be called, and it never is.
    #9
    epareja
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/27 18:53:53 (permalink)
    0
    Hello fgsantos7
    Here is a link for my ILI9325 Test project for download. The link only lives 10 days or so.
     
    Download


    Ernesto Pareja J
    www.dcctrains.netne.net

    #10
    fgsantos7
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2012/08/03 09:43:45
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/29 02:10:42 (permalink)
    0
    I've donwloaded, but the zip file is empty.
    #11
    epareja
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/11/29 05:35:18 (permalink)
    0
    Sorry, try this link
    https://we.tl/YimXGarMsm


    Ernesto Pareja J
    www.dcctrains.netne.net

    #12
    yts
    Super Member
    • Total Posts : 561
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/09 04:41:00 (permalink)
    0
    Hi. epareja;
     
    Thank you for your detailed explanation for constructing GFX driver.
     
    I think that you modified "C:\microchip\harmony\v2_04\framework\gfx\hal\templates\gfx_driver_def.c.ftl", too.
     
    yts
    post edited by yts - 2017/12/09 04:45:05
    #13
    epareja
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/10 16:05:43 (permalink)
    0
    yts
    Hi. epareja;
     
    Thank you for your detailed explanation for constructing GFX driver.
     
    I think that you modified "C:\microchip\harmony\v2_04\framework\gfx\hal\templates\gfx_driver_def.c.ftl", too.
     
    yts


     
    Yes, you are right. I added this lines
     

    <#if CONFIG_DRV_GFX_CONTROLLER_TYPE = "ILI9325 (8 and 16 bit parallel)">
    <#include "/framework/gfx/driver/controller/ili9325/templates/drv_gfx_ili9325_definition.ftl">
    <@DRV_GFX_ILI9325_DRIVER_DECLARATION IDX = 0/>
    </#if>
     
    <#if CONFIG_DRV_GFX_CONTROLLER_TYPE = "ILI9325 (8 and 16 bit parallel)">
    <#include "/framework/gfx/driver/controller/ili9325/templates/drv_gfx_ili9325_definition.ftl">
    <@DRV_GFX_ILI9325_DRIVER_DEFINITION
    ID = GFX_DRIVER_COUNT
    IDX = 0/>
    <#assign GFX_DRIVER_COUNT = GFX_DRIVER_COUNT + 1>
    </#if>

    post edited by epareja - 2017/12/10 16:08:09


    Ernesto Pareja J
    www.dcctrains.netne.net

    #14
    epareja
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/10 18:05:57 (permalink)
    0
    I updated the file. Change the extension to pdf
     


    Ernesto Pareja J
    www.dcctrains.netne.net

    #15
    yts
    Super Member
    • Total Posts : 561
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/10 23:55:49 (permalink)
    0
    Hi. epareja;
     
    Thank you very much for your update.
     
    I have studied very much from your documentation.
     
    yts
    #16
    fgsantos7
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2012/08/03 09:43:45
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/20 02:38:07 (permalink)
    0
    Hello there, I've implemented this last step but still I think It's missing 2 things.
    1 - the controller initialization never runs (ILI9341_InitHardware(GFX_Context * context))
    2 - The program crashes in this line : laContext_SetActiveScreen(0);
     
    The first one, where should it should be called?
    The last one i think that something is missing so the libaria runs the default screen.
     
    My macro of processor count GFX_PROCESSOR_COUNT is 0 shouldn't it be 1?
    #17
    epareja
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2003/11/07 12:53:08
    • Location: Colombia
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/20 05:26:39 (permalink)
    0
    fgsantos7
    Hello there, I've implemented this last step but still I think It's missing 2 things.
    1 - the controller initialization never runs (ILI9341_InitHardware(GFX_Context * context))
    2 - The program crashes in this line : laContext_SetActiveScreen(0);


    Hello,
     
    The function ILI9341_InitHardware should be called if this assignments are made
     
    1- in the ILI9325_initialize function is placed a call to initHardware
    2- in the ILI9325_ContextInitialize is asigned this
        context->hal.initialize = &ILI9325_initialize;
    3- There is a call in your code to LibAria_Initialize wich calls laContext_Create(), 
     
    The program should be crashing because it doesnt have the graphic context created in the time of a SetActiveScreen call.
     
    I found the I have not defined GFX_PROCESSOR_COUNT so it should be no problem.
     
    Hope it helps


    Ernesto Pareja J
    www.dcctrains.netne.net

    #18
    fgsantos7
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2012/08/03 09:43:45
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/20 07:13:20 (permalink)
    0
    You're right. In my code in LibAria_Initialize I have that function:
     
    libariaObj.context = laContext_Create(0, 0, 0, GFX_COLOR_MODE_RGB_565, NULL);
    The first argument is the driver it should be different than 0 right?
    #19
    fgsantos7
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2012/08/03 09:43:45
    • Location: 0
    • Status: offline
    Re: Guide to create a GFX driver in Harmony 2.04 2017/12/20 08:07:53 (permalink)
    0
    I've managed to get to the initalization.
    In the GFX.c file I've made this change:
     
        //res = contextDefInitialization(context);
        res = ILI9341_ContextInitialize(context);
     
    but i think I shouldn't change like this.
    but otherwise the contextDefInitialization() defaults the context.
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2018 APG vNext Commercial Version 4.5