From: bernie Date: Tue, 1 Mar 2005 23:26:46 +0000 (+0000) Subject: Use new CPU-neutral program-memory API. X-Git-Tag: 1.0.0~851 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=64969cdb6b48f50b642178779baf9e1e317e0645;p=bertos.git Use new CPU-neutral program-memory API. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@390 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/mware/font.h b/mware/font.h index afdd39c0..cdc0142a 100755 --- a/mware/font.h +++ b/mware/font.h @@ -1,8 +1,8 @@ /*! * \file * * * \version $Id$ @@ -14,6 +14,9 @@ /*#* *#* $Log$ + *#* Revision 1.5 2005/03/01 23:26:45 bernie + *#* Use new CPU-neutral program-memory API. + *#* *#* Revision 1.4 2004/12/31 16:42:55 bernie *#* Sanitize for non-Harvard processors. *#* @@ -33,16 +36,21 @@ *#* Move font table in program memory; add font.h *#* *#*/ -#ifndef FONT_H -#define FONT_H +#ifndef MWARE_FONT_H +#define MWARE_FONT_H -#include "compiler.h" /* PROGMEM */ +#include /* uint8_t */ +#include /* PROGMEM */ -/* Font size (in pixel) */ -#define FONT_WIDTH 6 -#define FONT_HEIGHT 8 +/*! + * \name Font size (in pixel) + * \{ + */ +#define FONT_WIDTH 6 +#define FONT_HEIGHT 8 +/* \} */ /*! Font table */ extern const PROGMEM uint8_t font[256 * FONT_WIDTH]; -#endif /* FONT_H */ +#endif /* MWARE_FONT_H */ diff --git a/mware/gfx.c b/mware/gfx.c index 2a4d8ef9..6d164f18 100755 --- a/mware/gfx.c +++ b/mware/gfx.c @@ -16,6 +16,9 @@ /*#* *#* $Log$ + *#* Revision 1.12 2005/03/01 23:26:45 bernie + *#* Use new CPU-neutral program-memory API. + *#* *#* Revision 1.11 2004/12/08 08:06:16 bernie *#* Remove done todo. *#* @@ -107,13 +110,16 @@ void gfx_bitmapClear(Bitmap *bm) #if CPU_HARVARD + +#include /* FIXME: memcpy_P() */ + /*! * Copy a raster picture located in program memory in the bitmap. * The size of the raster to copy *must* be the same of the raster bitmap. * * \note This function does \b not update the current pen position */ -void gfx_blit_P(Bitmap *bm, const prog_uchar *raster) +void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster) { memcpy_P(bm->raster, raster, (bm->height / 8) * bm->width); } diff --git a/mware/gfx.h b/mware/gfx.h index 427063a1..ab10712a 100755 --- a/mware/gfx.h +++ b/mware/gfx.h @@ -14,6 +14,9 @@ /*#* *#* $Log$ + *#* Revision 1.10 2005/03/01 23:26:45 bernie + *#* Use new CPU-neutral program-memory API. + *#* *#* Revision 1.9 2005/01/20 18:46:31 aleph *#* Fix progmem includes. *#* @@ -96,6 +99,7 @@ extern void gfx_lineTo (Bitmap *bm, coord_t x, coord_t y); extern void gfx_setClipRect(Bitmap *bm, coord_t xmin, coord_t ymin, coord_t xmax, coord_t ymax); #if CPU_HARVARD + #include extern void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster); #endif diff --git a/mware/pgm.h b/mware/pgm.h index dcce64da..d8ef9f54 100755 --- a/mware/pgm.h +++ b/mware/pgm.h @@ -1,8 +1,7 @@ /*! * \file * * @@ -40,6 +39,41 @@ ); \ __result; \ }) + #if 0 // 128/103 + #define pgm_read_uint16_t(addr) \ + ({ \ + uint32_t __addr32 = (uint32_t)(addr); \ + uint16_t __result; \ + __asm__ \ + ( \ + "out %2, %C1" "\n\t" \ + "movw r30, %1" "\n\t" \ + "elpm %A0, Z+" "\n\t" \ + "elpm %B0, Z" "\n\t" \ + : "=r" (__result) \ + : "r" (__addr32), \ + "I" (_SFR_IO_ADDR(RAMPZ)) \ + : "r30", "r31" \ + ); \ + __result; \ + }) + #endif + + #define pgm_read_uint16_t(addr) \ + ({ \ + uint16_t __addr16 = (uint16_t)(addr); \ + uint16_t __result; \ + __asm__ \ + ( \ + "lpm %A0, Z+" "\n\t" \ + "lpm %B0, Z" "\n\t" \ + : "=r" (__result), "=z" (__addr16) \ + : "1" (__addr16) \ + ); \ + __result; \ + }) + + #else #define pgm_read_char(addr) \ ({ \ @@ -55,10 +89,54 @@ ); \ __result; \ }) + #if 0 // 128/103 + #define pgm_read_uint16_t(addr) \ + ({ \ + uint32_t __addr32 = (uint32_t)(addr); \ + uint16_t __result; \ + __asm__ \ + ( \ + "out %2, %C1" "\n\t" \ + "mov r31, %B1" "\n\t" \ + "mov r30, %A1" "\n\t" \ + "elpm" "\n\t" \ + "mov %A0, r0" "\n\t" \ + "in r0, %2" "\n\t" \ + "adiw r30, 1" "\n\t" \ + "adc r0, __zero_reg__" "\n\t" \ + "out %2, r0" "\n\t" \ + "elpm" "\n\t" \ + "mov %B0, r0" "\n\t" \ + : "=r" (__result) \ + : "r" (__addr32), \ + "I" (_SFR_IO_ADDR(RAMPZ)) \ + : "r0", "r30", "r31" \ + ); \ + __result; \ + }) + #endif + #define pgm_read_uint16_t(addr) \ + ({ \ + uint16_t __addr16 = (uint16_t)(addr); \ + uint16_t __result; \ + __asm__ \ + ( \ + "lpm" "\n\t" \ + "mov %A0, r0" "\n\t" \ + "adiw r30, 1" "\n\t" \ + "lpm" "\n\t" \ + "mov %B0, r0" "\n\t" \ + : "=r" (__result), "=z" (__addr16) \ + : "1" (__addr16) \ + : "r0" \ + ); \ + __result; \ + }) + #endif #define PROGMEM __attribute__((__progmem__)) - #define PSTR(s) ({static const char __c[] PROGMEM = (s); __c;}) + #define PSTR(s) ({ static const char __c[] PROGMEM = (s); &__c[0]; }) #elif CPU_HARVARD #error Missing CPU support diff --git a/mware/text.h b/mware/text.h index d064215f..1f8bd894 100755 --- a/mware/text.h +++ b/mware/text.h @@ -1,9 +1,9 @@ /*! * \file * * * \brief Text graphic routines (interface) @@ -15,6 +15,9 @@ /*#* *#* $Log$ + *#* Revision 1.10 2005/03/01 23:26:46 bernie + *#* Use new CPU-neutral program-memory API. + *#* *#* Revision 1.9 2004/12/31 16:44:29 bernie *#* Sanitize for non-Harvard processors. *#* @@ -104,6 +107,7 @@ int text_widthf(struct Bitmap *bm, const char * fmt, ...) FORMAT(__printf__, 2, /* Text formatting functions for program-memory strings (mware/text_format.c) */ #if CPU_HARVARD +#include int text_puts_P(const char * PROGMEM str, struct Bitmap *bm); int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap); int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);