From f3870ce44130516ee7a898685c53ddf48d47d8cd Mon Sep 17 00:00:00 2001 From: "p.shamray" Date: Thu, 12 Jun 2014 11:05:53 +0300 Subject: [PATCH 01/38] first commit PCF8812 driver --- drivers/gdisp/PCF8812/PCF8812.h | 53 +++++ .../gdisp/PCF8812/board_PCF8812_template.h | 43 ++++ drivers/gdisp/PCF8812/gdisp_lld.mk | 2 + drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 213 ++++++++++++++++++ drivers/gdisp/PCF8812/gdisp_lld_config.h | 25 ++ 5 files changed, 336 insertions(+) create mode 100644 drivers/gdisp/PCF8812/PCF8812.h create mode 100644 drivers/gdisp/PCF8812/board_PCF8812_template.h create mode 100644 drivers/gdisp/PCF8812/gdisp_lld.mk create mode 100644 drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c create mode 100644 drivers/gdisp/PCF8812/gdisp_lld_config.h diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h new file mode 100644 index 00000000..6faec88a --- /dev/null +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -0,0 +1,53 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _PCF8812_H +#define _PCF8812_H + +#define PCF8812_SET_FUNC 0x20 // Function set +#define PCF8812_H 0x01 +#define PCF8812_V 0x02 +#define PCF8812_PD 0x04 + +#define PCF8812_DISPLAY 0x08 +#define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCF8812_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 + +#define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select + +#define PCF8812_SET_Y 0x04 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 + +// ========================================= + +#define PCF8812_TEMP_CONTROL 0x04 // set temperature coefficient (TCx) +#define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCF8812_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 + +#define PCF8812_SET_VMULT 0x08 // Set voltage multiplier factor +#define PCF8812_VMULT_MODE_0 0x00 // S1 = 0, S0 = 0 - 2 × voltage multiplier +#define PCF8812_VMULT_MODE_1 0x01 // S1 = 0, S0 = 1 - 3 × voltage multiplier +#define PCF8812_VMULT_MODE_2 0x02 // S1 = 1, S0 = 0 - 4 × voltage multiplier +#define PCF8812_VMULT_MODE_3 0x03 // S1 = 1, S0 = 1 - 5 × voltage multiplier + +#define PCF8812_SET_BIAS 0x10 // set bias system (BSx) +#define PCF8812_BIAS_MODE_7 0x00 // 1 to 100 +#define PCF8812_BIAS_MODE_6 0x01 // 1 to 80 +#define PCF8812_BIAS_MODE_5 0x02 // 1 to 65 +#define PCF8812_BIAS_MODE_4 0x03 // 1 to 48 +#define PCF8812_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCF8812_BIAS_MODE_2 0x05 // 1 to 24 +#define PCF8812_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCF8812_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 + +#define PCF8812_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 + +#endif /* _PCF8812_H */ diff --git a/drivers/gdisp/PCF8812/board_PCF8812_template.h b/drivers/gdisp/PCF8812/board_PCF8812_template.h new file mode 100644 index 00000000..08ec130d --- /dev/null +++ b/drivers/gdisp/PCF8812/board_PCF8812_template.h @@ -0,0 +1,43 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +static inline void init_board(GDisplay *g) { + (void) g; +} + +static inline void post_init_board(GDisplay *g) { + (void) g; +} + +static inline void setpin_reset(GDisplay *g, bool_t state) { + (void) g; + (void) state; +} + +static inline void acquire_bus(GDisplay *g) { + (void) g; +} + +static inline void release_bus(GDisplay *g) { + (void) g; +} + +static inline void write_cmd(GDisplay *g, uint8_t cmd) { + (void) g; + (void) cmd; +} + +static inline void write_data(GDisplay *g, uint8_t* data, uint16_t length) { + (void) g; + (void) data; + (void) length; +} + +#endif /* _GDISP_LLD_BOARD_H */ diff --git a/drivers/gdisp/PCF8812/gdisp_lld.mk b/drivers/gdisp/PCF8812/gdisp_lld.mk new file mode 100644 index 00000000..f2394eaf --- /dev/null +++ b/drivers/gdisp/PCF8812/gdisp_lld.mk @@ -0,0 +1,2 @@ +GFXINC += $(GFXLIB)/drivers/gdisp/PCF8812 +GFXSRC += $(GFXLIB)/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c new file mode 100644 index 00000000..083f6d50 --- /dev/null +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -0,0 +1,213 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#include "gfx.h" + +#if GFX_USE_GDISP + +#define GDISP_DRIVER_VMT GDISPVMT_PCF8812 +#include "drivers/gdisp/PCF8812/gdisp_lld_config.h" +#include "src/gdisp/driver.h" + +#include "board_PCF8812.h" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifndef GDISP_SCREEN_HEIGHT + #define GDISP_SCREEN_HEIGHT 65 +#endif +#ifndef GDISP_SCREEN_WIDTH + #define GDISP_SCREEN_WIDTH 102 +#endif +#ifndef GDISP_INITIAL_CONTRAST + #define GDISP_INITIAL_CONTRAST 51 +#endif +#ifndef GDISP_INITIAL_BACKLIGHT + #define GDISP_INITIAL_BACKLIGHT 100 +#endif + +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) + +#include "drivers/gdisp/PCF8812/PCF8812.h" + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +// Some common routines and macros +#define RAM(g) ((uint8_t *)g->priv) + +#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH) +#define xybit(y) (1<<((y)&7)) + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* + * As this controller can't update on a pixel boundary we need to maintain the + * the entire display surface in memory so that we can do the necessary bit + * operations. Fortunately it is a small display in monochrome. + * 65 * 102 / 8 = 829 bytes. + */ + +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { + // The private area is the display surface. + g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)); + + // Initialise the board interface + init_board(g); + + // Hardware reset + setpin_reset(g, TRUE); + gfxSleepMilliseconds(100); + setpin_reset(g, FALSE); + gfxSleepMilliseconds(100); + + acquire_bus(g); + + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_TEMP_CONTROL | PCF8812_TEMP_MODE_1); + write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_cmd(g, PCF8812_SET_VOP | 0xFF); + write_cmd(g, PCF8812_SET_FUNC); + write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + + + + unsigned int i; + for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); ++i) + { + RAM(g)[i] &= 0x00; + write_data(g, (uint8_t*)0x00, 1); + } + + // Finish Init + post_init_board(g); + + // Release the bus + release_bus(g); + + /* Initialise the GDISP structure */ + g->g.Width = GDISP_SCREEN_WIDTH; + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Orientation = GDISP_ROTATE_0; + g->g.Powermode = powerOn; + g->g.Backlight = GDISP_INITIAL_BACKLIGHT; + g->g.Contrast = GDISP_INITIAL_CONTRAST; + + return TRUE; +} + +#if GDISP_HARDWARE_FLUSH + LLDSPEC void gdisp_lld_flush(GDisplay *g) { + + // Don't flush if we don't need it. + if (!(g->flags & GDISP_FLG_NEEDFLUSH)) + return; + + unsigned int i; + + acquire_bus(g); + for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i += GDISP_SCREEN_WIDTH) { + write_data(g, RAM(g) + i, GDISP_SCREEN_WIDTH); + } + release_bus(g); + } +#endif + +#if GDISP_HARDWARE_DRAWPIXEL + LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { + coord_t x, y; + + switch(g->g.Orientation) { + default: + case GDISP_ROTATE_0: + x = g->p.x; + y = g->p.y; + break; + case GDISP_ROTATE_90: + x = g->p.y; + y = GDISP_SCREEN_HEIGHT-1 - g->p.x; + break; + case GDISP_ROTATE_180: + x = GDISP_SCREEN_WIDTH-1 - g->p.x; + y = GDISP_SCREEN_HEIGHT-1 - g->p.y; + break; + case GDISP_ROTATE_270: + x = GDISP_SCREEN_HEIGHT-1 - g->p.y; + y = g->p.x; + break; + } + if (gdispColor2Native(g->p.color) == Black) + RAM(g)[xyaddr(x, y)] |= xybit(y); + else + RAM(g)[xyaddr(x, y)] &= ~xybit(y); + g->flags |= GDISP_FLG_NEEDFLUSH; + } +#endif + +#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + switch(g->p.x) { + case GDISP_CONTROL_POWER: + if (g->g.Powermode == (powermode_t)g->p.ptr) + return; + switch((powermode_t)g->p.ptr) { + case powerOff: + case powerSleep: + case powerDeepSleep: + acquire_bus(g); + write_cmd(g, PCF8812_DISPLAY_OFF); + release_bus(g); + break; + case powerOn: + acquire_bus(g); + write_cmd(g, PCF8812_DISPLAY_ON); + release_bus(g); + break; + default: + return; + } + g->g.Powermode = (powermode_t)g->p.ptr; + return; + + case GDISP_CONTROL_ORIENTATION: + if (g->g.Orientation == (orientation_t)g->p.ptr) + return; + switch((orientation_t)g->p.ptr) { + /* Rotation is handled by the drawing routines */ + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + g->g.Height = GDISP_SCREEN_WIDTH; + g->g.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + g->g.Orientation = (orientation_t)g->p.ptr; + return; + + case GDISP_CONTROL_CONTRAST: + if ((unsigned)g->p.ptr > 100) + g->p.ptr = (void *)100; + acquire_bus(g); + release_bus(g); + g->g.Contrast = (unsigned)g->p.ptr; + return; + } + } +#endif // GDISP_NEED_CONTROL + +#endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCF8812/gdisp_lld_config.h b/drivers/gdisp/PCF8812/gdisp_lld_config.h new file mode 100644 index 00000000..f95fc178 --- /dev/null +++ b/drivers/gdisp/PCF8812/gdisp_lld_config.h @@ -0,0 +1,25 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing +#define GDISP_HARDWARE_DRAWPIXEL TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ From a38fd71311c212e06d6b4435737833784fa868ed Mon Sep 17 00:00:00 2001 From: pashamray Date: Fri, 13 Jun 2014 12:05:41 +0000 Subject: [PATCH 02/38] =?UTF-8?q?gdisp=5Flld=5FPCF8812.c=20=D0=BE=D1=82?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=20=D0=BE=D0=BD=D0=BB=D0=B0=D0=B9=D0=BD=20=D0=BD?= =?UTF-8?q?=D0=B0=20Bitbucket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 083f6d50..b0475fae 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -115,8 +115,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; acquire_bus(g); - for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i += GDISP_SCREEN_WIDTH) { - write_data(g, RAM(g) + i, GDISP_SCREEN_WIDTH); + for (i = 0; i < 9; ++i) { + write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); } release_bus(g); } From 8e13c10f392396022a4b2ae04b5ccd8cb795f17e Mon Sep 17 00:00:00 2001 From: pashamray Date: Wed, 18 Jun 2014 21:43:14 +0300 Subject: [PATCH 03/38] remove not use code --- drivers/gdisp/PCF8812/PCF8812.h | 4 +- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 91 +++++------------------ drivers/gdisp/PCF8812/gdisp_lld_config.h | 3 +- 3 files changed, 23 insertions(+), 75 deletions(-) diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h index 6faec88a..95e7c217 100644 --- a/drivers/gdisp/PCF8812/PCF8812.h +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -21,12 +21,12 @@ #define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select -#define PCF8812_SET_Y 0x04 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCF8812_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 #define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 // ========================================= -#define PCF8812_TEMP_CONTROL 0x04 // set temperature coefficient (TCx) +#define PCF8812_SET_TEMP 0x04 // set temperature coefficient (TCx) #define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 #define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 #define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index b0475fae..88fc2aea 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -32,7 +32,7 @@ #define GDISP_INITIAL_BACKLIGHT 100 #endif -#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCF8812/PCF8812.h" @@ -43,8 +43,10 @@ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH) -#define xybit(y) (1<<((y)&7)) +unsigned char RAM[(GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)]; + +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) +#define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ /* Driver exported functions. */ @@ -72,19 +74,19 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); - write_cmd(g, PCF8812_TEMP_CONTROL | PCF8812_TEMP_MODE_1); - write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_cmd(g, PCF8812_SET_VOP | 0xFF); + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); + write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_cmd(g, PCF8812_SET_VOP | 0xFF); write_cmd(g, PCF8812_SET_FUNC); - write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); - + write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_cmd(g, PCF8812_SET_X); // X = 0 + write_cmd(g, PCF8812_SET_Y); // Y = 0 unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); ++i) + for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i++) { - RAM(g)[i] &= 0x00; write_data(g, (uint8_t*)0x00, 1); } @@ -115,8 +117,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; acquire_bus(g); - for (i = 0; i < 9; ++i) { - write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); + + //write_cmd(g, PCF8812_SET_X); + //write_cmd(g, PCF8812_SET_Y); + + for (i = 0; i < 9; i++) { + write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); } release_bus(g); } @@ -145,7 +151,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = g->p.x; break; } - if (gdispColor2Native(g->p.color) == Black) + if (gdispColor2Native(g->p.color) != Black) RAM(g)[xyaddr(x, y)] |= xybit(y); else RAM(g)[xyaddr(x, y)] &= ~xybit(y); @@ -153,61 +159,4 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } #endif -#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL - LLDSPEC void gdisp_lld_control(GDisplay *g) { - switch(g->p.x) { - case GDISP_CONTROL_POWER: - if (g->g.Powermode == (powermode_t)g->p.ptr) - return; - switch((powermode_t)g->p.ptr) { - case powerOff: - case powerSleep: - case powerDeepSleep: - acquire_bus(g); - write_cmd(g, PCF8812_DISPLAY_OFF); - release_bus(g); - break; - case powerOn: - acquire_bus(g); - write_cmd(g, PCF8812_DISPLAY_ON); - release_bus(g); - break; - default: - return; - } - g->g.Powermode = (powermode_t)g->p.ptr; - return; - - case GDISP_CONTROL_ORIENTATION: - if (g->g.Orientation == (orientation_t)g->p.ptr) - return; - switch((orientation_t)g->p.ptr) { - /* Rotation is handled by the drawing routines */ - case GDISP_ROTATE_0: - case GDISP_ROTATE_180: - g->g.Height = GDISP_SCREEN_HEIGHT; - g->g.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - case GDISP_ROTATE_270: - g->g.Height = GDISP_SCREEN_WIDTH; - g->g.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - g->g.Orientation = (orientation_t)g->p.ptr; - return; - - case GDISP_CONTROL_CONTRAST: - if ((unsigned)g->p.ptr > 100) - g->p.ptr = (void *)100; - acquire_bus(g); - release_bus(g); - g->g.Contrast = (unsigned)g->p.ptr; - return; - } - } -#endif // GDISP_NEED_CONTROL - #endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCF8812/gdisp_lld_config.h b/drivers/gdisp/PCF8812/gdisp_lld_config.h index f95fc178..598f71af 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_config.h +++ b/drivers/gdisp/PCF8812/gdisp_lld_config.h @@ -16,9 +16,8 @@ #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing #define GDISP_HARDWARE_DRAWPIXEL TRUE -#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO #endif /* GFX_USE_GDISP */ From dc0f291350e8f44ceaf889c559f05342feacf6c9 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 25 Jun 2014 00:51:05 +1000 Subject: [PATCH 04/38] First cut eCos port --- src/gos/ecos.c | 112 ++++++++++++++++++++++++++++++++++++++++++ src/gos/ecos.h | 106 +++++++++++++++++++++++++++++++++++++++ src/gos/sys_defs.h | 2 + src/gos/sys_options.h | 7 +++ src/gos/sys_rules.h | 4 +- 5 files changed, 229 insertions(+), 2 deletions(-) create mode 100644 src/gos/ecos.c create mode 100644 src/gos/ecos.h diff --git a/src/gos/ecos.c b/src/gos/ecos.c new file mode 100644 index 00000000..5b94497a --- /dev/null +++ b/src/gos/ecos.c @@ -0,0 +1,112 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#include "gfx.h" + +#if GFX_USE_OS_ECOS + +void _gosInit(void) +{ + /* Don't initialise if the user already has */ + //cyg_scheduler_start(); +} + +void _gosDeinit(void) +{ + /* ToDo */ +} + +void gfxSleepMilliseconds(delaytime_t ms) +{ + switch(ms) { + case TIME_IMMEDIATE: cyg_thread_yield(); return; + case TIME_INFINITE: cyg_thread_suspend(cyg_thread_self()); return; + default: cyg_thread_delay(gfxMillisecondsToTicks(ms)); return; + } +} + +void gfxSleepMicroseconds(delaytime_t ms) +{ + switch(ms) { + case TIME_IMMEDIATE: return; + case TIME_INFINITE: cyg_thread_suspend(cyg_thread_self()); return; + default: cyg_thread_delay(gfxMillisecondsToTicks(ms/1000)); return; + } +} + +void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit) +{ + if (val > limit) + val = limit; + + psem->limit = limit; + cyg_semaphore_init(&psem->sem, val); +} + +void gfxSemDestroy(gfxSem *psem) +{ + cyg_semaphore_destroy(&psem->sem); +} + +bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) +{ + switch(ms) { + case TIME_IMMEDIATE: return cyg_semaphore_trywait(&psem->sem); + case TIME_INFINITE: return cyg_semaphore_wait(&psem->sem); + default: return cyg_semaphore_timed_wait(&psem->sem, gfxMillisecondsToTicks(ms)+cyg_current_time()); + } +} + +bool_t gfxSemWaitI(gfxSem *psem) +{ + return cyg_semaphore_trywait(&psem->sem); +} + +void gfxSemSignal(gfxSem *psem) +{ + if (psem->limit == MAX_SEMAPHORE_COUNT) + cyg_semaphore_post(&psem->sem); + else { + cyg_scheduler_lock(); + if (gfxSemCounterI(psem) < psem->limit) + cyg_semaphore_post(&psem->sem); + cyg_scheduler_unlock(); + } +} + +void gfxSemSignalI(gfxSem *psem) +{ + if (psem->limit == MAX_SEMAPHORE_COUNT || gfxSemCounterI(psem) < psem->limit) + cyg_semaphore_post(&psem->sem); +} + +semcount_t gfxSemCounterI(gfxSem *psem) { + semcount_t cnt; + + cyg_semaphore_peek(&psem->sem, &cnt); + return cnt; +} + +gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) +{ + gfxThreadHandle th; + + if (!stackarea) { + if (!stacksz) stacksz = CYGNUM_HAL_STACK_SIZE_TYPICAL; + if (!(stackarea = gfxAlloc(stacksz+sizeof(cyg_thread)))) + return 0; + } + + if (!stacksz) + return 0; + + cyg_thread_create(prio, fn, param, "uGFX", (((cyg_thread *)stackarea)+1), stacksz, &th, (cyg_thread *)stackarea); + cyg_thread_resume(th); + return th; +} + +#endif /* GFX_USE_OS_ECOS */ diff --git a/src/gos/ecos.h b/src/gos/ecos.h new file mode 100644 index 00000000..c24f3824 --- /dev/null +++ b/src/gos/ecos.h @@ -0,0 +1,106 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _GOS_ECOS_H +#define _GOS_ECOS_H + +#if GFX_USE_OS_ECOS + +#include +#include +#include + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +typedef cyg_bool_t bool_t; +typedef cyg_int8 int8_t; +typedef cyg_uint8 uint8_t; +typedef cyg_int16 int16_t; +typedef cyg_uint16 uint16_t; +typedef cyg_int32 int32_t; +typedef cyg_uint32 uint32_t; +typedef cyg_uint32 size_t; + +#define TRUE -1 +#define FALSE 0 +#define TIME_IMMEDIATE 0 +#define TIME_INFINITE 0xFFFFFFFF + +typedef cyg_ucount32 delaytime_t; +typedef cyg_tick_count_t systemticks_t; +typedef cyg_count32 semcount_t; +typedef void threadreturn_t; +typedef cyg_addrword_t threadpriority_t; +typedef cyg_handle_t gfxThreadHandle; + +#define MAX_SEMAPHORE_COUNT 0x7FFFFFFF +#define LOW_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES-2) +#define NORMAL_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES/2) +#define HIGH_PRIORITY 0 + +#define DECLARE_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[sz]; } name[1] +#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(cyg_addrword_t param) + +typedef struct { + cyg_sem_t sem; + semcount_t limit; + } gfxSem; + +typedef cyg_mutex_t gfxMutex; + + +/*===========================================================================*/ +/* Function declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define gfxSystemTicks() cyg_current_time() +#define gfxExit() exit(0) +#define gfxHalt(msg) exit(-1) +#define gfxYield() cyg_thread_yield() + +#define gfxMillisecondsToTicks(ms) (((ms)*(CYGNUM_HAL_RTC_DENOMINATOR*1000))/(CYGNUM_HAL_RTC_NUMERATOR/1000)) +void gfxSleepMilliseconds(delaytime_t ms); +void gfxSleepMicroseconds(delaytime_t ms); + +#define gfxAlloc(sz) malloc(sz) +#define gfxFree(ptr) free(sz) +#define gfxRealloc(ptr, oldsz, newsz) realloc(ptr, newsz) + +#define gfxSystemLock() cyg_scheduler_lock() +#define gfxSystemUnlock() cyg_scheduler_unlock() + +#define gfxMutexInit(pmutex) cyg_mutex_init(pmutex) +#define gfxMutexExit(pmutex) cyg_mutex_unlock(pmutex) +#define gfxMutexDestroy(pmutex) cyg_mutex_destroy(pmutex) +#define gfxMutexEnter(pmutex) cyg_mutex_lock(pmutex) + +void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit); +void gfxSemDestroy(gfxSem *psem); +bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); +bool_t gfxSemWaitI(gfxSem *psem); +void gfxSemSignal(gfxSem *psem); +void gfxSemSignalI(gfxSem *psem); +semcount_t gfxSemCounterI(gfxSem *psem); +#define gfxSemCounter(psem) gfxSemCounterI(psem) + +gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); +#define gfxThreadWait(thread) NOTIMPLEMENTED_YET +#define gfxThreadMe() cyg_thread_self() +#define gfxThreadClose(thread) (void)thread + +#ifdef __cplusplus +} +#endif + +#endif /* GFX_USE_OS_ECOS */ +#endif /* _GOS_ECOS_H */ diff --git a/src/gos/sys_defs.h b/src/gos/sys_defs.h index c55cdf73..9da9dff0 100644 --- a/src/gos/sys_defs.h +++ b/src/gos/sys_defs.h @@ -451,6 +451,8 @@ #include "src/gos/osx.h" #elif GFX_USE_OS_RAW32 #include "src/gos/raw32.h" +#elif GFX_USE_OS_ECOS + #include "src/gos/ecos.h" #else #error "Your operating system is not supported yet" #endif diff --git a/src/gos/sys_options.h b/src/gos/sys_options.h index cfbed057..c0cce08f 100644 --- a/src/gos/sys_options.h +++ b/src/gos/sys_options.h @@ -62,6 +62,13 @@ #ifndef GFX_USE_OS_RAW32 #define GFX_USE_OS_RAW32 FALSE #endif + /** + * @brief Use a eCos + * @details Defaults to FALSE + */ + #ifndef GFX_USE_OS_ECOS + #define GFX_USE_OS_ECOS FALSE + #endif /** * @} * diff --git a/src/gos/sys_rules.h b/src/gos/sys_rules.h index f23d330b..0da01ff2 100644 --- a/src/gos/sys_rules.h +++ b/src/gos/sys_rules.h @@ -16,7 +16,7 @@ #ifndef _GOS_RULES_H #define _GOS_RULES_H -#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS +#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS #if GFX_DISPLAY_RULE_WARNINGS #warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you." #endif @@ -24,7 +24,7 @@ #define GFX_USE_OS_CHIBIOS TRUE #endif -#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS != 1 * TRUE +#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS != 1 * TRUE #error "GOS: More than one operation system has been defined as TRUE." #endif From 8a3da5a2a3b0ff92227cab1dd65eb8f259a4bff5 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 2 Jul 2014 11:52:08 +1000 Subject: [PATCH 05/38] Add framebuffer board file to interface with the eCos framebuffer device. --- boards/addons/gdisp/board_framebuffer_eCos.h | 94 ++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 boards/addons/gdisp/board_framebuffer_eCos.h diff --git a/boards/addons/gdisp/board_framebuffer_eCos.h b/boards/addons/gdisp/board_framebuffer_eCos.h new file mode 100644 index 00000000..80c9147b --- /dev/null +++ b/boards/addons/gdisp/board_framebuffer_eCos.h @@ -0,0 +1,94 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * Note: this implementation makes a number of design choices... + * 1/ We are using the macro definitions for eCos framebuffer driver. If you want to use the + * function's instead you could use the g->board variable to store your cyg_fb pointer. + * 2/ We assume the initialisation succeeds. It is probably a fatal error if it doesn't. + * 3/ We hard-code in this file the pixel format, whether flushing is required and the FRAMEBUF device. + * Please adjust them for your hardware. + */ + +// Set this to your frame buffer pixel format. +#ifndef GDISP_LLD_PIXELFORMAT + #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#endif + +// Uncomment this if your frame buffer device requires flushing ("Synch" in eCos speak) +//#define GDISP_HARDWARE_FLUSH TRUE + +#ifdef GDISP_DRIVER_VMT + + #include + + // SET THIS HERE!!! + // This must also match the pixel format above + #define FRAMEBUF 640x480x16 + + static void board_init(GDisplay *g, fbInfo *fbi) { + // Initialize the frame buffer device - we assume everything is going to succeed. + CYG_FB_ON(FRAMEBUF); + #if (CYG_FB_FLAGS0(FRAMEBUF) & CYG_FB_FLAGS0_MUST_BE_ON) + CYG_FB_FILL_BLOCK(FRAMEBUF, 0, 0, CYG_FB_WIDTH(FRAMEBUF), CYG_FB_HEIGHT(FRAMEBUF), CYG_FB_MAKE_COLOUR(FRAMEBUF, 0, 0, 0)); + #endif + + // Set the details of the frame buffer + #ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_VIEWPORT + g->g.Width = CYG_FB_VIEWPORT_WIDTH(FRAMEBUF); + g->g.Height = CYG_FB_VIEWPORT_HEIGHT(FRAMEBUF); + #else + g->g.Width = CYG_FB_WIDTH(FRAMEBUF); + g->g.Height = CYG_FB_HEIGHT(FRAMEBUF); + #endif + g->g.Backlight = 100; + g->g.Contrast = 50; + fbi->linelen = CYG_FB_STRIDE(FRAMEBUF); // bytes per row + fbi->pixels = CYG_FB_BASE(FRAMEBUF); // pointer to the memory frame buffer + } + + #if GDISP_HARDWARE_FLUSH + static void board_flush(GDisplay *g) { + (void) g; + + // You might want to replace CYG_FB_UPDATE_NOW with CYG_FB_UPDATE_VERTICAL_RETRACE + // if you are not using uGFX's auto flush or timer flush mechanisms and frame synchronisation + // is important for your display. + CYG_FB_SYNCH(FRAMEBUF, CYG_FB_UPDATE_NOW); + } + #endif + + #if GDISP_NEED_CONTROL + static void board_backlight(GDisplay *g, uint8_t percent) { + (void) g; + #if (CYG_FB_FLAGS0(FRAMEBUF) & CYG_FB_FLAGS0_BACKLIGHT) + cyg_fb_ioctl_backlight backlight; + size_t len = sizeof(cyg_fb_ioctl_backlight); + + if (CYG_FB_IOCTL(FRAMEBUF, CYG_FB_IOCTL_BACKLIGHT_GET, &backlight, &len) || !backlight.fbbl_max) + return; + if (backlight.fbbl_max == 1) + backlight.fbbl_current = percent ? 1 : 0; + else + backlight.fbbl_current = (((uint32_t)percent)*backlight.fbbl_max)/100; + CYG_FB_IOCTL(FRAMEBUF, CYG_FB_IOCTL_BACKLIGHT_SET, &backlight, &len); + #endif + } + + static void board_contrast(GDisplay *g, uint8_t percent) { + (void) g; + (void) percent; + } + + static void board_power(GDisplay *g, powermode_t pwr) { + // Not implemented yet. + (void) g; + (void) pwr; + } + #endif + +#endif /* GDISP_DRIVER_VMT */ From 2b141cea7f30cb45f559db5949dcfbf0ebb7c613 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 2 Jul 2014 03:53:38 +0200 Subject: [PATCH 06/38] adding RAW32 to gfxconf.example.h --- gfxconf.example.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gfxconf.example.h b/gfxconf.example.h index bc9964e6..66411ec3 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -26,6 +26,7 @@ /////////////////////////////////////////////////////////////////////////// // GOS - One of these must be defined, preferably in your Makefile // /////////////////////////////////////////////////////////////////////////// +//#define GFX_USE_OS_RAW32 FALSE //#define GFX_USE_OS_CHIBIOS FALSE //#define GFX_USE_OS_FREERTOS FALSE // #define GFX_FREERTOS_USE_TRACE FALSE From 9c3935bdb409ed59889aad8b5da45302b2fb1951 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 2 Jul 2014 12:28:20 +1000 Subject: [PATCH 07/38] Add eCos to gfxconf.example.h --- gfxconf.example.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfxconf.example.h b/gfxconf.example.h index bc9964e6..ad84181e 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -26,12 +26,14 @@ /////////////////////////////////////////////////////////////////////////// // GOS - One of these must be defined, preferably in your Makefile // /////////////////////////////////////////////////////////////////////////// +//#define GFX_USE_OS_RAW32 FALSE //#define GFX_USE_OS_CHIBIOS FALSE //#define GFX_USE_OS_FREERTOS FALSE // #define GFX_FREERTOS_USE_TRACE FALSE //#define GFX_USE_OS_WIN32 FALSE //#define GFX_USE_OS_LINUX FALSE //#define GFX_USE_OS_OSX FALSE +//#define GFX_USE_OS_ECOS FALSE /////////////////////////////////////////////////////////////////////////// From 5c421b09f72c679e2052a65a58fa4314b8acf9d0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 2 Jul 2014 15:05:12 +0300 Subject: [PATCH 08/38] edit --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 88fc2aea..d280fd21 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -43,8 +43,6 @@ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -unsigned char RAM[(GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)]; - #define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) #define xybit(y) (1 << ((y) & 7)) @@ -61,7 +59,7 @@ unsigned char RAM[(GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)]; LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // The private area is the display surface. - g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8)); + g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8))); // Initialise the board interface init_board(g); @@ -85,13 +83,14 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT / 8); i++) + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { - write_data(g, (uint8_t*)0x00, 1); + RAM(g)[i] = 0x00; + write_data(g, 0x00, 1); } - // Finish Init - post_init_board(g); + // Finish Init + post_init_board(g); // Release the bus release_bus(g); @@ -114,15 +113,17 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; - unsigned int i; - acquire_bus(g); - //write_cmd(g, PCF8812_SET_X); - //write_cmd(g, PCF8812_SET_Y); + write_cmd(g, PCF8812_SET_X); + write_cmd(g, PCF8812_SET_Y); - for (i = 0; i < 9; i++) { - write_data(g, RAM(g) + (i * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); + unsigned char x, y; + + for (y = 0; y < (GDISP_SCREEN_HEIGHT / 8); y++) { + for(x = 0; x < GDISP_SCREEN_WIDTH; x++) { + write_data(g, RAM(g) + xyaddr(x, y), 1); + } } release_bus(g); } @@ -151,7 +152,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = g->p.x; break; } - if (gdispColor2Native(g->p.color) != Black) + if (gdispColor2Native(g->p.color) == Black) RAM(g)[xyaddr(x, y)] |= xybit(y); else RAM(g)[xyaddr(x, y)] &= ~xybit(y); From fd17106f99338e91485f8bbdee5af727ac07f2d7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Jul 2014 00:19:39 +0300 Subject: [PATCH 09/38] work --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index d280fd21..668d8ffd 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -83,9 +83,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) - { - RAM(g)[i] = 0x00; + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { write_data(g, 0x00, 1); } @@ -110,21 +108,21 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { LLDSPEC void gdisp_lld_flush(GDisplay *g) { // Don't flush if we don't need it. - if (!(g->flags & GDISP_FLG_NEEDFLUSH)) + if (!(g->flags & GDISP_FLG_NEEDFLUSH)) { return; + } acquire_bus(g); write_cmd(g, PCF8812_SET_X); write_cmd(g, PCF8812_SET_Y); - unsigned char x, y; + unsigned int i; - for (y = 0; y < (GDISP_SCREEN_HEIGHT / 8); y++) { - for(x = 0; x < GDISP_SCREEN_WIDTH; x++) { - write_data(g, RAM(g) + xyaddr(x, y), 1); - } + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { + write_data(g, RAM(g)[i], 1); } + release_bus(g); } #endif @@ -152,10 +150,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = g->p.x; break; } - if (gdispColor2Native(g->p.color) == Black) + + if (gdispColor2Native(g->p.color) != Black) { RAM(g)[xyaddr(x, y)] |= xybit(y); - else + } else { RAM(g)[xyaddr(x, y)] &= ~xybit(y); + } + g->flags |= GDISP_FLG_NEEDFLUSH; } #endif From 7f9a894587ab881ff47b6dddb17e0f441a7cfa59 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 3 Jul 2014 17:28:20 +1000 Subject: [PATCH 10/38] Missing gfxconf definitions for the RAW32 port --- gfxconf.example.h | 5 ++++- src/gos/sys_options.h | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gfxconf.example.h b/gfxconf.example.h index 66411ec3..686f4473 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -26,13 +26,16 @@ /////////////////////////////////////////////////////////////////////////// // GOS - One of these must be defined, preferably in your Makefile // /////////////////////////////////////////////////////////////////////////// -//#define GFX_USE_OS_RAW32 FALSE //#define GFX_USE_OS_CHIBIOS FALSE //#define GFX_USE_OS_FREERTOS FALSE // #define GFX_FREERTOS_USE_TRACE FALSE //#define GFX_USE_OS_WIN32 FALSE //#define GFX_USE_OS_LINUX FALSE //#define GFX_USE_OS_OSX FALSE +//#define GFX_USE_OS_RAW32 FALSE +// #define GOS_RAW_HEAP_SIZE 0 +// #define INTERRUPTS_OFF() optional_code +// #define INTERRUPTS_ON() optional_code /////////////////////////////////////////////////////////////////////////// diff --git a/src/gos/sys_options.h b/src/gos/sys_options.h index cfbed057..c7376878 100644 --- a/src/gos/sys_options.h +++ b/src/gos/sys_options.h @@ -75,6 +75,19 @@ #ifndef GFX_FREERTOS_USE_TRACE #define GFX_FREERTOS_USE_TRACE FALSE #endif + /** + * @brief How much RAM should uGFX use for the heap + * @details Defaults to 0. Only valid with GFX_USE_OS_RAW32 + * @note If 0 then the standard C runtime malloc(), free() and realloc() + * are used. + * @note If it is non-zero then this is the number of bytes of RAM + * to use for the heap (gfxAlloc() and gfxFree()). No C + * runtime routines will be used and a new routine @p gfxAddHeapBlock() + * is added allowing the user to add extra memory blocks to the heap. + */ + #ifndef GOS_RAW_HEAP_SIZE + #define GOS_RAW_HEAP_SIZE 0 + #endif /** @} */ #endif /* _GOS_OPTIONS_H */ From d8d47f804e245b48afbc0058aa3731c58934dfda Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Jul 2014 18:13:49 +0300 Subject: [PATCH 11/38] work driver pcf8812 --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 668d8ffd..87d5d6d9 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -9,7 +9,7 @@ #if GFX_USE_GDISP -#define GDISP_DRIVER_VMT GDISPVMT_PCF8812 +#define GDISP_DRIVER_VMT GDISPVMT_PCF8812 #include "drivers/gdisp/PCF8812/gdisp_lld_config.h" #include "src/gdisp/driver.h" @@ -20,10 +20,10 @@ /*===========================================================================*/ #ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 65 + #define GDISP_SCREEN_HEIGHT 65 #endif #ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 102 + #define GDISP_SCREEN_WIDTH 102 #endif #ifndef GDISP_INITIAL_CONTRAST #define GDISP_INITIAL_CONTRAST 51 @@ -41,7 +41,7 @@ /*===========================================================================*/ // Some common routines and macros -#define RAM(g) ((uint8_t *)g->priv) +#define RAM(g) ((uint8_t *)g->priv) #define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) #define xybit(y) (1 << ((y) & 7)) @@ -54,7 +54,7 @@ * As this controller can't update on a pixel boundary we need to maintain the * the entire display surface in memory so that we can do the necessary bit * operations. Fortunately it is a small display in monochrome. - * 65 * 102 / 8 = 829 bytes. + * 102 * 65 / 8 = 828,75 bytes. */ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { @@ -72,18 +72,18 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); - write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); - write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_cmd(g, PCF8812_SET_VOP | 0xFF); + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); + write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_cmd(g, PCF8812_SET_VOP | 0xFF); write_cmd(g, PCF8812_SET_FUNC); - write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); write_cmd(g, PCF8812_SET_X); // X = 0 write_cmd(g, PCF8812_SET_Y); // Y = 0 - unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { + + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { write_data(g, 0x00, 1); } @@ -93,6 +93,9 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // Release the bus release_bus(g); + /* Turn on the back-light */ + set_backlight(g, GDISP_INITIAL_BACKLIGHT); + /* Initialise the GDISP structure */ g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; @@ -114,12 +117,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_X); - write_cmd(g, PCF8812_SET_Y); + write_cmd(g, PCF8812_SET_X); // X = 0 + write_cmd(g, PCF8812_SET_Y); // Y = 0 unsigned int i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); i++) { + for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { write_data(g, RAM(g)[i], 1); } @@ -129,7 +132,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { - coord_t x, y; + coord_t x, y; switch(g->g.Orientation) { default: From 54a0387bd47df37d7f2e17bdeff4a99ea6d94163 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 4 Jul 2014 00:23:12 +0200 Subject: [PATCH 12/38] fixing doxygen typo --- src/gfile/sys_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gfile/sys_defs.h b/src/gfile/sys_defs.h index 4280f7fe..0c5bac0c 100644 --- a/src/gfile/sys_defs.h +++ b/src/gfile/sys_defs.h @@ -73,7 +73,7 @@ extern "C" { /** * @brief Get the size of a file - * @note Please use @p gfileGetSize() if the file is not opened + * @note Please use @p gfileGetSize() if the file is opened * * @param[in] fname The file name * From e4eba63f95b5abfad46dc45390e5709cf3ee61c4 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 4 Jul 2014 23:53:50 +0200 Subject: [PATCH 13/38] Frame widget doxygen fix --- src/gwin/frame.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gwin/frame.h b/src/gwin/frame.h index bf7cd2d8..fc5daf8e 100644 --- a/src/gwin/frame.h +++ b/src/gwin/frame.h @@ -45,8 +45,7 @@ typedef struct GFrameObject { /** * @brief Create a frame widget * - * @details This widget provides a window like we know it from desktop systems. You usually use this together with - * gwinAddChild(). + * @details This widget provides a window like we know it from desktop systems. * * @param[in] g The GDisplay to display this window on * @param[in] fo The GFrameObject structure to initialize. If this is NULL the structure is dynamically allocated. @@ -54,7 +53,7 @@ typedef struct GFrameObject { * @param[in] flags Some flags, see notes. * * @note Possible flags are: GWIN_FRAME_BORDER, GWIN_FRAME_CLOSE_BTN, GWIN_FRAME_MINMAX_BTN. - * Whether the close or the minimize maximize buttons are used, the boarder is automatically invoked. + * When the close or the minimize/maximize buttons are used, the boarder is automatically invoked. * @note These frame buttons are processed internally. The close button will invoke a gwinDestroy() which will * destroy the window itself and EVERY child it contains (also children of children). * From 2cc1dd96ea455f1f8e6d6b1e73ed19406eb629d2 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 5 Jul 2014 15:55:45 +0200 Subject: [PATCH 14/38] doxygen fix --- Doxygenfile | 190 ++++++++++++++++++++++------------------------ src/gwin/gimage.h | 2 +- 2 files changed, 92 insertions(+), 100 deletions(-) diff --git a/Doxygenfile b/Doxygenfile index 1ca7ef5a..00ed2fcc 100644 --- a/Doxygenfile +++ b/Doxygenfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.6 +# Doxyfile 1.8.7 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = +PROJECT_NAME = # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -70,6 +70,14 @@ OUTPUT_DIRECTORY = docs CREATE_SUBDIRS = NO +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. @@ -163,7 +171,7 @@ STRIP_FROM_PATH = "C:/Documents and Settings/Administrator/" # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -240,7 +248,7 @@ ALIASES = "iclass=@par Function Class:\n This is an I-Class ... \endif and \cond # ... \endcond blocks. -ENABLED_SECTIONS = +ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the @@ -658,7 +673,7 @@ SHOW_NAMESPACES = YES # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated @@ -682,7 +697,7 @@ LAYOUT_FILE = docs/rsc/layout.xml # search path. Do not use file names with spaces, bibtex cannot handle them. See # also \cite for info how to create references. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -741,7 +756,7 @@ WARN_FORMAT = "$file:$line: $text" # messages should be written. If left blank the output is written to standard # error (stderr). -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files @@ -773,7 +788,7 @@ INPUT_ENCODING = UTF-8 # *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, # *.qsf, *.as and *.js. -FILE_PATTERNS = +FILE_PATTERNS = # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -806,7 +821,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -817,13 +832,13 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = +EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and @@ -843,7 +858,7 @@ EXAMPLE_RECURSIVE = NO # that contain images that are to be included in the documentation (see the # \image command). -IMAGE_PATH = +IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -860,7 +875,7 @@ IMAGE_PATH = # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. -INPUT_FILTER = +INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the @@ -869,7 +884,7 @@ INPUT_FILTER = # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER ) will also be used to filter the input files that are used for @@ -884,14 +899,14 @@ FILTER_SOURCE_FILES = NO # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing @@ -937,7 +952,7 @@ REFERENCES_RELATION = YES # link to the documentation. # The default value is: YES. -REFERENCES_LINK_SOURCE = NO +REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, @@ -979,25 +994,6 @@ USE_HTAGS = NO VERBATIM_HEADERS = NO -# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more acurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1022,7 +1018,7 @@ COLS_IN_ALPHA_INDEX = 5 # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output @@ -1066,7 +1062,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1076,7 +1072,7 @@ HTML_HEADER = # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1088,7 +1084,7 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user- # defined cascading style sheet that is included after the standard style sheets @@ -1099,7 +1095,7 @@ HTML_STYLESHEET = # see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = +HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note @@ -1109,7 +1105,7 @@ HTML_EXTRA_STYLESHEET = # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_FILES = +HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the stylesheet and background images according to @@ -1258,10 +1254,11 @@ GENERATE_CHI = NO # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. +# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1288,7 +1285,7 @@ GENERATE_QHP = NO # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. -QCH_FILE = +QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace @@ -1313,7 +1310,7 @@ QHP_VIRTUAL_FOLDER = doc # filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom @@ -1321,21 +1318,21 @@ QHP_CUST_FILTER_NAME = # filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. -QHG_LOCATION = +QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To @@ -1468,7 +1465,7 @@ MATHJAX_RELPATH = http://www.mathjax.org/mathjax # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site @@ -1476,7 +1473,7 @@ MATHJAX_EXTENSIONS = # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_CODEFILE = +MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and @@ -1501,11 +1498,11 @@ SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. There -# are two flavours of web server based searching depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. See -# the section "External Indexing and Searching" for details. +# are two flavors of web server based searching depending on the EXTERNAL_SEARCH +# setting. When disabled, doxygen will generate a PHP script for searching and +# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing +# and searching needs to be provided by external tools. See the section +# "External Indexing and Searching" for details. # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. @@ -1536,7 +1533,7 @@ EXTERNAL_SEARCH = NO # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. -SEARCHENGINE_URL = +SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the @@ -1552,7 +1549,7 @@ SEARCHDATA_FILE = searchdata.xml # projects and redirect the results back to the right project. # This tag requires that the tag SEARCHENGINE is set to YES. -EXTERNAL_SEARCH_ID = +EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are @@ -1562,7 +1559,7 @@ EXTERNAL_SEARCH_ID = # EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... # This tag requires that the tag SEARCHENGINE is set to YES. -EXTRA_SEARCH_MAPPINGS = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output @@ -1623,7 +1620,7 @@ PAPER_TYPE = a4wide # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = +EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first @@ -1639,7 +1636,7 @@ EXTRA_PACKAGES = # PROJECT_NAME), or the project number (see PROJECT_NUMBER). # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_HEADER = +LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the # generated LaTeX document. The footer should contain everything after the last @@ -1648,7 +1645,7 @@ LATEX_HEADER = # Note: Only use a user-defined footer if you know what you are doing! # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_FOOTER = +LATEX_FOOTER = # The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the LATEX_OUTPUT output @@ -1656,7 +1653,7 @@ LATEX_FOOTER = # markers available. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_FILES = +LATEX_EXTRA_FILES = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is # prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will @@ -1756,14 +1753,14 @@ RTF_HYPERLINKS = NO # default style sheet that doxygen normally uses. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is # similar to doxygen's config file. A template extensions file can be generated # using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # Configuration options related to the man page output @@ -1793,6 +1790,13 @@ MAN_OUTPUT = man MAN_EXTENSION = .3 +# The MAN_SUBDIR tag determines the name of the directory created within +# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by +# MAN_EXTENSION with the initial . removed. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_SUBDIR = + # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it # will generate one additional man file for each entity documented in the real # man page(s). These additional files only source the real man page, but without @@ -1820,18 +1824,6 @@ GENERATE_XML = NO XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify a XML DTD, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_DTD = - # If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program # listings (including syntax highlighting and cross-referencing information) to # the XML output. Note that enabling this will significantly increase the size @@ -1907,7 +1899,7 @@ PERLMOD_PRETTY = YES # overwrite each other's variables. # This tag requires that the tag GENERATE_PERLMOD is set to YES. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor @@ -1948,7 +1940,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = +INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the @@ -1956,7 +1948,7 @@ INCLUDE_PATH = # used. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that are # defined before the preprocessor is started (similar to the -D option of e.g. @@ -1975,12 +1967,12 @@ PREDEFINED = __DOXYGEN__ # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will -# remove all refrences to function-like macros that are alone on a line, have an -# all uppercase name, and do not end with a semicolon. Such function macros are -# typically used for boiler-plate code, and will confuse the parser if not +# remove all references to function-like macros that are alone on a line, have +# an all uppercase name, and do not end with a semicolon. Such function macros +# are typically used for boiler-plate code, and will confuse the parser if not # removed. # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. @@ -2000,17 +1992,17 @@ SKIP_FUNCTION_MACROS = NO # where loc1 and loc2 can be relative or absolute paths or URLs. See the # section "Linking to external documentation" for more information about the use # of tag files. -# Note: Each tag file must have an unique name (where the name does NOT include +# Note: Each tag file must have a unique name (where the name does NOT include # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to # external documentation" for more information about the usage of tag files. -GENERATE_TAGFILE = +GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external class will be listed in the # class index. If set to NO only the inherited external classes will be listed. @@ -2058,14 +2050,14 @@ CLASS_DIAGRAMS = NO # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. # If left empty dia is assumed to be found in the default search path. -DIA_PATH = +DIA_PATH = # If set to YES, the inheritance and collaboration graphs will hide inheritance # and usage relations if the target is undocumented or is not a class. @@ -2114,7 +2106,7 @@ DOT_FONTSIZE = 8 # the path where dot can find it using this tag. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTPATH = +DOT_FONTPATH = # If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for # each documented class showing the direct and indirect inheritance relations. @@ -2252,26 +2244,26 @@ INTERACTIVE_SVG = NO # found. If left blank, it is assumed the dot tool can be found in the path. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_PATH = +DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the \dotfile # command). # This tag requires that the tag HAVE_DOT is set to YES. -DOTFILE_DIRS = +DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the \mscfile # command). -MSCFILE_DIRS = +MSCFILE_DIRS = # The DIAFILE_DIRS tag can be used to specify one or more directories that # contain dia files that are included in the documentation (see the \diafile # command). -DIAFILE_DIRS = +DIAFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes # that will be shown in the graph. If the number of nodes in a graph becomes diff --git a/src/gwin/gimage.h b/src/gwin/gimage.h index 670a9ec4..0052f024 100644 --- a/src/gwin/gimage.h +++ b/src/gwin/gimage.h @@ -9,7 +9,7 @@ * @file src/gwin/gimage.h * @brief GWIN image widget header file. * - * @defgroup Image Image + * @defgroup ImageBox ImageBox * @ingroup Widgets * * @details GWIN allos it to create an image widget. The widget From 71892bf7616cfd3289e728b9034f286681dfccab Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 13:57:28 +0300 Subject: [PATCH 15/38] fixed height bug and add actual display size 96*65 pixels --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 254 +++++++++++++++++----- drivers/gdisp/PCF8812/gdisp_lld_config.h | 6 +- 2 files changed, 208 insertions(+), 52 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 87d5d6d9..cf4518b4 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -12,39 +12,37 @@ #define GDISP_DRIVER_VMT GDISPVMT_PCF8812 #include "drivers/gdisp/PCF8812/gdisp_lld_config.h" #include "src/gdisp/driver.h" - #include "board_PCF8812.h" /*===========================================================================*/ /* Driver local definitions. */ /*===========================================================================*/ -#ifndef GDISP_SCREEN_HEIGHT - #define GDISP_SCREEN_HEIGHT 65 -#endif -#ifndef GDISP_SCREEN_WIDTH - #define GDISP_SCREEN_WIDTH 102 -#endif -#ifndef GDISP_INITIAL_CONTRAST - #define GDISP_INITIAL_CONTRAST 51 -#endif -#ifndef GDISP_INITIAL_BACKLIGHT - #define GDISP_INITIAL_BACKLIGHT 100 -#endif +#define GDISP_MATRIX_HEIGHT 72 +#define GDISP_MATRIX_WIDTH 102 + +#define GDISP_SCREEN_HEIGHT 65 +#define GDISP_SCREEN_WIDTH 96 + +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCF8812/PCF8812.h" /*===========================================================================*/ -/* Driver local functions. */ +/* Driver local routines . */ /*===========================================================================*/ // Some common routines and macros -#define RAM(g) ((uint8_t *)g->priv) +#define RAM(g) ((uint8_t *)g->priv) -#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) -#define xybit(y) (1 << ((y) & 7)) +//#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) +//#define xybit(y) (1 << ((y) & 7)) + +#define xyaddr(x, y) ((((y) / 8) * GDISP_MATRIX_WIDTH) + (x)) +#define xybit(y) (1 << ((y) % 8)) /*===========================================================================*/ /* Driver exported functions. */ @@ -54,12 +52,17 @@ * As this controller can't update on a pixel boundary we need to maintain the * the entire display surface in memory so that we can do the necessary bit * operations. Fortunately it is a small display in monochrome. - * 102 * 65 / 8 = 828,75 bytes. + * Matrix 102 * 65 / 8 = 828,75 bytes. + * Display 96 * 65 / 8 = 780 */ +#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) +#define GDISP_MATRIX_BYTES ((GDISP_MATRIX_WIDTH * GDISP_MATRIX_HEIGHT) / 8) // real height 65 pixels, this fix 65 / 8 != 9 + LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // The private area is the display surface. - g->priv = gfxAlloc((GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8))); + if (!(g->priv = gfxAlloc(GDISP_MATRIX_BYTES))) + gfxHalt("GDISP PCF8812: Failed to allocate private memory"); // Initialise the board interface init_board(g); @@ -72,18 +75,18 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); - write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); - write_cmd(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_cmd(g, PCF8812_SET_VOP | 0xFF); - write_cmd(g, PCF8812_SET_FUNC); - write_cmd(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); - write_cmd(g, PCF8812_SET_X); // X = 0 - write_cmd(g, PCF8812_SET_Y); // Y = 0 + write_index(g, PCF8812_SET_FUNC | PCF8812_H); + write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); + write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); + write_index(g, PCF8812_SET_VOP | 0x00); + write_index(g, PCF8812_SET_FUNC); + write_index(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_index(g, PCF8812_SET_X); // X = 0 + write_index(g, PCF8812_SET_Y); // Y = 0 - unsigned int i; + coord_t i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { + for (i = 0; i < GDISP_MATRIX_BYTES; i++) { write_data(g, 0x00, 1); } @@ -117,12 +120,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_cmd(g, PCF8812_SET_X); // X = 0 - write_cmd(g, PCF8812_SET_Y); // Y = 0 + write_index(g, PCF8812_SET_X | 0); // X = 0 + write_index(g, PCF8812_SET_Y | 0); // Y = 0 - unsigned int i; + coord_t i; - for (i = 0; i < (GDISP_SCREEN_WIDTH * (GDISP_SCREEN_HEIGHT / 8)); ++i) { + for (i = 0; i < GDISP_MATRIX_BYTES; i++) { write_data(g, RAM(g)[i], 1); } @@ -133,26 +136,31 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { coord_t x, y; - - switch(g->g.Orientation) { - default: - case GDISP_ROTATE_0: + + #if GDISP_NEED_CONTROL + switch(g->g.Orientation) { + default: + case GDISP_ROTATE_0: + x = g->p.x; + y = g->p.y; + break; + case GDISP_ROTATE_90: + x = g->p.y; + y = g->g.Height - g->p.x-1; + break; + case GDISP_ROTATE_180: + x = g->g.Width - g->p.x-1; + y = g->g.Height - g->p.y-1; + break; + case GDISP_ROTATE_270: + x = g->g.Height - g->p.y-1; + y = g->p.x; + break; + } + #else x = g->p.x; y = g->p.y; - break; - case GDISP_ROTATE_90: - x = g->p.y; - y = GDISP_SCREEN_HEIGHT-1 - g->p.x; - break; - case GDISP_ROTATE_180: - x = GDISP_SCREEN_WIDTH-1 - g->p.x; - y = GDISP_SCREEN_HEIGHT-1 - g->p.y; - break; - case GDISP_ROTATE_270: - x = GDISP_SCREEN_HEIGHT-1 - g->p.y; - y = g->p.x; - break; - } + #endif if (gdispColor2Native(g->p.color) != Black) { RAM(g)[xyaddr(x, y)] |= xybit(y); @@ -164,4 +172,148 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } #endif +/* +#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + switch(g->p.x) { + case GDISP_CONTROL_POWER: + if (g->g.Powermode == (powermode_t)g->p.ptr) + return; + switch((powermode_t)g->p.ptr) { + case powerOff: + acquire_bus(g); + + release_bus(g); + break; + case powerOn: + acquire_bus(g); + + release_bus(g); + break; + case powerSleep: + acquire_bus(g); + + release_bus(g); + break; + default: + return; + } + g->g.Powermode = (powermode_t)g->p.ptr; + return; + + case GDISP_CONTROL_ORIENTATION: + if (g->g.Orientation == (orientation_t)g->p.ptr) + return; + switch((orientation_t)g->p.ptr) { + case GDISP_ROTATE_0: + acquire_bus(g); + + release_bus(g); + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_90: + acquire_bus(g); + + release_bus(g); + g->g.Height = GDISP_SCREEN_WIDTH; + g->g.Width = GDISP_SCREEN_HEIGHT; + break; + case GDISP_ROTATE_180: + acquire_bus(g); + + release_bus(g); + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Width = GDISP_SCREEN_WIDTH; + break; + case GDISP_ROTATE_270: + acquire_bus(g); + + release_bus(g); + g->g.Height = GDISP_SCREEN_WIDTH; + g->g.Width = GDISP_SCREEN_HEIGHT; + break; + default: + return; + } + g->g.Orientation = (orientation_t)g->p.ptr; + return; + + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)g->p.ptr > 100) + g->p.ptr = (void *)100; + set_backlight(g, (unsigned)g->p.ptr); + g->g.Backlight = (unsigned)g->p.ptr; + return; + + //case GDISP_CONTROL_CONTRAST: + default: + return; + } + } +#endif +*/ +#if GDISP_NEED_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + switch(g->p.x) { + case GDISP_CONTROL_POWER: + if (g->g.Powermode == (powermode_t)g->p.ptr) + return; + switch((powermode_t)g->p.ptr) { + case powerOff: case powerOn: case powerSleep: case powerDeepSleep: + //board_power(g, (powermode_t)g->p.ptr); + break; + default: + return; + } + g->g.Powermode = (powermode_t)g->p.ptr; + return; + + case GDISP_CONTROL_ORIENTATION: + if (g->g.Orientation == (orientation_t)g->p.ptr) + return; + switch((orientation_t)g->p.ptr) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + write_index(g, PCF8812_SET_FUNC | PCF8812_H | 0x01); + if (g->g.Orientation == GDISP_ROTATE_90 || g->g.Orientation == GDISP_ROTATE_270) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + write_index(g, PCF8812_SET_FUNC | PCF8812_V | 0x01); + if (g->g.Orientation == GDISP_ROTATE_0 || g->g.Orientation == GDISP_ROTATE_180) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + default: + return; + } + g->g.Orientation = (orientation_t)g->p.ptr; + return; + + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + //board_backlight(g, (unsigned)g->p.ptr); + g->g.Backlight = (unsigned)g->p.ptr; + return; + + case GDISP_CONTROL_CONTRAST: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + //board_contrast(g, (unsigned)g->p.ptr); + g->g.Contrast = (unsigned)g->p.ptr; + return; + } + } +#endif + #endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCF8812/gdisp_lld_config.h b/drivers/gdisp/PCF8812/gdisp_lld_config.h index 598f71af..6ad8a571 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_config.h +++ b/drivers/gdisp/PCF8812/gdisp_lld_config.h @@ -16,8 +16,12 @@ #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing #define GDISP_HARDWARE_DRAWPIXEL TRUE +#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +// Set this to your frame buffer pixel format. +#ifndef GDISP_LLD_PIXELFORMAT + #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +#endif #endif /* GFX_USE_GDISP */ From 28f9e7f7669c900a471aef6936d56a3a51b243ea Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 19:29:50 +0300 Subject: [PATCH 16/38] fixed orientation 0 90 180 270 degree --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 107 +++------------------- 1 file changed, 11 insertions(+), 96 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index cf4518b4..91f77351 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -38,11 +38,8 @@ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -//#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) -//#define xybit(y) (1 << ((y) & 7)) - -#define xyaddr(x, y) ((((y) / 8) * GDISP_MATRIX_WIDTH) + (x)) -#define xybit(y) (1 << ((y) % 8)) +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) +#define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ /* Driver exported functions. */ @@ -56,7 +53,7 @@ * Display 96 * 65 / 8 = 780 */ -#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) +//#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) #define GDISP_MATRIX_BYTES ((GDISP_MATRIX_WIDTH * GDISP_MATRIX_HEIGHT) / 8) // real height 65 pixels, this fix 65 / 8 != 9 LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { @@ -76,9 +73,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); write_index(g, PCF8812_SET_FUNC | PCF8812_H); - write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_1); - write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_1); - write_index(g, PCF8812_SET_VOP | 0x00); + write_index(g, PCF8812_SET_BIAS | PCF8812_BIAS_MODE_7); + write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_2); + write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_0); + write_index(g, PCF8812_SET_VOP | 0xFF); write_index(g, PCF8812_SET_FUNC); write_index(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); write_index(g, PCF8812_SET_X); // X = 0 @@ -146,14 +144,14 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: x = g->p.y; - y = g->g.Height - g->p.x-1; + y = g->p.x; break; case GDISP_ROTATE_180: - x = g->g.Width - g->p.x-1; - y = g->g.Height - g->p.y-1; + x = g->g.Width - g->p.x - 1; + y = g->g.Height - g->p.y - 1; break; case GDISP_ROTATE_270: - x = g->g.Height - g->p.y-1; + x = g->g.Height - g->p.y - 1; y = g->p.x; break; } @@ -172,87 +170,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } #endif -/* -#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL - LLDSPEC void gdisp_lld_control(GDisplay *g) { - switch(g->p.x) { - case GDISP_CONTROL_POWER: - if (g->g.Powermode == (powermode_t)g->p.ptr) - return; - switch((powermode_t)g->p.ptr) { - case powerOff: - acquire_bus(g); - - release_bus(g); - break; - case powerOn: - acquire_bus(g); - - release_bus(g); - break; - case powerSleep: - acquire_bus(g); - - release_bus(g); - break; - default: - return; - } - g->g.Powermode = (powermode_t)g->p.ptr; - return; - - case GDISP_CONTROL_ORIENTATION: - if (g->g.Orientation == (orientation_t)g->p.ptr) - return; - switch((orientation_t)g->p.ptr) { - case GDISP_ROTATE_0: - acquire_bus(g); - - release_bus(g); - g->g.Height = GDISP_SCREEN_HEIGHT; - g->g.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_90: - acquire_bus(g); - - release_bus(g); - g->g.Height = GDISP_SCREEN_WIDTH; - g->g.Width = GDISP_SCREEN_HEIGHT; - break; - case GDISP_ROTATE_180: - acquire_bus(g); - - release_bus(g); - g->g.Height = GDISP_SCREEN_HEIGHT; - g->g.Width = GDISP_SCREEN_WIDTH; - break; - case GDISP_ROTATE_270: - acquire_bus(g); - - release_bus(g); - g->g.Height = GDISP_SCREEN_WIDTH; - g->g.Width = GDISP_SCREEN_HEIGHT; - break; - default: - return; - } - g->g.Orientation = (orientation_t)g->p.ptr; - return; - - case GDISP_CONTROL_BACKLIGHT: - if ((unsigned)g->p.ptr > 100) - g->p.ptr = (void *)100; - set_backlight(g, (unsigned)g->p.ptr); - g->g.Backlight = (unsigned)g->p.ptr; - return; - - //case GDISP_CONTROL_CONTRAST: - default: - return; - } - } -#endif -*/ #if GDISP_NEED_CONTROL LLDSPEC void gdisp_lld_control(GDisplay *g) { switch(g->p.x) { @@ -275,7 +192,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { switch((orientation_t)g->p.ptr) { case GDISP_ROTATE_0: case GDISP_ROTATE_180: - write_index(g, PCF8812_SET_FUNC | PCF8812_H | 0x01); if (g->g.Orientation == GDISP_ROTATE_90 || g->g.Orientation == GDISP_ROTATE_270) { coord_t tmp; @@ -286,7 +202,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: case GDISP_ROTATE_270: - write_index(g, PCF8812_SET_FUNC | PCF8812_V | 0x01); if (g->g.Orientation == GDISP_ROTATE_0 || g->g.Orientation == GDISP_ROTATE_180) { coord_t tmp; From 76625b646bf3bbbb70a612be993e7003b0033e22 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 19:56:54 +0300 Subject: [PATCH 17/38] fixed orientation 90 degree --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 91f77351..c4543d45 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -144,7 +144,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: x = g->p.y; - y = g->p.x; + y = (g->g.Width - g->p.x - 1); break; case GDISP_ROTATE_180: x = g->g.Width - g->p.x - 1; From b2a85002310b36cd663e2af5b7664c29f4a28404 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Jul 2014 21:14:24 +0300 Subject: [PATCH 18/38] power manager --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index c4543d45..2fcff54b 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -177,8 +177,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { if (g->g.Powermode == (powermode_t)g->p.ptr) return; switch((powermode_t)g->p.ptr) { - case powerOff: case powerOn: case powerSleep: case powerDeepSleep: - //board_power(g, (powermode_t)g->p.ptr); + case powerOff: + case powerSleep: + case powerDeepSleep: + write_index(g, PCF8812_SET_FUNC | PCF8812_PD); + break; + case powerOn: + write_index(g, PCF8812_SET_FUNC); break; default: return; @@ -218,13 +223,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { case GDISP_CONTROL_BACKLIGHT: if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; - //board_backlight(g, (unsigned)g->p.ptr); + set_backlight(g, (unsigned)g->p.ptr); g->g.Backlight = (unsigned)g->p.ptr; return; case GDISP_CONTROL_CONTRAST: if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; - //board_contrast(g, (unsigned)g->p.ptr); + // ToDo g->g.Contrast = (unsigned)g->p.ptr; return; } From efe79a4a310cd9c02dae1eab014346d6092a0d44 Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 7 Jul 2014 11:19:04 +1000 Subject: [PATCH 19/38] eCos fix --- boards/addons/gdisp/board_framebuffer_eCos.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boards/addons/gdisp/board_framebuffer_eCos.h b/boards/addons/gdisp/board_framebuffer_eCos.h index 80c9147b..90226b5d 100644 --- a/boards/addons/gdisp/board_framebuffer_eCos.h +++ b/boards/addons/gdisp/board_framebuffer_eCos.h @@ -28,7 +28,8 @@ // SET THIS HERE!!! // This must also match the pixel format above - #define FRAMEBUF 640x480x16 + //#define FRAMEBUF 640x480x16 + #define FRAMEBUF fb0 static void board_init(GDisplay *g, fbInfo *fbi) { // Initialize the frame buffer device - we assume everything is going to succeed. From f103da84bcc8f2de985e31bb34d04fee65947b23 Mon Sep 17 00:00:00 2001 From: pashamray Date: Mon, 7 Jul 2014 08:49:57 +0000 Subject: [PATCH 20/38] README.md --- drivers/gdisp/PCF8812/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 drivers/gdisp/PCF8812/README.md diff --git a/drivers/gdisp/PCF8812/README.md b/drivers/gdisp/PCF8812/README.md new file mode 100644 index 00000000..3cc98179 --- /dev/null +++ b/drivers/gdisp/PCF8812/README.md @@ -0,0 +1,4 @@ +=== Driver for PCF8812/OM6206 controller === +Displays based on this controller: + Nokia 3410 + Siemens C55/A55/A52 \ No newline at end of file From 4611a10bc93031e45c739da646ec09bae16eaa64 Mon Sep 17 00:00:00 2001 From: pashamray Date: Mon, 7 Jul 2014 08:54:14 +0000 Subject: [PATCH 21/38] README.md --- drivers/gdisp/PCF8812/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gdisp/PCF8812/README.md b/drivers/gdisp/PCF8812/README.md index 3cc98179..b8b9a84a 100644 --- a/drivers/gdisp/PCF8812/README.md +++ b/drivers/gdisp/PCF8812/README.md @@ -1,4 +1,5 @@ -=== Driver for PCF8812/OM6206 controller === +Driver for PCF8812/OM6206 controller +========================== Displays based on this controller: Nokia 3410 Siemens C55/A55/A52 \ No newline at end of file From 34cc5e029a21784bf2eeb17f3c22f3914326d982 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 9 Jul 2014 14:26:16 +1000 Subject: [PATCH 22/38] eCos Synthetic framebuffer is now a supported "base" board. --- .../base/eCos-Synthetic-Framebuffer/board.mk | 5 + .../board_framebuffer.h} | 3 +- .../example/Makefile | 165 ++++++++++++++++++ .../example/readme.txt | 7 + .../eCos-Synthetic-Framebuffer/readme.txt | 11 ++ 5 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 boards/base/eCos-Synthetic-Framebuffer/board.mk rename boards/{addons/gdisp/board_framebuffer_eCos.h => base/eCos-Synthetic-Framebuffer/board_framebuffer.h} (97%) create mode 100644 boards/base/eCos-Synthetic-Framebuffer/example/Makefile create mode 100644 boards/base/eCos-Synthetic-Framebuffer/example/readme.txt create mode 100644 boards/base/eCos-Synthetic-Framebuffer/readme.txt diff --git a/boards/base/eCos-Synthetic-Framebuffer/board.mk b/boards/base/eCos-Synthetic-Framebuffer/board.mk new file mode 100644 index 00000000..d4e9ebe1 --- /dev/null +++ b/boards/base/eCos-Synthetic-Framebuffer/board.mk @@ -0,0 +1,5 @@ +GFXINC += $(GFXLIB)/boards/base/eCos-Synthetic-Framebuffer +GFXSRC += +GFXDEFS += -DGFX_USE_OS_ECOS=TRUE + +include $(GFXLIB)/drivers/gdisp/framebuffer/driver.mk diff --git a/boards/addons/gdisp/board_framebuffer_eCos.h b/boards/base/eCos-Synthetic-Framebuffer/board_framebuffer.h similarity index 97% rename from boards/addons/gdisp/board_framebuffer_eCos.h rename to boards/base/eCos-Synthetic-Framebuffer/board_framebuffer.h index 90226b5d..e8e46131 100644 --- a/boards/addons/gdisp/board_framebuffer_eCos.h +++ b/boards/base/eCos-Synthetic-Framebuffer/board_framebuffer.h @@ -20,7 +20,7 @@ #endif // Uncomment this if your frame buffer device requires flushing ("Synch" in eCos speak) -//#define GDISP_HARDWARE_FLUSH TRUE +#define GDISP_HARDWARE_FLUSH TRUE #ifdef GDISP_DRIVER_VMT @@ -28,7 +28,6 @@ // SET THIS HERE!!! // This must also match the pixel format above - //#define FRAMEBUF 640x480x16 #define FRAMEBUF fb0 static void board_init(GDisplay *g, fbInfo *fbi) { diff --git a/boards/base/eCos-Synthetic-Framebuffer/example/Makefile b/boards/base/eCos-Synthetic-Framebuffer/example/Makefile new file mode 100644 index 00000000..e30e1c92 --- /dev/null +++ b/boards/base/eCos-Synthetic-Framebuffer/example/Makefile @@ -0,0 +1,165 @@ +# +# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!! +# +############################################################################################## +# +# On command line: +# +# make INSTALL_DIR=/path/to/ecos/install all = Create project +# +# make clean = Clean project files. +# +# To rebuild project do "make clean" and "make all". +# + +############################################################################################## +# Start of default section +# + +INSTALL_DIR=$$(INSTALL_DIR) # override on make command line + +include $(INSTALL_DIR)/include/pkgconf/ecos.mak + +CC = $(ECOS_COMMAND_PREFIX)gcc +AS = $(CC) -x assembler-with-cpp +CXX = $(CC) +LD = $(CC) +CFLAGS = -I$(INSTALL_DIR)/include +CXXFLAGS = $(CFLAGS) -g +LDFLAGS = -nostartfiles -L$(INSTALL_DIR)/lib -Ttarget.ld + +# List all default C defines here, like -D_DEBUG=1 +DDEFS = + +# List all default ASM defines here, like -D_DEBUG=1 +DADEFS = + +# List all default directories to look for include files here +DINCDIR = + +# List the default directory to look for the libraries here +DLIBDIR = + +# List all default libraries here +DLIBS = + +# +# End of default section +############################################################################################## + +############################################################################################## +# Start of user section +# + +# Define project name here +PROJECT = ugfx_over_ecos + +# Imported source files and paths for uGFX +GFXLIB = ../ugfx + +include ${GFXLIB}/gfx.mk +include ${GFXLIB}/boards/base/eCos-Synthetic-Framebuffer/board.mk + +# Where is our source code - alter these for your project. +# Either just include the demo makefile or add your own definitions +include $(GFXLIB)/demos/modules/gdisp/basics/demo.mk + +#MYFILES = +#MYCSRC = +#MYDEFS = + +# List all user C define here, like -D_DEBUG=1 +UDEFS = $(MYDEFS) $(GFXDEFS) + +# Define ASM defines here +UADEFS = + +# List C source files here +SRC = $(GFXSRC) \ + $(MYCSRC) + +# List ASM source files here +ASRC = + +# List all user directories here +UINCDIR = $(MYFILES) $(GFXINC) + +# List the user directory to look for the libraries here +ULIBDIR = + +# List all user libraries here +ULIBS = + +# Define optimisation level here +OPT = -ggdb -O0 -fomit-frame-pointer + +# +# End of user defines +############################################################################################## + +INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) +LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) +DEFS = $(DDEFS) $(UDEFS) +ADEFS = $(DADEFS) $(UADEFS) +OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) +LIBS = $(DLIBS) $(ULIBS) + +ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) +CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS) + +ifeq ($(HOST_OSX),yes) + ifeq ($(OSX_SDK),) + OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk + endif + ifeq ($(OSX_ARCH),) + OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 + endif + + CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) + LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR) + LIBS += $(OSX_ARCH) +else + # Linux, or other + CPFLAGS += -m32 -Wa,-alms=$(<:.c=.lst) -I$(INSTALL_DIR)/include + LDFLAGS = -g -nostdlib -m32 -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) -nostartfiles -L$(INSTALL_DIR)/lib -Ttarget.ld +endif + +# Generate dependency information +CPFLAGS += -MD -MP -MF .dep/$(@F).d + +# +# makefile rules +# + +all: $(OBJS) $(PROJECT) + +%.o : %.c + $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ + +%.o : %.s + $(AS) -c $(ASFLAGS) $< -o $@ + +$(PROJECT): $(OBJS) + $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ + +gcov: + -mkdir gcov + $(COV) -u $(subst /,\,$(SRC)) + -mv *.gcov ./gcov + +clean: + -rm -f $(OBJS) + -rm -f $(PROJECT) + -rm -f $(PROJECT).map + -rm -f $(SRC:.c=.c.bak) + -rm -f $(SRC:.c=.lst) + -rm -f $(ASRC:.s=.s.bak) + -rm -f $(ASRC:.s=.lst) + -rm -fR .dep + +# +# Include the dependency files, should be the last of the makefile +# +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + +# *** EOF *** diff --git a/boards/base/eCos-Synthetic-Framebuffer/example/readme.txt b/boards/base/eCos-Synthetic-Framebuffer/example/readme.txt new file mode 100644 index 00000000..ca841f5b --- /dev/null +++ b/boards/base/eCos-Synthetic-Framebuffer/example/readme.txt @@ -0,0 +1,7 @@ +Copy these files into your own project directory and alter them to suite. + +Notes: + +1/ Look at the MYFILES definition and the MYCSRC definition. +2/ To run please install eCos synthetic framebuffer according to the documentation. +3/ Call application ./ugfx_over_ecos -io \ No newline at end of file diff --git a/boards/base/eCos-Synthetic-Framebuffer/readme.txt b/boards/base/eCos-Synthetic-Framebuffer/readme.txt new file mode 100644 index 00000000..6bb1c32b --- /dev/null +++ b/boards/base/eCos-Synthetic-Framebuffer/readme.txt @@ -0,0 +1,11 @@ +This directory contains the interface for eCos using a synthetic framebuffer display. + + + +On this board uGFX currently supports: + + - GDISP via the framebuffer driver + + + +There is an example Makefile and project in the examples directory. From ab9ce99647965d0d3e9ea65ea92ad694c8b8ee1b Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 9 Jul 2014 15:40:03 +1000 Subject: [PATCH 23/38] Support added for the Raspberry Pi - talking directly to the graphics co-processor. --- boards/base/RaspberryPi/board.mk | 4 + boards/base/RaspberryPi/board_framebuffer.h | 89 +++++++++++++++++++++ boards/base/RaspberryPi/readme.txt | 18 +++++ boards/base/RaspberryPi/rpi_mailbox.c | 47 +++++++++++ boards/base/RaspberryPi/rpi_mailbox.h | 7 ++ 5 files changed, 165 insertions(+) create mode 100644 boards/base/RaspberryPi/board.mk create mode 100644 boards/base/RaspberryPi/board_framebuffer.h create mode 100644 boards/base/RaspberryPi/readme.txt create mode 100644 boards/base/RaspberryPi/rpi_mailbox.c create mode 100644 boards/base/RaspberryPi/rpi_mailbox.h diff --git a/boards/base/RaspberryPi/board.mk b/boards/base/RaspberryPi/board.mk new file mode 100644 index 00000000..99fc64db --- /dev/null +++ b/boards/base/RaspberryPi/board.mk @@ -0,0 +1,4 @@ +GFXINC += $(GFXLIB)/boards/base/RaspberryPi +GFXSRC += $(GFXLIB)/boards/base/RaspberryPi/rpi_mailbox.c + +include $(GFXLIB)/drivers/gdisp/framebuffer/driver.mk diff --git a/boards/base/RaspberryPi/board_framebuffer.h b/boards/base/RaspberryPi/board_framebuffer.h new file mode 100644 index 00000000..eeefeb06 --- /dev/null +++ b/boards/base/RaspberryPi/board_framebuffer.h @@ -0,0 +1,89 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + + +// Set this to your frame buffer pixel format and size. You can also override these in your makefile. +#ifndef GDISP_LLD_PIXELFORMAT + #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#endif +#ifndef GDISP_SCREEN_WIDTH + #define GDISP_SCREEN_WIDTH 800 +#endif +#ifndef GDISP_SCREEN_HEIGHT + #define GDISP_SCREEN_HEIGHT 600 +#endif + +#ifdef GDISP_DRIVER_VMT + + #if GDISP_SCREEN_WIDTH > 4096 || GDISP_SCREEN_HEIGHT > 4096 + #error "Raspberry Pi Framebuffer: Screen size is defined too large. Max is 4096x4096" + #endif + + #include "rpi_mailbox.h" + + typedef struct FrameBufferDescription { + uint32_t width; + uint32_t height; + uint32_t vWidth; + uint32_t vHeight; + uint32_t pitch; + uint32_t bitDepth; + uint32_t x; + uint32_t y; + void * pointer; + uint32_t size; + } FrameBufferDescription; + + static FrameBufferDescription FrameBufferInfo __attribute__((aligned (16))) = { 1024, 768, 1024, 768, 0, 24, 0, 0, 0, 0 }; + + static void board_init(GDisplay *g, fbInfo *fbi) { + // Initialize the Raspberry Pi frame buffer + + FrameBufferInfo.width = GDISP_SCREEN_WIDTH; + FrameBufferInfo.height = GDISP_SCREEN_HEIGHT; + FrameBufferInfo.vWidth = GDISP_SCREEN_WIDTH; + FrameBufferInfo.vHeight = GDISP_SCREEN_HEIGHT; + FrameBufferInfo.bitDepth = LLDCOLOR_BITS; + + rpi_writemailbox(1, 0x40000000 + (uint32_t) &FrameBufferInfo); + + if (rpi_readmailbox(1) != 0) + gfxHalt("Could not set display parameters") + + // Set the details of the frame buffer + g->g.Width = GDISP_SCREEN_WIDTH; + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Backlight = 100; + g->g.Contrast = 50; + fbi->linelen = g->g.Width * sizeof(LLDCOLOR_TYPE); // bytes per row + fbi->pixels = FrameBufferInfo.pointer; // pointer to the memory frame buffer + } + + #if GDISP_HARDWARE_FLUSH + static void board_flush(GDisplay *g) { + (void) g; + } + #endif + + #if GDISP_NEED_CONTROL + static void board_backlight(GDisplay *g, uint8_t percent) { + (void) g; + (void) percent; + } + + static void board_contrast(GDisplay *g, uint8_t percent) { + (void) g; + (void) percent; + } + + static void board_power(GDisplay *g, powermode_t pwr) { + (void) g; + (void) pwr; + } + #endif + +#endif /* GDISP_DRIVER_VMT */ diff --git a/boards/base/RaspberryPi/readme.txt b/boards/base/RaspberryPi/readme.txt new file mode 100644 index 00000000..d4a59bf2 --- /dev/null +++ b/boards/base/RaspberryPi/readme.txt @@ -0,0 +1,18 @@ +This directory contains the interface for the Raspberry Pi framebuffer. +This talks directly to the raspberry pi hardware (not via a linux framebuffer driver). + +This graphics interface is software driven - it is not an accelerated interface. + +This board definition should work on any operating system that will work on the Raspberry Pi + eg. Linux, FreeRTOS. + +On this board uGFX currently supports: + - GDISP via the framebuffer driver + +THe following variables may optionally be defined in your gfxconf.h or your makefile... + - GDISP_LLD_PIXELFORMAT default = GDISP_PIXELFORMAT_RGB565 + - GDISP_SCREEN_WIDTH default = 800 + - GDISP_SCREEN_HEIGHT default = 600 + +Note that this also provides a Raspberry Pi specific api defined in rpi_mailbox.h to talk +directly to the graphics co-processor from the ARM processor. diff --git a/boards/base/RaspberryPi/rpi_mailbox.c b/boards/base/RaspberryPi/rpi_mailbox.c new file mode 100644 index 00000000..798cbb1f --- /dev/null +++ b/boards/base/RaspberryPi/rpi_mailbox.c @@ -0,0 +1,47 @@ +/* + * Access system mailboxes + */ +#include "rpi_mailbox.h" + +/* Mailbox memory addresses */ +static volatile unsigned int *MAILBOX0READ = (unsigned int *) (0x2000b880); +static volatile unsigned int *MAILBOX0STATUS = (unsigned int *) (0x2000b898); +static volatile unsigned int *MAILBOX0WRITE = (unsigned int *) (0x2000b8a0); + +/* Bit 31 set in status register if the write mailbox is full */ +#define MAILBOX_FULL 0x80000000 + +/* Bit 30 set in status register if the read mailbox is empty */ +#define MAILBOX_EMPTY 0x40000000 + +unsigned int rpi_readmailbox(unsigned int channel) +{ + unsigned int val; + + if (channel > 15) + return 0xFFFFFFFF; + + /* Wait for mailbox to be full */ + while (*MAILBOX0STATUS & MAILBOX_EMPTY); + + val = *MAILBOX0READ; + + if ((val & 15) == channel) + return (val & 0xFFFFFFF0); + else + return 0xFFFFFFFF; +} + +void rpi_writemailbox(unsigned int channel, unsigned int data) +{ + if (channel > 15) + return; + + if (data & 0x000F) + return; + + /* Wait for mailbox to be not full */ + while (*MAILBOX0STATUS & MAILBOX_FULL); + + *MAILBOX0WRITE = (data | channel); +} diff --git a/boards/base/RaspberryPi/rpi_mailbox.h b/boards/base/RaspberryPi/rpi_mailbox.h new file mode 100644 index 00000000..f3c03a26 --- /dev/null +++ b/boards/base/RaspberryPi/rpi_mailbox.h @@ -0,0 +1,7 @@ +#ifndef RPI_MAILBOX_H +#define RPI_MAILBOX_H + +extern unsigned int readmailbox(unsigned int channel); +extern void writemailbox(unsigned int channel, unsigned int data); + +#endif /* RPI_MAILBOX_H */ From 6dea259ea2dd0afc4b610961e211d77460cfd0c6 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 9 Jul 2014 18:47:59 +1000 Subject: [PATCH 24/38] Example added for FreeRTOS on Raspberry Pi --- .../example-FreeRTOS/Drivers/bcm2835_intc.h | 45 +++++ .../example-FreeRTOS/Drivers/gpio.c | 134 ++++++++++++++ .../example-FreeRTOS/Drivers/gpio.h | 48 +++++ .../example-FreeRTOS/Drivers/interrupts.c | 166 ++++++++++++++++++ .../example-FreeRTOS/Drivers/interrupts.h | 25 +++ .../example-FreeRTOS/Drivers/mmio.h | 24 +++ .../example-FreeRTOS/Drivers/uart.c | 125 +++++++++++++ .../example-FreeRTOS/Drivers/uart.h | 25 +++ .../example-FreeRTOS/FreeRTOSConfig.h | 139 +++++++++++++++ .../RaspberryPi/example-FreeRTOS/Makefile | 73 ++++++++ .../base/RaspberryPi/example-FreeRTOS/main.c | 82 +++++++++ .../example-FreeRTOS/raspberrypi.ld | 70 ++++++++ .../RaspberryPi/example-FreeRTOS/startup.s | 102 +++++++++++ 13 files changed, 1058 insertions(+) create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/bcm2835_intc.h create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.c create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.h create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.c create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.h create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/mmio.h create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.c create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.h create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/FreeRTOSConfig.h create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/Makefile create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/main.c create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/raspberrypi.ld create mode 100644 boards/base/RaspberryPi/example-FreeRTOS/startup.s diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/bcm2835_intc.h b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/bcm2835_intc.h new file mode 100644 index 00000000..9f87b88e --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/bcm2835_intc.h @@ -0,0 +1,45 @@ +#ifndef _BCM2835_INTC_H_ +#define _BCM2835_INTC_H_ + +//#include "bcm2835.h" + +#define BCM2835_INTC_TOTAL_IRQ 64 + 8 + +#define BCM2835_BASE_INTC (0x2000B200) +#define BCM2835_INTC_IRQ_BASIC (BCM2835_BASE_INTC + 0x00) +#define BCM2835_IRQ_PENDING1 (BCM2835_BASE_INTC + 0x04) +#define BCM2835_IRQ_PENDING2 (BCM2835_BASE_INTC + 0x08) +#define BCM2835_IRQ_FIQ_CTRL (BCM2835_BASE_INTC + 0x0C) +#define BCM2835_IRQ_ENABLE1 (BCM2835_BASE_INTC + 0x10) +#define BCM2835_IRQ_ENABLE2 (BCM2835_BASE_INTC + 0x14) +#define BCM2835_IRQ_ENABLE_BASIC (BCM2835_BASE_INTC + 0x18) +#define BCM2835_IRQ_DISABLE1 (BCM2835_BASE_INTC + 0x1C) +#define BCM2835_IRQ_DISABLE2 (BCM2835_BASE_INTC + 0x20) +#define BCM2835_IRQ_DISABLE_BASIC (BCM2835_BASE_INTC + 0x24) + + + + +#define BCM2835_IRQ_ID_AUX 29 +#define BCM2835_IRQ_ID_SPI_SLAVE 43 +#define BCM2835_IRQ_ID_PWA0 45 +#define BCM2835_IRQ_ID_PWA1 46 +#define BCM2835_IRQ_ID_SMI 48 +#define BCM2835_IRQ_ID_GPIO_0 49 +#define BCM2835_IRQ_ID_GPIO_1 50 +#define BCM2835_IRQ_ID_GPIO_2 51 +#define BCM2835_IRQ_ID_GPIO_3 52 +#define BCM2835_IRQ_ID_I2C 53 +#define BCM2835_IRQ_ID_SPI 54 +#define BCM2835_IRQ_ID_PCM 55 +#define BCM2835_IRQ_ID_UART 57 + + +#define BCM2835_IRQ_ID_TIMER_0 64 +#define BCM2835_IRQ_ID_MAILBOX_0 65 +#define BCM2835_IRQ_ID_DOORBELL_0 66 +#define BCM2835_IRQ_ID_DOORBELL_1 67 +#define BCM2835_IRQ_ID_GPU0_HALTED 68 + + +#endif diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.c b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.c new file mode 100644 index 00000000..485de897 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.c @@ -0,0 +1,134 @@ +/** + * Quick and very Dirty GPIO API. + * + **/ + +#include "gpio.h" + +typedef struct { + unsigned long GPFSEL[6]; ///< Function selection registers. + unsigned long Reserved_1; + unsigned long GPSET[2]; + unsigned long Reserved_2; + unsigned long GPCLR[2]; + unsigned long Reserved_3; + unsigned long GPLEV[2]; + unsigned long Reserved_4; + unsigned long GPEDS[2]; + unsigned long Reserved_5; + unsigned long GPREN[2]; + unsigned long Reserved_6; + unsigned long GPFEN[2]; + unsigned long Reserved_7; + unsigned long GPHEN[2]; + unsigned long Reserved_8; + unsigned long GPLEN[2]; + unsigned long Reserved_9; + unsigned long GPAREN[2]; + unsigned long Reserved_A; + unsigned long GPAFEN[2]; + unsigned long Reserved_B; + unsigned long GPPUD[1]; + unsigned long GPPUDCLK[2]; + //Ignoring the reserved and test bytes +} BCM2835_GPIO_REGS; + +volatile BCM2835_GPIO_REGS * const pRegs = (BCM2835_GPIO_REGS *) (0x20200000); + + +void SetGpioFunction(unsigned int pinNum, unsigned int funcNum) { + + int offset = pinNum / 10; + + unsigned long val = pRegs->GPFSEL[offset]; // Read in the original register value. + + int item = pinNum % 10; + val &= ~(0x7 << (item * 3)); + val |= ((funcNum & 0x7) << (item * 3)); + pRegs->GPFSEL[offset] = val; +} + +void SetGpioDirection(unsigned int pinNum, enum GPIO_DIR dir) { + SetGpioFunction(pinNum,dir); +} + +void SetGpio(unsigned int pinNum, unsigned int pinVal) { + unsigned long offset=pinNum/32; + unsigned long mask=(1<<(pinNum%32)); + + if(pinVal) { + pRegs->GPSET[offset]|=mask; + } else { + pRegs->GPCLR[offset]|=mask; + } +} + +int ReadGpio(unsigned int pinNum) { + return ((pRegs->GPLEV[pinNum/32])>>(pinNum%32))&1; +} + +void EnableGpioDetect(unsigned int pinNum, enum DETECT_TYPE type) +{ + unsigned long mask=(1<GPREN[offset]|=mask; + break; + case DETECT_FALLING: + pRegs->GPFEN[offset]|=mask; + break; + case DETECT_HIGH: + pRegs->GPHEN[offset]|=mask; + break; + case DETECT_LOW: + pRegs->GPLEN[offset]|=mask; + break; + case DETECT_RISING_ASYNC: + pRegs->GPAREN[offset]|=mask; + break; + case DETECT_FALLING_ASYNC: + pRegs->GPAFEN[offset]|=mask; + break; + case DETECT_NONE: + break; + } +} + +void DisableGpioDetect(unsigned int pinNum, enum DETECT_TYPE type) +{ + unsigned long mask=~(1<<(pinNum%32)); + unsigned long offset=pinNum/32; + + switch(type) { + case DETECT_RISING: + pRegs->GPREN[offset]&=mask; + break; + case DETECT_FALLING: + pRegs->GPFEN[offset]&=mask; + break; + case DETECT_HIGH: + pRegs->GPHEN[offset]&=mask; + break; + case DETECT_LOW: + pRegs->GPLEN[offset]&=mask; + break; + case DETECT_RISING_ASYNC: + pRegs->GPAREN[offset]&=mask; + break; + case DETECT_FALLING_ASYNC: + pRegs->GPAFEN[offset]&=mask; + break; + case DETECT_NONE: + break; + } +} + +void ClearGpioInterrupt(unsigned int pinNum) +{ + unsigned long mask=(1<<(pinNum%32)); + unsigned long offset=pinNum/32; + + pRegs->GPEDS[offset]=mask; +} diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.h b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.h new file mode 100644 index 00000000..fa459707 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.h @@ -0,0 +1,48 @@ +#ifndef _GPIO_H_ +#define _GPIO_H_ + +/* GPIO event detect types */ +enum DETECT_TYPE { + DETECT_NONE, + DETECT_RISING, + DETECT_FALLING, + DETECT_HIGH, + DETECT_LOW, + DETECT_RISING_ASYNC, + DETECT_FALLING_ASYNC +}; + +/* GPIO pull up or down states */ +enum PULL_STATE { + PULL_DISABLE, + PULL_UP, + PULL_DOWN, + PULL_RESERVED +}; + +/* Pin data direction */ +enum GPIO_DIR { + GPIO_IN, + GPIO_OUT +}; + +/* GPIO pin setup */ +void SetGpioFunction (unsigned int pinNum, unsigned int funcNum); +/* A simple wrapper around SetGpioFunction */ +void SetGpioDirection (unsigned int pinNum, enum GPIO_DIR dir); + +/* Set GPIO output level */ +void SetGpio (unsigned int pinNum, unsigned int pinVal); + +/* Read GPIO pin level */ +int ReadGpio (unsigned int pinNum); + +/* GPIO pull up/down resistor control function (NOT YET IMPLEMENTED) */ +int PudGpio (unsigned int pinNum, enum PULL_STATE state); + +/* Interrupt related functions */ +void EnableGpioDetect (unsigned int pinNum, enum DETECT_TYPE type); +void DisableGpioDetect (unsigned int pinNum, enum DETECT_TYPE type); +void ClearGpioInterrupt (unsigned int pinNum); + +#endif diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.c b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.c new file mode 100644 index 00000000..9908b7c4 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.c @@ -0,0 +1,166 @@ +/** + * Integrated Interrupt Controller for RaspberryPi. + * @author James Walmsley + **/ + +#include "interrupts.h" +#include "bcm2835_intc.h" + +static INTERRUPT_VECTOR g_VectorTable[BCM2835_INTC_TOTAL_IRQ]; + + +typedef struct { + unsigned long IRQBasic; // Pending 0 + unsigned long Pending1; + unsigned long Pending2; + unsigned long FIQCtrl; + unsigned long Enable1; + unsigned long Enable2; + unsigned long EnableBasic; + unsigned long Disable1; + unsigned long Disable2; + unsigned long DisableBasic; +} BCM2835_INTC_REGS; + +static volatile BCM2835_INTC_REGS * const pRegs = (BCM2835_INTC_REGS *) (BCM2835_BASE_INTC); + +/** + * Enables all IRQ's in the CPU's CPSR register. + **/ +static void irqEnable() { + __asm volatile("mrs r0,cpsr"); // Read in the cpsr register. + __asm volatile("bic r0,r0,#0x80"); // Clear bit 8, (0x80) -- Causes IRQs to be enabled. + __asm volatile("msr cpsr_c, r0"); // Write it back to the CPSR register +} + +static void irqDisable() { + __asm volatile("mrs r0,cpsr"); // Read in the cpsr register. + __asm volatile("orr r0,r0,#0x80"); // Set bit 8, (0x80) -- Causes IRQs to be disabled. + __asm volatile("msr cpsr_c, r0"); // Write it back to the CPSR register. + +} + +#define clz(a) \ + ({ unsigned long __value, __arg = (a); \ + asm ("clz\t%0, %1": "=r" (__value): "r" (__arg)); \ + __value; }) + +/** + * This is the global IRQ handler on this platform! + * It is based on the assembler code found in the Broadcom datasheet. + * + **/ +void irqHandler() { + register unsigned long ulMaskedStatus; + register unsigned long irqNumber; + + ulMaskedStatus = pRegs->IRQBasic; + + /* Bits 7 through 0 in IRQBasic represent interrupts 64-71 */ + if (ulMaskedStatus & 0xFF) { + irqNumber=64 + 31; + } + + /* Bit 8 in IRQBasic indicates interrupts in Pending1 (interrupts 31-0) */ + else if(ulMaskedStatus & 0x100) { + ulMaskedStatus = pRegs->Pending1; + irqNumber = 0 + 31; + } + + /* Bit 9 in IRQBasic indicates interrupts in Pending2 (interrupts 63-32) */ + else if(ulMaskedStatus & 0x200) { + ulMaskedStatus = pRegs->Pending2; + irqNumber = 32 + 31; + } + + else { + // No interrupt avaialbe, so just return. + return; + } + + /* Keep only least significant bit, in case multiple interrupts have occured */ + ulMaskedStatus&=-ulMaskedStatus; + /* Some magic to determine number of interrupt to serve */ + irqNumber=irqNumber-clz(ulMaskedStatus); + /* Call interrupt handler */ + g_VectorTable[irqNumber].pfnHandler(irqNumber, g_VectorTable[irqNumber].pParam); +} + + +static void stubHandler(int nIRQ, void *pParam) { + /** + * Actually if we get here, we should probably disable the IRQ, + * otherwise we could lock up this system, as there is nothing to + * ackknowledge the interrupt. + **/ +} + +int InitInterruptController() { + int i; + for(i = 0; i < BCM2835_INTC_TOTAL_IRQ; i++) { + g_VectorTable[i].pfnHandler = stubHandler; + g_VectorTable[i].pParam = (void *) 0; + } + return 0; +} + + + +int RegisterInterrupt(int nIRQ, FN_INTERRUPT_HANDLER pfnHandler, void *pParam) { + if(nIRQ<0 || nIRQ>71) + return -1; + + irqDisable(); + { + g_VectorTable[nIRQ].pfnHandler = pfnHandler; + g_VectorTable[nIRQ].pParam = pParam; + } + irqEnable(); + return 0; +} + +int EnableInterrupt(int nIRQ) { + /* Datasheet says "All other bits are unaffected", and I'm counting on that. */ + unsigned int mask=1<<(nIRQ%32); + + if(nIRQ >=0 && nIRQ <=31) { + pRegs->Enable1 = mask; + } else + if(nIRQ >=32 && nIRQ <=63){ + pRegs->Enable2 = mask; + } else + if(nIRQ >= 64 && nIRQ <= 71) { // Basic IRQ enables + pRegs->EnableBasic = mask; + } else + return -1; + + return 0; +} + +int DisableInterrupt(int nIRQ) { + /* Datasheet says "All other bits are unaffected", and I'm counting on that. */ + unsigned int mask=1<<(nIRQ%32); + + if(nIRQ >=0 && nIRQ <=31) { + pRegs->Disable1 = mask; + } else + if(nIRQ >=32 && nIRQ <=63){ + pRegs->Disable2 = mask; + } else + if(nIRQ >= 64 && nIRQ <= 71) { + pRegs->DisableBasic = mask; + } else + return -1; + + return 0; +} + +int EnableInterrupts() { + irqEnable(); + return 0; +} + +int DisableInterrupts() { + irqDisable(); + return 0; +} diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.h b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.h new file mode 100644 index 00000000..d09353a4 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.h @@ -0,0 +1,25 @@ +/** + * Tiny Interrupt Manager + * + * @author James Walmsley + * This code is licensed under the GNU GPLv3 license. + **/ + +#ifndef _INTERRUPTS_H_ +#define _INTERRUPTS_H_ + +typedef void (*FN_INTERRUPT_HANDLER)(int nIRQ, void *pParam); + +typedef struct { + FN_INTERRUPT_HANDLER pfnHandler; ///< Function that handles this IRQn + void *pParam; ///< A special parameter that the use can pass to the IRQ. +} INTERRUPT_VECTOR; + +int InitInterruptController (); +int RegisterInterrupt (int nIRQ, FN_INTERRUPT_HANDLER pfnHandler, void *pParam); +int EnableInterrupt (int nIRQ); +int DisableInterrupt (int nIRQ); +int EnableInterrupts (); +int DisableInterrupts (); + +#endif diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/mmio.h b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/mmio.h new file mode 100644 index 00000000..89bea700 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/mmio.h @@ -0,0 +1,24 @@ +/* mmio.h - access to MMIO registers */ + +#ifndef MMIO_H +#define MMIO_H + +#include + +// write to MMIO register +static inline void mmio_write(uint32_t reg, uint32_t data) { + uint32_t *ptr = (uint32_t*)reg; + asm volatile("str %[data], [%[reg]]" + : : [reg]"r"(ptr), [data]"r"(data)); +} + +// read from MMIO register +static inline uint32_t mmio_read(uint32_t reg) { + uint32_t *ptr = (uint32_t*)reg; + uint32_t data; + asm volatile("ldr %[data], [%[reg]]" + : [data]"=r"(data) : [reg]"r"(ptr)); + return data; +} + +#endif // #ifndef MMIO_H diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.c b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.c new file mode 100644 index 00000000..92f837e7 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.c @@ -0,0 +1,125 @@ +/* uart.c - UART initialization & communication */ +/* Reference material: + * http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf + * Chapter 13: UART + */ + +#include +#include +#include + +enum { + // The GPIO registers base address. + GPIO_BASE = 0x20200000, + + // The offsets for reach register. + + // Controls actuation of pull up/down to ALL GPIO pins. + GPPUD = (GPIO_BASE + 0x94), + + // Controls actuation of pull up/down for specific GPIO pin. + GPPUDCLK0 = (GPIO_BASE + 0x98), + + // The base address for UART. + UART0_BASE = 0x20201000, + + // The offsets for reach register for the UART. + UART0_DR = (UART0_BASE + 0x00), + UART0_RSRECR = (UART0_BASE + 0x04), + UART0_FR = (UART0_BASE + 0x18), + UART0_ILPR = (UART0_BASE + 0x20), + UART0_IBRD = (UART0_BASE + 0x24), + UART0_FBRD = (UART0_BASE + 0x28), + UART0_LCRH = (UART0_BASE + 0x2C), + UART0_CR = (UART0_BASE + 0x30), + UART0_IFLS = (UART0_BASE + 0x34), + UART0_IMSC = (UART0_BASE + 0x38), + UART0_RIS = (UART0_BASE + 0x3C), + UART0_MIS = (UART0_BASE + 0x40), + UART0_ICR = (UART0_BASE + 0x44), + UART0_DMACR = (UART0_BASE + 0x48), + UART0_ITCR = (UART0_BASE + 0x80), + UART0_ITIP = (UART0_BASE + 0x84), + UART0_ITOP = (UART0_BASE + 0x88), + UART0_TDR = (UART0_BASE + 0x8C), +}; + +/* + * delay function + * int32_t delay: number of cycles to delay + * + * This just loops times in a way that the compiler + * wont optimize away. + */ +static void delay(int32_t count) { + asm volatile("__delay_%=: subs %[count], %[count], #1; bne __delay_%=\n" + : : [count]"r"(count) : "cc"); +} + +/* + * Initialize UART0. + */ +void uart_init() { + // Disable UART0. + mmio_write(UART0_CR, 0x00000000); + // Setup the GPIO pin 14 && 15. + + // Disable pull up/down for all GPIO pins & delay for 150 cycles. + mmio_write(GPPUD, 0x00000000); + delay(150); + + // Disable pull up/down for pin 14,15 & delay for 150 cycles. + mmio_write(GPPUDCLK0, (1 << 14) | (1 << 15)); + delay(150); + + // Write 0 to GPPUDCLK0 to make it take effect. + mmio_write(GPPUDCLK0, 0x00000000); + + // Clear pending interrupts. + mmio_write(UART0_ICR, 0x7FF); + + // Set integer & fractional part of baud rate. + // Divider = UART_CLOCK/(16 * Baud) + // Fraction part register = (Fractional part * 64) + 0.5 + // UART_CLOCK = 3000000; Baud = 115200. + + // Divider = 3000000/(16 * 115200) = 1.627 = ~1. + // Fractional part register = (.627 * 64) + 0.5 = 40.6 = ~40. + mmio_write(UART0_IBRD, 1); + mmio_write(UART0_FBRD, 40); + + // Enable FIFO & 8 bit data transmissio (1 stop bit, no parity). + mmio_write(UART0_LCRH, (1 << 4) | (1 << 5) | (1 << 6)); + + // Mask all interrupts. + mmio_write(UART0_IMSC, (1 << 1) | (1 << 4) | (1 << 5) | + (1 << 6) | (1 << 7) | (1 << 8) | + (1 << 9) | (1 << 10)); + + // Enable UART0, receive & transfer part of UART. + mmio_write(UART0_CR, (1 << 0) | (1 << 8) | (1 << 9)); +} + +/* + * Transmit a byte via UART0. + * uint8_t Byte: byte to send. + */ +void uart_putc(uint8_t byte) { + // wait for UART to become ready to transmit + while (1) { + if (!(mmio_read(UART0_FR) & (1 << 5))) { + break; + } + } + mmio_write(UART0_DR, byte); +} + +/* + * print a string to the UART one character at a time + * const char *str: 0-terminated string + */ +void uart_puts(const char *str) { + while (*str) { + uart_putc(*str++); + } +} diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.h b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.h new file mode 100644 index 00000000..fe7f64aa --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.h @@ -0,0 +1,25 @@ +/* uart.h - UART initialization & communication */ + +#ifndef UART_H +#define UART_H + +#include + +/* + * Initialize UART0. + */ +void uart_init(); + +/* + * Transmit a byte via UART0. + * uint8_t Byte: byte to send. + */ +void uart_putc(uint8_t byte); + +/* + * print a string to the UART one character at a time + * const char *str: 0-terminated string + */ +void uart_puts(const char *str); + +#endif // #ifndef UART_H diff --git a/boards/base/RaspberryPi/example-FreeRTOS/FreeRTOSConfig.h b/boards/base/RaspberryPi/example-FreeRTOS/FreeRTOSConfig.h new file mode 100644 index 00000000..c2477416 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/FreeRTOSConfig.h @@ -0,0 +1,139 @@ +/* + FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that has become a de facto standard. * + * * + * Help yourself get started quickly and support the FreeRTOS * + * project by purchasing a FreeRTOS tutorial book, reference * + * manual, or both from: http://www.FreeRTOS.org/Documentation * + * * + * Thank you! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + >>! NOTE: The modification to the GPL is included to allow you to distribute + >>! a combined work that includes FreeRTOS without being obliged to provide + >>! the source code for proprietary components outside of the FreeRTOS + >>! kernel. + + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. Full license text is available from the following + link: http://www.freertos.org/a00114.html + + 1 tab == 4 spaces! + + *************************************************************************** + * * + * Having a problem? Start by reading the FAQ "My application does * + * not run, what could be wrong?" * + * * + * http://www.FreeRTOS.org/FAQHelp.html * + * * + *************************************************************************** + + http://www.FreeRTOS.org - Documentation, books, training, latest versions, + license and Real Time Engineers Ltd. contact details. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * + * See http://www.freertos.org/a00110.html. + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configCPU_CLOCK_HZ ( ( unsigned long ) 24000000 ) +#define configPERIPHERAL_CLOCK_HZ ( 40000000UL ) +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) +#define configISR_STACK_SIZE ( 250 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 4096 ) ) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configCHECK_FOR_STACK_OVERFLOW 3 +#define configQUEUE_REGISTRY_SIZE 0 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_MALLOC_FAILED_HOOK 0 +#define configUSE_APPLICATION_TASK_TAG 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configGENERATE_RUN_TIME_STATS 0 + + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_eTaskGetState 1 + + +/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 +(lowest) to 0 (1?) (highest). */ +#define configKERNEL_INTERRUPT_PRIORITY 255 +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ + + +/* This is the value being used as per the ST library which permits 16 +priority values, 0 to 15. This must correspond to the +configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest +NVIC value of 255. */ +#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 + +#endif /* FREERTOS_CONFIG_H */ + diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Makefile b/boards/base/RaspberryPi/example-FreeRTOS/Makefile new file mode 100644 index 00000000..c1751204 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/Makefile @@ -0,0 +1,73 @@ +# build environment +PREFIX ?= /your compiler path/gcc-arm-none-eabi-4_8-2014q1 +ARCH ?= $(PREFIX)/bin/arm-none-eabi + +CC = ${ARCH}-gcc +CPP = ${ARCH}-g++ +AS = ${ARCH}-as +LD = ${ARCH}-ld +AR = ${ARCH}-ar +OBJCOPY = ${ARCH}-objcopy + +PLATFORM = raspi +LINKER_SCRIPT = raspberrypi.ld + +CFLAGS = -march=armv6z -g -Wall -Wextra +ASFLAGS = -g + +CFLAGS_FOR_TARGET = #-mcpu=arm1176jzf-s +ASFLAGS_FOR_TARGET = #-mcpu=arm1176jzf-s +LDFLAGS = #--error-unresolved-symbols + +GFXLIB := ../uGFX +include $(GFXLIB)/gfx.mk +include $(GFXLIB)/drivers/gdisp/framebuffer/driver.mk + +OSLIB := ../FreeRTOS +MODULES := $(OSLIB)/Source/portable/GCC/RaspberryPi +MODULES += $(OSLIB)/Source/portable/MemMang +MODULES += $(OSLIB)/Source +MODULES += Drivers + +SRC_DIR := $(MODULES) +INC_DIR := $(addsuffix /include,$(SRC_DIR)) +BUILD_DIR := $(addsuffix /build,$(SRC_DIR)) + +INCLUDEDIRS := $(OSLIB)/Source/portable/GCC/RaspberryPi +INCLUDEDIRS += $(OSLIB)/Source/include +INCLUDEDIRS += Drivers +INCLUDEDIRS += $(GFXINC) + +INCLUDES := $(addprefix -I,$(INCLUDEDIRS)) + +ASRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s)) +AOBJ := $(ASRC:.s=.o) +CSRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) +CSRC += $(GFXSRC) +COBJ := $(CSRC:.c=.o) + +vpath %.c $(SRC_DIR) +vpath %.cpp $(SRC_DIR) +vpath %.s $(SRC_DIR) + +%.o: %.c + $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c -o $*.o $< + +%.o: %.s + $(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $< + +OBJ = $(AOBJ) $(COBJ) + +bin/kernel.img: bin/kernel.elf + ${OBJCOPY} -O binary $< $@ + +bin/kernel.elf: LDFLAGS += -L "$(PREFIX)/lib/gcc/arm-none-eabi/4.8.3" -lgcc +bin/kernel.elf: LDFLAGS += -L "$(PREFIX)/arm-none-eabi/lib" -lc +bin/kernel.elf: $(OBJ) + ${LD} $(OBJ) -Map bin/kernel.map -o $@ -T $(LINKER_SCRIPT) ${LDFLAGS} + +clean: + rm -f bin/*.elf bin/*.img bin/*.map $(OBJ) + + + diff --git a/boards/base/RaspberryPi/example-FreeRTOS/main.c b/boards/base/RaspberryPi/example-FreeRTOS/main.c new file mode 100644 index 00000000..3a64a7bb --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/main.c @@ -0,0 +1,82 @@ +#include +#include + +#include "Drivers/interrupts.h" + +#include "gfx.h" + +static void displayTask(void *pvParameters) { + coord_t width, height; + // Get the screen size + width = gdispGetWidth(); + height = gdispGetHeight(); + + // Code Here + gdispDrawBox(10, 10, width/2, height/2, Yellow); + gdispFillArea(width/2, height/2, width/2-10, height/2-10, Blue); + gdispDrawLine(5, 30, width-50, height-40, Red); + + while(1) + { + vTaskDelay(1000); + } + + return; +} + +/** + * This is the systems main entry, some call it a boot thread. + * + * -- Absolutely nothing wrong with this being called main(), just it doesn't have + * -- the same prototype as you'd see in a linux program. + **/ +int main(void) { + + DisableInterrupts(); + InitInterruptController(); + + // Initialize and clear the display + gfxInit(); + + xTaskCreate(displayTask, + (portCHAR *)"Display Task", + 128, + NULL, + 0, + NULL); + + vTaskStartScheduler(); + + /* + * We should never get here, but just in case something goes wrong, + * we'll place the CPU into a safe loop. + */ + while(1) { + ; + } + + return 0; +} + +void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) +{ + ( void ) pcTaskName; + ( void ) pxTask; + + /* Run time task stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a task stack overflow is detected. Note the system/interrupt + stack is not checked. */ + taskDISABLE_INTERRUPTS(); + for( ;; ); +} +/*-----------------------------------------------------------*/ + +void vApplicationTickHook( void ) +{ + /* This function will be called by each tick interrupt if + configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be + added here, but the tick hook is called from an interrupt context, so + code must not attempt to block, and only the interrupt safe FreeRTOS API + functions can be used (those that end in FromISR()). */ +} diff --git a/boards/base/RaspberryPi/example-FreeRTOS/raspberrypi.ld b/boards/base/RaspberryPi/example-FreeRTOS/raspberrypi.ld new file mode 100644 index 00000000..ece588b5 --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/raspberrypi.ld @@ -0,0 +1,70 @@ +/** + * BlueThunder Linker Script for the raspberry Pi! + * + * + * + **/ +MEMORY +{ + RESERVED (r) : ORIGIN = 0x00000000, LENGTH = 32K + INIT_RAM (rwx) : ORIGIN = 0x00008000, LENGTH = 32K + RAM (rwx) : ORIGIN = 0x00010000, LENGTH = 128M +} + +ENTRY(_start) + +SECTIONS { + /* + * Our init section allows us to place the bootstrap code at address 0x8000 + * + * This is where the Graphics processor forces the ARM to start execution. + * However the interrupt vector code remains at 0x0000, and so we must copy the correct + * branch instructions to 0x0000 - 0x001C in order to get the processor to handle interrupts. + * + */ + .init : { + KEEP(*(.init)) + } > INIT_RAM = 0 + + .module_entries : { + __module_entries_start = .; + KEEP(*(.module_entries)) + KEEP(*(.module_entries.*)) + __module_entries_end = .; + __module_entries_size = SIZEOF(.module_entries); + } > INIT_RAM + + + /** + * This is the main code section, it is essentially of unlimited size. (128Mb). + * + **/ + .text : { + *(.text) + } > RAM + + /* + * Next we put the data. + */ + .data : { + *(.data) + } > RAM + + .bss : + { + __bss_start = .; + *(.bss) + *(.bss.*) + __bss_end = .; + } > RAM + + /** + * Place HEAP here??? + **/ + + /** + * Stack starts at the top of the RAM, and moves down! + **/ + _estack = ORIGIN(RAM) + LENGTH(RAM); +} + diff --git a/boards/base/RaspberryPi/example-FreeRTOS/startup.s b/boards/base/RaspberryPi/example-FreeRTOS/startup.s new file mode 100644 index 00000000..286f396c --- /dev/null +++ b/boards/base/RaspberryPi/example-FreeRTOS/startup.s @@ -0,0 +1,102 @@ +.extern system_init +.extern __bss_start +.extern __bss_end +.extern vFreeRTOS_ISR +.extern vPortYieldProcessor +.extern DisableInterrupts +.extern main + .section .init + .globl _start +;; +_start: + ;@ All the following instruction should be read as: + ;@ Load the address at symbol into the program counter. + + ldr pc,reset_handler ;@ Processor Reset handler -- we will have to force this on the raspi! + ;@ Because this is the first instruction executed, of cause it causes an immediate branch into reset! + + ldr pc,undefined_handler ;@ Undefined instruction handler -- processors that don't have thumb can emulate thumb! + ldr pc,swi_handler ;@ Software interrupt / TRAP (SVC) -- system SVC handler for switching to kernel mode. + ldr pc,prefetch_handler ;@ Prefetch/abort handler. + ldr pc,data_handler ;@ Data abort handler/ + ldr pc,unused_handler ;@ -- Historical from 26-bit addressing ARMs -- was invalid address handler. + ldr pc,irq_handler ;@ IRQ handler + ldr pc,fiq_handler ;@ Fast interrupt handler. + + ;@ Here we create an exception address table! This means that reset/hang/irq can be absolute addresses +reset_handler: .word reset +undefined_handler: .word undefined_instruction +swi_handler: .word vPortYieldProcessor +prefetch_handler: .word prefetch_abort +data_handler: .word data_abort +unused_handler: .word unused +irq_handler: .word vFreeRTOS_ISR +fiq_handler: .word fiq + +reset: + ;@ In the reset handler, we need to copy our interrupt vector table to 0x0000, its currently at 0x8000 + + mov r0,#0x8000 ;@ Store the source pointer + mov r1,#0x0000 ;@ Store the destination pointer. + + ;@ Here we copy the branching instructions + ldmia r0!,{r2,r3,r4,r5,r6,r7,r8,r9} ;@ Load multiple values from indexed address. ; Auto-increment R0 + stmia r1!,{r2,r3,r4,r5,r6,r7,r8,r9} ;@ Store multiple values from the indexed address. ; Auto-increment R1 + + ;@ So the branches get the correct address we also need to copy our vector table! + ldmia r0!,{r2,r3,r4,r5,r6,r7,r8,r9} ;@ Load from 4*n of regs (8) as R0 is now incremented. + stmia r1!,{r2,r3,r4,r5,r6,r7,r8,r9} ;@ Store this extra set of data. + + + ;@ Set up the various STACK pointers for different CPU modes + ;@ (PSR_IRQ_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS) + mov r0,#0xD2 + msr cpsr_c,r0 + mov sp,#0x8000 + + ;@ (PSR_FIQ_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS) + mov r0,#0xD1 + msr cpsr_c,r0 + mov sp,#0x4000 + + ;@ (PSR_SVC_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS) + mov r0,#0xD3 + msr cpsr_c,r0 + mov sp,#0x8000000 + + ldr r0, =__bss_start + ldr r1, =__bss_end + + mov r2, #0 + +zero_loop: + cmp r0,r1 + it lt + strlt r2,[r0], #4 + blt zero_loop + + bl DisableInterrupts + + + ;@ mov sp,#0x1000000 + b main ;@ We're ready?? Lets start main execution! + .section .text + +undefined_instruction: + b undefined_instruction + +prefetch_abort: + b prefetch_abort + +data_abort: + b data_abort + +unused: + b unused + +fiq: + b fiq + +hang: + b hang + From 0afcec1ddb9990b857ae06eadb8fbdbad86c9ca4 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jul 2014 21:25:02 +0300 Subject: [PATCH 25/38] finish commit --- drivers/gdisp/PCF8812/PCF8812.h | 2 +- drivers/gdisp/PCF8812/gdisp_lld.mk | 2 -- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 28 +++++++++++------------ 3 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 drivers/gdisp/PCF8812/gdisp_lld.mk diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h index 95e7c217..3064f9b1 100644 --- a/drivers/gdisp/PCF8812/PCF8812.h +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -13,7 +13,7 @@ #define PCF8812_V 0x02 #define PCF8812_PD 0x04 -#define PCF8812_DISPLAY 0x08 +#define PCF8812_SET_DISPLAY 0x08 #define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 #define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 #define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 diff --git a/drivers/gdisp/PCF8812/gdisp_lld.mk b/drivers/gdisp/PCF8812/gdisp_lld.mk deleted file mode 100644 index f2394eaf..00000000 --- a/drivers/gdisp/PCF8812/gdisp_lld.mk +++ /dev/null @@ -1,2 +0,0 @@ -GFXINC += $(GFXLIB)/drivers/gdisp/PCF8812 -GFXSRC += $(GFXLIB)/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 2fcff54b..5377b7cd 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -72,15 +72,14 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_index(g, PCF8812_SET_FUNC | PCF8812_H); - write_index(g, PCF8812_SET_BIAS | PCF8812_BIAS_MODE_7); - write_index(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_2); - write_index(g, PCF8812_SET_VMULT | PCF8812_VMULT_MODE_0); - write_index(g, PCF8812_SET_VOP | 0xFF); - write_index(g, PCF8812_SET_FUNC); - write_index(g, PCF8812_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); - write_index(g, PCF8812_SET_X); // X = 0 - write_index(g, PCF8812_SET_Y); // Y = 0 + write_cmd(g, PCF8812_SET_FUNC | PCF8812_H); + write_cmd(g, PCF8812_SET_TEMP | PCF8812_TEMP_MODE_2); + write_cmd(g, PCF8812_SET_BIAS | PCF8812_BIAS_MODE_4); + write_cmd(g, PCF8812_SET_VOP | (0x40)); + write_cmd(g, PCF8812_SET_FUNC); + write_cmd(g, PCF8812_SET_DISPLAY | PCF8812_DISPLAY_MODE_NORMAL); + write_cmd(g, PCF8812_SET_X); // X = 0 + write_cmd(g, PCF8812_SET_Y); // Y = 0 coord_t i; @@ -118,8 +117,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); - write_index(g, PCF8812_SET_X | 0); // X = 0 - write_index(g, PCF8812_SET_Y | 0); // Y = 0 + write_cmd(g, PCF8812_SET_X | 0); // X = 0 + write_cmd(g, PCF8812_SET_Y | 0); // Y = 0 coord_t i; @@ -144,7 +143,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { break; case GDISP_ROTATE_90: x = g->p.y; - y = (g->g.Width - g->p.x - 1); + y = g->g.Width - g->p.x - 1; break; case GDISP_ROTATE_180: x = g->g.Width - g->p.x - 1; @@ -180,10 +179,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { case powerOff: case powerSleep: case powerDeepSleep: - write_index(g, PCF8812_SET_FUNC | PCF8812_PD); + write_cmd(g, PCF8812_SET_FUNC | PCF8812_PD); break; case powerOn: - write_index(g, PCF8812_SET_FUNC); + write_cmd(g, PCF8812_SET_FUNC); break; default: return; @@ -229,7 +228,6 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { case GDISP_CONTROL_CONTRAST: if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; - // ToDo g->g.Contrast = (unsigned)g->p.ptr; return; } From a3de59d7ad7a62ae80331e0fbf0c72398a18d2ee Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jul 2014 22:01:59 +0300 Subject: [PATCH 26/38] first commit --- drivers/gdisp/PCD8544/PCD8544.h | 45 ++++ .../gdisp/PCD8544/board_PCD8544_template.h | 43 ++++ drivers/gdisp/PCD8544/driver.mk | 2 + drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c | 233 ++++++++++++++++++ drivers/gdisp/PCD8544/gdisp_lld_config.h | 28 +++ 5 files changed, 351 insertions(+) create mode 100644 drivers/gdisp/PCD8544/PCD8544.h create mode 100644 drivers/gdisp/PCD8544/board_PCD8544_template.h create mode 100644 drivers/gdisp/PCD8544/driver.mk create mode 100644 drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c create mode 100644 drivers/gdisp/PCD8544/gdisp_lld_config.h diff --git a/drivers/gdisp/PCD8544/PCD8544.h b/drivers/gdisp/PCD8544/PCD8544.h new file mode 100644 index 00000000..1a269ab4 --- /dev/null +++ b/drivers/gdisp/PCD8544/PCD8544.h @@ -0,0 +1,45 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _PCD8544_H +#define _PCD8544_H + +#define PCD8544_SET_FUNC 0x20 // Function set +#define PCD8544_H 0x01 +#define PCD8544_V 0x02 +#define PCD8544_PD 0x04 + +#define PCD8544_SET_DISPLAY 0x08 +#define PCD8544_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCD8544_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCD8544_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCD8544_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 + +#define PCD8544_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCD8544_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 + +// ========================================= + +#define PCD8544_SET_TEMP 0x04 // set temperature coefficient (TCx) +#define PCD8544_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCD8544_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCD8544_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCD8544_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 + +#define PCD8544_SET_BIAS 0x10 // set bias system (BSx) +#define PCD8544_BIAS_MODE_7 0x00 // 1 to 100 +#define PCD8544_BIAS_MODE_6 0x01 // 1 to 80 +#define PCD8544_BIAS_MODE_5 0x02 // 1 to 65 +#define PCD8544_BIAS_MODE_4 0x03 // 1 to 48 +#define PCD8544_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCD8544_BIAS_MODE_2 0x05 // 1 to 24 +#define PCD8544_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCD8544_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 + +#define PCD8544_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 + +#endif /* _PCD8544_H */ diff --git a/drivers/gdisp/PCD8544/board_PCD8544_template.h b/drivers/gdisp/PCD8544/board_PCD8544_template.h new file mode 100644 index 00000000..08ec130d --- /dev/null +++ b/drivers/gdisp/PCD8544/board_PCD8544_template.h @@ -0,0 +1,43 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +static inline void init_board(GDisplay *g) { + (void) g; +} + +static inline void post_init_board(GDisplay *g) { + (void) g; +} + +static inline void setpin_reset(GDisplay *g, bool_t state) { + (void) g; + (void) state; +} + +static inline void acquire_bus(GDisplay *g) { + (void) g; +} + +static inline void release_bus(GDisplay *g) { + (void) g; +} + +static inline void write_cmd(GDisplay *g, uint8_t cmd) { + (void) g; + (void) cmd; +} + +static inline void write_data(GDisplay *g, uint8_t* data, uint16_t length) { + (void) g; + (void) data; + (void) length; +} + +#endif /* _GDISP_LLD_BOARD_H */ diff --git a/drivers/gdisp/PCD8544/driver.mk b/drivers/gdisp/PCD8544/driver.mk new file mode 100644 index 00000000..262550d3 --- /dev/null +++ b/drivers/gdisp/PCD8544/driver.mk @@ -0,0 +1,2 @@ +GFXINC += $(GFXLIB)/drivers/gdisp/PCD8544 +GFXSRC += $(GFXLIB)/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c diff --git a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c new file mode 100644 index 00000000..8ebd619a --- /dev/null +++ b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c @@ -0,0 +1,233 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#include "gfx.h" + +#if GFX_USE_GDISP + +#define GDISP_DRIVER_VMT GDISPVMT_PCD8544 +#include "drivers/gdisp/PCD8544/gdisp_lld_config.h" +#include "src/gdisp/driver.h" +#include "board_PCD8544.h" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#define GDISP_SCREEN_HEIGHT 48 +#define GDISP_SCREEN_WIDTH 84 + +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 + +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) + +#include "drivers/gdisp/PCD8544/PCD8544.h" + +/*===========================================================================*/ +/* Driver local routines . */ +/*===========================================================================*/ + +// Some common routines and macros +#define RAM(g) ((uint8_t *)g->priv) + +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) +#define xybit(y) (1 << ((y) & 7)) + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* + * As this controller can't update on a pixel boundary we need to maintain the + * the entire display surface in memory so that we can do the necessary bit + * operations. Fortunately it is a small display in monochrome. + * Display 48 * 84 / 8 = 504 + */ + +#define GDISP_SCREEN_BYTES ((GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT) / 8) + +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { + // The private area is the display surface. + if (!(g->priv = gfxAlloc(GDISP_SCREEN_BYTES))) + gfxHalt("GDISP PCD8544: Failed to allocate private memory"); + + // Initialise the board interface + init_board(g); + + // Hardware reset + setpin_reset(g, TRUE); + gfxSleepMilliseconds(100); + setpin_reset(g, FALSE); + gfxSleepMilliseconds(100); + + acquire_bus(g); + + write_cmd(g, PCD8544_SET_FUNC | PCD8544_H); + write_cmd(g, PCD8544_SET_TEMP | PCD8544_TEMP_MODE_2); + write_cmd(g, PCD8544_SET_BIAS | PCD8544_BIAS_MODE_4); + write_cmd(g, PCD8544_SET_VOP | (0x40)); + write_cmd(g, PCD8544_SET_FUNC); + write_cmd(g, PCD8544_SET_DISPLAY | PCD8544_DISPLAY_MODE_NORMAL); + write_cmd(g, PCD8544_SET_X); // X = 0 + write_cmd(g, PCD8544_SET_Y); // Y = 0 + + coord_t i; + + for (i = 0; i < GDISP_SCREEN_BYTES; i++) { + write_data(g, 0x00, 1); + } + + // Finish Init + post_init_board(g); + + // Release the bus + release_bus(g); + + /* Turn on the back-light */ + set_backlight(g, GDISP_INITIAL_BACKLIGHT); + + /* Initialise the GDISP structure */ + g->g.Width = GDISP_SCREEN_WIDTH; + g->g.Height = GDISP_SCREEN_HEIGHT; + g->g.Orientation = GDISP_ROTATE_0; + g->g.Powermode = powerOn; + g->g.Backlight = GDISP_INITIAL_BACKLIGHT; + g->g.Contrast = GDISP_INITIAL_CONTRAST; + + return TRUE; +} + +#if GDISP_HARDWARE_FLUSH + LLDSPEC void gdisp_lld_flush(GDisplay *g) { + + // Don't flush if we don't need it. + if (!(g->flags & GDISP_FLG_NEEDFLUSH)) { + return; + } + + acquire_bus(g); + + write_cmd(g, PCD8544_SET_X | 0); // X = 0 + write_cmd(g, PCD8544_SET_Y | 0); // Y = 0 + + coord_t i; + + for (i = 0; i < GDISP_SCREEN_BYTES; i++) { + write_data(g, RAM(g)[i], 1); + } + + release_bus(g); + } +#endif + +#if GDISP_HARDWARE_DRAWPIXEL + LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { + coord_t x, y; + + #if GDISP_NEED_CONTROL + switch(g->g.Orientation) { + default: + case GDISP_ROTATE_0: + x = g->p.x; + y = g->p.y; + break; + case GDISP_ROTATE_90: + x = g->p.y; + y = g->g.Width - g->p.x - 1; + break; + case GDISP_ROTATE_180: + x = g->g.Width - g->p.x - 1; + y = g->g.Height - g->p.y - 1; + break; + case GDISP_ROTATE_270: + x = g->g.Height - g->p.y - 1; + y = g->p.x; + break; + } + #else + x = g->p.x; + y = g->p.y; + #endif + + if (gdispColor2Native(g->p.color) != Black) { + RAM(g)[xyaddr(x, y)] |= xybit(y); + } else { + RAM(g)[xyaddr(x, y)] &= ~xybit(y); + } + + g->flags |= GDISP_FLG_NEEDFLUSH; + } +#endif + +#if GDISP_NEED_CONTROL + LLDSPEC void gdisp_lld_control(GDisplay *g) { + switch(g->p.x) { + case GDISP_CONTROL_POWER: + if (g->g.Powermode == (powermode_t)g->p.ptr) + return; + switch((powermode_t)g->p.ptr) { + case powerOff: + case powerSleep: + case powerDeepSleep: + write_cmd(g, PCD8544_SET_FUNC | PCD8544_PD); + break; + case powerOn: + write_cmd(g, PCD8544_SET_FUNC); + break; + default: + return; + } + g->g.Powermode = (powermode_t)g->p.ptr; + return; + + case GDISP_CONTROL_ORIENTATION: + if (g->g.Orientation == (orientation_t)g->p.ptr) + return; + switch((orientation_t)g->p.ptr) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + if (g->g.Orientation == GDISP_ROTATE_90 || g->g.Orientation == GDISP_ROTATE_270) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + if (g->g.Orientation == GDISP_ROTATE_0 || g->g.Orientation == GDISP_ROTATE_180) { + coord_t tmp; + + tmp = g->g.Width; + g->g.Width = g->g.Height; + g->g.Height = tmp; + } + break; + default: + return; + } + g->g.Orientation = (orientation_t)g->p.ptr; + return; + + case GDISP_CONTROL_BACKLIGHT: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + set_backlight(g, (unsigned)g->p.ptr); + g->g.Backlight = (unsigned)g->p.ptr; + return; + + case GDISP_CONTROL_CONTRAST: + if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100; + write_cmd(g, PCD8544_SET_VOP | (unsigned)g->p.ptr); + g->g.Contrast = (unsigned)g->p.ptr; + return; + } + } +#endif + +#endif // GFX_USE_GDISP diff --git a/drivers/gdisp/PCD8544/gdisp_lld_config.h b/drivers/gdisp/PCD8544/gdisp_lld_config.h new file mode 100644 index 00000000..6ad8a571 --- /dev/null +++ b/drivers/gdisp/PCD8544/gdisp_lld_config.h @@ -0,0 +1,28 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if GFX_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing +#define GDISP_HARDWARE_DRAWPIXEL TRUE +#define GDISP_HARDWARE_CONTROL TRUE + +// Set this to your frame buffer pixel format. +#ifndef GDISP_LLD_PIXELFORMAT + #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO +#endif + +#endif /* GFX_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ From 538f9fcea3150b926cc1da0360b92254cc544a47 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 9 Jul 2014 22:53:01 +0200 Subject: [PATCH 27/38] whitespaces --- drivers/gdisp/PCD8544/PCD8544.h | 46 +++++++++++++------------- drivers/gdisp/PCF8812/PCF8812.h | 58 ++++++++++++++++----------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/drivers/gdisp/PCD8544/PCD8544.h b/drivers/gdisp/PCD8544/PCD8544.h index 1a269ab4..3716a4a8 100644 --- a/drivers/gdisp/PCD8544/PCD8544.h +++ b/drivers/gdisp/PCD8544/PCD8544.h @@ -8,38 +8,38 @@ #ifndef _PCD8544_H #define _PCD8544_H -#define PCD8544_SET_FUNC 0x20 // Function set +#define PCD8544_SET_FUNC 0x20 // Function set #define PCD8544_H 0x01 #define PCD8544_V 0x02 #define PCD8544_PD 0x04 -#define PCD8544_SET_DISPLAY 0x08 -#define PCD8544_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 -#define PCD8544_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 -#define PCD8544_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 -#define PCD8544_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 +#define PCD8544_SET_DISPLAY 0x08 +#define PCD8544_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCD8544_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCD8544_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCD8544_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 -#define PCD8544_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 -#define PCD8544_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 +#define PCD8544_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCD8544_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 // ========================================= -#define PCD8544_SET_TEMP 0x04 // set temperature coefficient (TCx) -#define PCD8544_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 -#define PCD8544_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 -#define PCD8544_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 -#define PCD8544_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 +#define PCD8544_SET_TEMP 0x04 // set temperature coefficient (TCx) +#define PCD8544_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCD8544_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCD8544_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCD8544_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 -#define PCD8544_SET_BIAS 0x10 // set bias system (BSx) -#define PCD8544_BIAS_MODE_7 0x00 // 1 to 100 -#define PCD8544_BIAS_MODE_6 0x01 // 1 to 80 -#define PCD8544_BIAS_MODE_5 0x02 // 1 to 65 -#define PCD8544_BIAS_MODE_4 0x03 // 1 to 48 -#define PCD8544_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 -#define PCD8544_BIAS_MODE_2 0x05 // 1 to 24 -#define PCD8544_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 -#define PCD8544_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 +#define PCD8544_SET_BIAS 0x10 // set bias system (BSx) +#define PCD8544_BIAS_MODE_7 0x00 // 1 to 100 +#define PCD8544_BIAS_MODE_6 0x01 // 1 to 80 +#define PCD8544_BIAS_MODE_5 0x02 // 1 to 65 +#define PCD8544_BIAS_MODE_4 0x03 // 1 to 48 +#define PCD8544_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCD8544_BIAS_MODE_2 0x05 // 1 to 24 +#define PCD8544_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCD8544_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 -#define PCD8544_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 +#define PCD8544_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 #endif /* _PCD8544_H */ diff --git a/drivers/gdisp/PCF8812/PCF8812.h b/drivers/gdisp/PCF8812/PCF8812.h index 3064f9b1..c2695b71 100644 --- a/drivers/gdisp/PCF8812/PCF8812.h +++ b/drivers/gdisp/PCF8812/PCF8812.h @@ -8,46 +8,46 @@ #ifndef _PCF8812_H #define _PCF8812_H -#define PCF8812_SET_FUNC 0x20 // Function set +#define PCF8812_SET_FUNC 0x20 // Function set #define PCF8812_H 0x01 #define PCF8812_V 0x02 #define PCF8812_PD 0x04 -#define PCF8812_SET_DISPLAY 0x08 -#define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 -#define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 -#define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 -#define PCF8812_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 +#define PCF8812_SET_DISPLAY 0x08 +#define PCF8812_DISPLAY_MODE_BLANK 0x00 // bit D = 0, E = 0 +#define PCF8812_DISPLAY_MODE_FILL 0x01 // bit D = 0, E = 1 +#define PCF8812_DISPLAY_MODE_NORMAL 0x04 // bit D = 1, E = 0 +#define PCF8812_DISPLAY_MODE_INVERT 0x05 // bit D = 1, E = 1 -#define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select +#define PCF8812_SET_PRS 0x10 // Set Vop range, VLCD programming range select -#define PCF8812_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 -#define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 +#define PCF8812_SET_Y 0x40 // 0 0 1 0 0 Y3 Y2 Y1 Y0 +#define PCF8812_SET_X 0x80 // 0 1 X6 X5 X4 X3 X2 X1 X0 // ========================================= -#define PCF8812_SET_TEMP 0x04 // set temperature coefficient (TCx) -#define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 -#define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 -#define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 -#define PCF8812_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 +#define PCF8812_SET_TEMP 0x04 // set temperature coefficient (TCx) +#define PCF8812_TEMP_MODE_0 0x00 // TC1 = 0, TC0 = 0 +#define PCF8812_TEMP_MODE_1 0x01 // TC1 = 0, TC0 = 1 +#define PCF8812_TEMP_MODE_2 0x02 // TC1 = 1, TC0 = 0 +#define PCF8812_TEMP_MODE_3 0x03 // TC1 = 1, TC0 = 1 -#define PCF8812_SET_VMULT 0x08 // Set voltage multiplier factor -#define PCF8812_VMULT_MODE_0 0x00 // S1 = 0, S0 = 0 - 2 × voltage multiplier -#define PCF8812_VMULT_MODE_1 0x01 // S1 = 0, S0 = 1 - 3 × voltage multiplier -#define PCF8812_VMULT_MODE_2 0x02 // S1 = 1, S0 = 0 - 4 × voltage multiplier -#define PCF8812_VMULT_MODE_3 0x03 // S1 = 1, S0 = 1 - 5 × voltage multiplier +#define PCF8812_SET_VMULT 0x08 // Set voltage multiplier factor +#define PCF8812_VMULT_MODE_0 0x00 // S1 = 0, S0 = 0 - 2 × voltage multiplier +#define PCF8812_VMULT_MODE_1 0x01 // S1 = 0, S0 = 1 - 3 × voltage multiplier +#define PCF8812_VMULT_MODE_2 0x02 // S1 = 1, S0 = 0 - 4 × voltage multiplier +#define PCF8812_VMULT_MODE_3 0x03 // S1 = 1, S0 = 1 - 5 × voltage multiplier -#define PCF8812_SET_BIAS 0x10 // set bias system (BSx) -#define PCF8812_BIAS_MODE_7 0x00 // 1 to 100 -#define PCF8812_BIAS_MODE_6 0x01 // 1 to 80 -#define PCF8812_BIAS_MODE_5 0x02 // 1 to 65 -#define PCF8812_BIAS_MODE_4 0x03 // 1 to 48 -#define PCF8812_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 -#define PCF8812_BIAS_MODE_2 0x05 // 1 to 24 -#define PCF8812_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 -#define PCF8812_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 +#define PCF8812_SET_BIAS 0x10 // set bias system (BSx) +#define PCF8812_BIAS_MODE_7 0x00 // 1 to 100 +#define PCF8812_BIAS_MODE_6 0x01 // 1 to 80 +#define PCF8812_BIAS_MODE_5 0x02 // 1 to 65 +#define PCF8812_BIAS_MODE_4 0x03 // 1 to 48 +#define PCF8812_BIAS_MODE_3 0x04 // 1 to 40 or 1 to 34 +#define PCF8812_BIAS_MODE_2 0x05 // 1 to 24 +#define PCF8812_BIAS_MODE_1 0x06 // 1 to 18 or 1 to 16 +#define PCF8812_BIAS_MODE_0 0x07 // 1 to 10 or 1 to 9 or 1 to 8 -#define PCF8812_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 +#define PCF8812_SET_VOP 0x80 // write VOP to register, 1 VOP6 VOP5 VOP4 VOP3 VOP2 VOP1 VOP0 #endif /* _PCF8812_H */ From 5c8c0c7b36cd8f2c94b67cce56e99804a048a906 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 9 Jul 2014 22:57:57 +0200 Subject: [PATCH 28/38] more whitepsaces --- drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c | 10 +++++----- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c index 8ebd619a..377f3d8b 100644 --- a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c +++ b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c @@ -21,21 +21,21 @@ #define GDISP_SCREEN_HEIGHT 48 #define GDISP_SCREEN_WIDTH 84 -#define GDISP_INITIAL_CONTRAST 51 -#define GDISP_INITIAL_BACKLIGHT 100 +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 -#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCD8544/PCD8544.h" /*===========================================================================*/ -/* Driver local routines . */ +/* Driver local routines. */ /*===========================================================================*/ // Some common routines and macros #define RAM(g) ((uint8_t *)g->priv) -#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH) #define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 5377b7cd..27ce5b91 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -24,22 +24,22 @@ #define GDISP_SCREEN_HEIGHT 65 #define GDISP_SCREEN_WIDTH 96 -#define GDISP_INITIAL_CONTRAST 51 -#define GDISP_INITIAL_BACKLIGHT 100 +#define GDISP_INITIAL_CONTRAST 51 +#define GDISP_INITIAL_BACKLIGHT 100 -#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) +#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0) #include "drivers/gdisp/PCF8812/PCF8812.h" /*===========================================================================*/ -/* Driver local routines . */ +/* Driver local routines. */ /*===========================================================================*/ // Some common routines and macros -#define RAM(g) ((uint8_t *)g->priv) +#define RAM(g) ((uint8_t *)g->priv) -#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) -#define xybit(y) (1 << ((y) & 7)) +#define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_MATRIX_WIDTH) +#define xybit(y) (1 << ((y) & 7)) /*===========================================================================*/ /* Driver exported functions. */ From 7f7e2e5e1dfd5292e6b5d97c5ffb4ab56d723144 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 10 Jul 2014 23:07:13 +0300 Subject: [PATCH 29/38] fix SPI --- drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c index 377f3d8b..c970aaef 100644 --- a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c +++ b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c @@ -78,7 +78,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { coord_t i; - for (i = 0; i < GDISP_SCREEN_BYTES; i++) { + for(i = 0; i < GDISP_SCREEN_BYTES; i++) { write_data(g, 0x00, 1); } @@ -116,8 +116,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_cmd(g, PCD8544_SET_Y | 0); // Y = 0 coord_t i; - - for (i = 0; i < GDISP_SCREEN_BYTES; i++) { + for(i = 0; i < GDISP_SCREEN_BYTES; i++) { write_data(g, RAM(g)[i], 1); } @@ -128,7 +127,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { coord_t x, y; - + #if GDISP_NEED_CONTROL switch(g->g.Orientation) { default: From 1f72ee9f43eb07a6b3d5fb53f41a56f4a4a046a8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 10 Jul 2014 23:16:00 +0300 Subject: [PATCH 30/38] driver.mk is missed --- drivers/gdisp/PCF8812/driver.mk | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 drivers/gdisp/PCF8812/driver.mk diff --git a/drivers/gdisp/PCF8812/driver.mk b/drivers/gdisp/PCF8812/driver.mk new file mode 100644 index 00000000..f2394eaf --- /dev/null +++ b/drivers/gdisp/PCF8812/driver.mk @@ -0,0 +1,2 @@ +GFXINC += $(GFXLIB)/drivers/gdisp/PCF8812 +GFXSRC += $(GFXLIB)/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c From 326e246b77a9260c17a002863fccb9b9da7748cb Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 11 Jul 2014 19:06:42 +0200 Subject: [PATCH 31/38] adding ecos port to makefile --- src/gos/sys_make.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gos/sys_make.mk b/src/gos/sys_make.mk index 8ef22121..9e24f875 100644 --- a/src/gos/sys_make.mk +++ b/src/gos/sys_make.mk @@ -4,4 +4,5 @@ GFXSRC += $(GFXLIB)/src/gos/chibios.c \ $(GFXLIB)/src/gos/linux.c \ $(GFXLIB)/src/gos/osx.c \ $(GFXLIB)/src/gos/raw32.c \ + $(GFXLIB)/src/gos/ecos.c From c8342a0d25ee62643a77727624d155e3dc1142de Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 11 Jul 2014 19:07:47 +0200 Subject: [PATCH 32/38] eCos: fixing gfxFree() routine --- src/gos/ecos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gos/ecos.h b/src/gos/ecos.h index c24f3824..be9037b6 100644 --- a/src/gos/ecos.h +++ b/src/gos/ecos.h @@ -73,7 +73,7 @@ void gfxSleepMilliseconds(delaytime_t ms); void gfxSleepMicroseconds(delaytime_t ms); #define gfxAlloc(sz) malloc(sz) -#define gfxFree(ptr) free(sz) +#define gfxFree(ptr) free(ptr) #define gfxRealloc(ptr, oldsz, newsz) realloc(ptr, newsz) #define gfxSystemLock() cyg_scheduler_lock() From 1fe4bcde39507769255080b5e98c1c09119902f2 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 11 Jul 2014 20:41:50 +0200 Subject: [PATCH 33/38] Added gwinDrawThickLine() wrapper for corresponding GDISP call --- docs/releases.txt | 1 + src/gwin/gwin.c | 6 ++++++ src/gwin/sys_defs.h | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/docs/releases.txt b/docs/releases.txt index e0c47c4a..31fe2843 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -10,6 +10,7 @@ FEATURE: Added Linux-Framebuffer board definition FEATURE: Added FatFS support for GFILE FEATURE: Added gfileMount() and gfileUnmount() FEATURE: Added gfileSync() +FEATURE: Added gwinDrawThickLine() *** Release 2.1 *** diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index e1625b13..ab2e2981 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -226,6 +226,12 @@ void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1) { _gwinDrawEnd(gh); } +void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round) { + if (!_gwinDrawStart(gh)) return; + gdispGDrawThickLine(gh->display, gh->x+x0, gh->y+y0, gh->x+x1, gh->y+y1, gh->color, width, round); + _gwinDrawEnd(gh); +} + void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy) { if (!_gwinDrawStart(gh)) return; gdispGDrawBox(gh->display, gh->x+x, gh->y+y, cx, cy, gh->color); diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h index 830827b2..169b4498 100644 --- a/src/gwin/sys_defs.h +++ b/src/gwin/sys_defs.h @@ -600,6 +600,24 @@ extern "C" { */ void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1); + /** + * @brief Draw a thick line in the window + * @details The line thickness is specified in pixels. The line ends can + * be selected to be either flat or round. + * @note Uses gdispGFillConvexPoly() internally to perform the drawing. + * @note Uses the current foreground color to draw the line + * + * @param[in] gh The window handle + * @param[in] x0,y0 The start position + * @param[in] x1,y1 The end position + * @param[in] color The color to use + * @param[in] width The width of the line + * @param[in] round Use round ends for the line + * + * @api + */ + void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round); + /** * @brief Draw a box in the window * @note Uses the current foreground color to draw the box From a26cf85256eacf740a7fad15f91d0b2186238d1b Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 11 Jul 2014 23:15:24 +0200 Subject: [PATCH 34/38] FireBull board file fix --- boards/base/FireBull-STM32F103-FB/board_SSD1289.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/base/FireBull-STM32F103-FB/board_SSD1289.h b/boards/base/FireBull-STM32F103-FB/board_SSD1289.h index 99001e07..e7c07c70 100644 --- a/boards/base/FireBull-STM32F103-FB/board_SSD1289.h +++ b/boards/base/FireBull-STM32F103-FB/board_SSD1289.h @@ -113,6 +113,8 @@ static inline void setwritemode(GDisplay *g) } static inline uint16_t read_data(GDisplay *g) { + (void) g; + return palReadPort(GPIOE); } From 94bc703fe24996b063d8f800a485a26a04f0d234 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 12 Jul 2014 10:55:42 +0300 Subject: [PATCH 35/38] fix SPI send data --- drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c index 27ce5b91..56d14f3e 100644 --- a/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c +++ b/drivers/gdisp/PCF8812/gdisp_lld_PCF8812.c @@ -81,11 +81,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_cmd(g, PCF8812_SET_X); // X = 0 write_cmd(g, PCF8812_SET_Y); // Y = 0 - coord_t i; - for (i = 0; i < GDISP_MATRIX_BYTES; i++) { - write_data(g, 0x00, 1); - } + write_data(g, 0x00, GDISP_MATRIX_BYTES); // Finish Init post_init_board(g); @@ -120,11 +117,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_cmd(g, PCF8812_SET_X | 0); // X = 0 write_cmd(g, PCF8812_SET_Y | 0); // Y = 0 - coord_t i; - - for (i = 0; i < GDISP_MATRIX_BYTES; i++) { - write_data(g, RAM(g)[i], 1); - } + write_data(g, RAM(g), GDISP_MATRIX_BYTES); release_bus(g); } From 1104638ff06150d5b611186406e20eeb5be55b12 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 12 Jul 2014 11:00:39 +0300 Subject: [PATCH 36/38] fix SPI send data --- drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c index c970aaef..ee447202 100644 --- a/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c +++ b/drivers/gdisp/PCD8544/gdisp_lld_PCD8544.c @@ -76,11 +76,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_cmd(g, PCD8544_SET_X); // X = 0 write_cmd(g, PCD8544_SET_Y); // Y = 0 - coord_t i; - - for(i = 0; i < GDISP_SCREEN_BYTES; i++) { - write_data(g, 0x00, 1); - } + write_data(g, 0x00, GDISP_SCREEN_BYTES); // Finish Init post_init_board(g); @@ -115,10 +111,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_cmd(g, PCD8544_SET_X | 0); // X = 0 write_cmd(g, PCD8544_SET_Y | 0); // Y = 0 - coord_t i; - for(i = 0; i < GDISP_SCREEN_BYTES; i++) { - write_data(g, RAM(g)[i], 1); - } + write_data(g, RAM(g), GDISP_SCREEN_BYTES); release_bus(g); } From fdb3b86ee088ed4b263664f388742099c1210edb Mon Sep 17 00:00:00 2001 From: inmarket Date: Tue, 15 Jul 2014 12:40:43 +1000 Subject: [PATCH 37/38] Thick line support is only available if Polygon drawing is available --- src/gwin/gwin.c | 11 +++++------ src/gwin/sys_defs.h | 35 +++++++++++++++++------------------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index ab2e2981..ee0a7222 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -226,12 +226,6 @@ void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1) { _gwinDrawEnd(gh); } -void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round) { - if (!_gwinDrawStart(gh)) return; - gdispGDrawThickLine(gh->display, gh->x+x0, gh->y+y0, gh->x+x1, gh->y+y1, gh->color, width, round); - _gwinDrawEnd(gh); -} - void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy) { if (!_gwinDrawStart(gh)) return; gdispGDrawBox(gh->display, gh->x+x, gh->y+y, cx, cy, gh->color); @@ -350,6 +344,11 @@ void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coor gdispGFillConvexPoly(gh->display, tx+gh->x, ty+gh->y, pntarray, cnt, gh->color); _gwinDrawEnd(gh); } + void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round) { + if (!_gwinDrawStart(gh)) return; + gdispGDrawThickLine(gh->display, gh->x+x0, gh->y+y0, gh->x+x1, gh->y+y1, gh->color, width, round); + _gwinDrawEnd(gh); + } #endif #if GDISP_NEED_IMAGE diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h index 169b4498..4b103d11 100644 --- a/src/gwin/sys_defs.h +++ b/src/gwin/sys_defs.h @@ -600,24 +600,6 @@ extern "C" { */ void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1); - /** - * @brief Draw a thick line in the window - * @details The line thickness is specified in pixels. The line ends can - * be selected to be either flat or round. - * @note Uses gdispGFillConvexPoly() internally to perform the drawing. - * @note Uses the current foreground color to draw the line - * - * @param[in] gh The window handle - * @param[in] x0,y0 The start position - * @param[in] x1,y1 The end position - * @param[in] color The color to use - * @param[in] width The width of the line - * @param[in] round Use round ends for the line - * - * @api - */ - void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round); - /** * @brief Draw a box in the window * @note Uses the current foreground color to draw the box @@ -910,6 +892,23 @@ extern "C" { * @api */ void gwinFillConvexPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt); + + /** + * @brief Draw a thick line in the window + * @details The line thickness is specified in pixels. The line ends can + * be selected to be either flat or round. + * @note Uses gdispGFillConvexPoly() internally to perform the drawing. + * @note Uses the current foreground color to draw the line + * + * @param[in] gh The window handle + * @param[in] x0,y0 The start position + * @param[in] x1,y1 The end position + * @param[in] width The width of the line + * @param[in] round Use round ends for the line + * + * @api + */ + void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round); #endif /*------------------------------------------------- From db4719bd1d3cef2597f1bf443f8d82a27f233eae Mon Sep 17 00:00:00 2001 From: inmarket Date: Tue, 15 Jul 2014 12:41:07 +1000 Subject: [PATCH 38/38] Release doco update --- docs/releases.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/releases.txt b/docs/releases.txt index 31fe2843..2d5bb648 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -11,6 +11,10 @@ FEATURE: Added FatFS support for GFILE FEATURE: Added gfileMount() and gfileUnmount() FEATURE: Added gfileSync() FEATURE: Added gwinDrawThickLine() +FEATURE: Added support for eCos +FEATURE: Added PCF8812 gdisp driver +FEATURE: Added PCD8544 gdisp driver +FEATURE: Added Raspberry Pi board support *** Release 2.1 ***