Use new CPU-neutral program-memory API.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 1 Mar 2005 23:26:46 +0000 (23:26 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 1 Mar 2005 23:26:46 +0000 (23:26 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@390 38d2e660-2303-0410-9eaa-f027e97ec537

mware/font.h
mware/gfx.c
mware/gfx.h
mware/pgm.h
mware/text.h

index afdd39c097a039bbca5bd2e309685b845f302cde..cdc0142a2500b5c687fe6586ca5176830bde8a4b 100755 (executable)
@@ -1,8 +1,8 @@
 /*!
  * \file
  * <!--
- * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
- * This file is part of DevLib - See devlib/README for information.
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * This file is part of DevLib - See README.devlib for information.
  * -->
  *
  * \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.
  *#*
  *#* 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 <compiler.h> /* uint8_t */
+#include <mware/pgm.h> /* 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 */
index 2a4d8ef95af168ab340cc92e2d0f7c42055c14b9..6d164f18e5939f542d0378bcfa0287c53e4e9a76 100755 (executable)
@@ -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 <avr/pgmspace.h> /* 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);
 }
index 427063a1b906c5667d28f3f776b7680b1882189e..ab10712ad747782c3ba881464ece756a9ed7df4d 100755 (executable)
@@ -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 <mware/pgm.h>
        extern void gfx_blit_P(Bitmap *bm, const pgm_uint8_t *raster);
 #endif
 
index dcce64da67732d30fcd1fb5833b9b27f3fd07835..d8ef9f5426df09b5996b9c0c0ce64a7cf70d762c 100755 (executable)
@@ -1,8 +1,7 @@
 /*!
  * \file
  * <!--
- * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2004 Giovanni Bajo
+ * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
  * This file is part of DevLib - See README.devlib for information.
  * -->
  *
                        ); \
                        __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) \
                ({ \
                        ); \
                        __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
index d064215f26453dc9821c9d6f9180afcab1cdfa75..1f8bd89463496dced16fca7d7cdfa1ffd140b160 100755 (executable)
@@ -1,9 +1,9 @@
 /*!
  * \file
  * <!--
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
  * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See devlib/README for information.
+ * This file is part of DevLib - See README.devlib for information.
  * -->
  *
  * \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 <mware/pgm.h>
 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);