Configuring Sparklet for RH850

Some of the configurations associated with RH850 port is given in the below section.

LCD Timing

TFT display related configurations specific to RH850 should be done by the user as it is fetched by Sparklet library via the function sgui_hal_rh850_get_custom_timing. For e.g., the timing of a display of resolution 800*480 can be in the predefined structure r_ddb_Timing_t and returned as similar to the following snippet:

 1r_ddb_Timing_t rh850_custom_timing=
 2{
 3  "TRULY_WVGA_TFT_800x480",
 4      800u,480u,
 5      {928,128u,40u,48u},
 6      {525u,45u,13u,3u},
 7      ((uint32_t)R_DDB_DISP_FLAG_VOEN | (uint32_t)R_DDB_DISP_FLAG_DESYNC_ACTHI),
 8      30000000u
 9};
10r_ddb_Timing_t *sgui_hal_rh850_get_custom_timing (void)
11{
12      return &rh850_custom_timing;
13}

Frame Buffer Format

The RGL library has to be provided information about the screen color format via the sgui_hal_rh850_get_color_format function. It should return one of predefined formats as defined in RGLrgl_ghs_D1Mx_obj_V2.1.0avlibmacrowmlibr_wm_api.h

  • R_WM_OUTCOLORFMT_RGB888

  • R_WM_OUTCOLORFMT_RGB666

  • R_WM_OUTCOLORFMT_RGB565

For example, to support RGB888 format framebuffer, do as following:

1int sgui_hal_rh850_get_color_format (void)
2{
3 return R_WM_OUTCOLORFMT_RGB888;
4}

LCD Display Output format

The RGL library has to be provided information about the display output format via the sgui_hal_rh850_get_display_out_format function. It should return one of the following predefined formats from RGLrgl_ghs_D1Mx_obj_V2.1.0avlibmacrovdcelibr_vdce_api.h

  • R_VDCE_OUT_FORMAT_RGB888

  • R_VDCE_OUT_FORMAT_RGB666

  • R_VDCE_OUT_FORMAT_RGB565

  • R_VDCE_OUT_FORMAT_SERIAL_RGB

For example, to support RGB888 format display, do as following:

1int sgui_hal_rh850_get_display_out_format (void)
2{
3 return R_VDCE_OUT_FORMAT_RGB888 ;
4}

Vertical Mirroring Support

The RGL library can also support vertical mirroring which can be enabled by returning the same from sgui_hal_rh850_vertical_mirroring_needed function.

For example, if vertical mirroring is needed, do as following:

1int sgui_hal_rh850_vertical_mirroring_needed (void)
2{
3  return 0;
4}

Memory Configuration

The RGL library has to be provided information about the various RAM details for heap memory management via the sgui_rh850_mem_init function.

For example, a typical memory configuration is as follows:

 1#define LOCAL_NUM_BLOCKS             0x800
 2#define LOCAL_BLOCK_SIZE             0x40
 3#define LOC_HEAP_SIZE                        (LOCAL_NUM_BLOCKS * LOCAL_BLOCK_SIZE)
 4static uint32_t loc_LocalHeap[LOC_HEAP_SIZE >> 2];
 5#define SDRAM_BASE                           0x40000000
 6#define SDRAM_SIZE                           (16 << 20)
 7#define SDRAM_BLOCK_SIZE             (2 * 1024)
 8#define SDRAM_NUM_BLOCKS             (SDRAM_SIZE / SDRAM_BLOCK_SIZE)
 9#define VRAM_BASE                    (0x3FD9C000u + 8192)
10#define VRAM_NUM_BLOCKS              2431
11#define VRAM_BLOCK_SIZE                      512
12#define CAMERA_BASE                  0x3FD9C000u
13#define CAMERA_BLOCK_SIZE                    8192
14#define CAPTURE_BUF            (VRAM_BASE + (VRAM_NUM_BLOCKS * VRAM_BLOCK_SIZE))
15sgui_rh850_mem_init( (uint32_t)loc_LocalHeap, LOCAL_NUM_BLOCKS, LOCAL_BLOCK_SIZE,\
16VRAM_BASE, VRAM_NUM_BLOCKS, VRAM_BLOCK_SIZE,\
17SDRAM_BASE, SDRAM_NUM_BLOCKS, SDRAM_BLOCK_SIZE,\
18CAMERA_BASE, CAMERA_BLOCK_SIZE, CAPTURE_BUF);

Other Considerations

Some of the memory is allocated by external code and is used inside Sparklet. For example, certain RAM addresses are allocated by business logic and provided to Sparklet via sgui_get_ram_bin_addr() (in rh850_bsp.c). These sections must be aligned for certain boundaries for proper operation, otherwise leading to memory alignment exceptions. It can be achieved via attribute alignment:

 1#define RAM_BUF_SIZE                 9240
 2int8_t arr_ram_buf [RAM_BUF_SIZE] __attribute__((aligned (16)));
 3void *sgui_get_ram_bin_addr (int32_t u32_offset)
 4        {
 5              if (u32_offset >= RAM_BUF_SIZE)
 6               {
 7                sgui_app_report_error (SGUI_ERR_TODO, 1, "Insufficient RAM size");
 8               }
 9        return &arr_ram_buf[u32_offset];
10        }