aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-06-14 00:04:45 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-06-14 00:04:45 -0400
commit74b7520159a5f7fc86f8698a5ac042d96ae4f6ee (patch)
tree2f41a6974c6dab9172dced642994e10f39b2d59a
parent57f21c8c3a0bd540fd0894a10917e77398ef38b8 (diff)
downloadlibrambutan-74b7520159a5f7fc86f8698a5ac042d96ae4f6ee.tar.gz
librambutan-74b7520159a5f7fc86f8698a5ac042d96ae4f6ee.zip
arm-gcc: Expanding notes on replacing pgmspace.h
Thanks to James Bowman for the extra defines and typedef.
-rw-r--r--source/arm-gcc.rst23
1 files changed, 17 insertions, 6 deletions
diff --git a/source/arm-gcc.rst b/source/arm-gcc.rst
index e97bb2f..5fb9a17 100644
--- a/source/arm-gcc.rst
+++ b/source/arm-gcc.rst
@@ -74,12 +74,23 @@ including Arduino) for use on the Maple.
.. _arm-gcc-attribute-flash:
-- Replacing ``PROGMEM``: You can direct the linker script provided
- with libmaple to store a variable in Flash (instead of RAM) by using
- the libmaple macro ``__FLASH__``, like so::
+- Replacing ``PROGMEM``: If you need to store a lot of constant data,
+ you can store variables in Flash (instead of RAM) by using the
+ libmaple macro ``__FLASH__``. Here's an example::
uint32 array[] __FLASH__ = {0, 1, 2};
- Be aware, however, that if you do that, you can only store values
- which are compile-time constants, and that if you attempt to change
- a variable stored in Flash, your program will crash.
+ This will help you save RAM when you need to store large amounts of
+ data, like look-up tables.
+
+ You can only store values which are compile-time constants (like
+ numbers and strings, and arrays of numbers and strings) in this way.
+ Also, if you try to change a variable stored in Flash, your program
+ will crash.
+
+ If you need to port over AVR/Arduino code that uses pgmspace.h,
+ these declarations may help you::
+
+ typedef const unsigned char prog_uchar;
+ #define pgm_read_byte_near(x) (*(prog_uchar*)x)
+ #define pgm_read_byte(x) (*(prog_uchar*)x)