summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDave Hodder <dave.hodder@focusrite.com>2016-02-12 18:06:50 +0000
committerDave Hodder <dave.hodder@focusrite.com>2016-02-12 18:06:50 +0000
commit167a7dc6a753b5ba11c8c2ae2a365cec8656c171 (patch)
treeab89dcb74260171628ef12dce11f1ba6f8c64391 /include
parent6edc776b3d0a33c1b59ed29d66570cc8b5bc74e2 (diff)
downloadlaunchpad-polymaker-167a7dc6a753b5ba11c8c2ae2a365cec8656c171.tar.gz
launchpad-polymaker-167a7dc6a753b5ba11c8c2ae2a365cec8656c171.zip
single-page flash storage
Diffstat (limited to 'include')
-rw-r--r--include/app.h36
-rw-r--r--include/app_defs.h7
2 files changed, 42 insertions, 1 deletions
diff --git a/include/app.h b/include/app.h
index ed946d5..c26c131 100644
--- a/include/app.h
+++ b/include/app.h
@@ -43,7 +43,7 @@
43 43
44/****************************************************************************** 44/******************************************************************************
45 Button indexing is as follows - numbers in brackets do not correspond to real 45 Button indexing is as follows - numbers in brackets do not correspond to real
46buttons, but can be harmessly sent in hal_set_led. 46 buttons, but can be harmessly sent in hal_set_led.
47 47
48 (90)91 92 93 94 95 96 97 98 (99) 48 (90)91 92 93 94 95 96 97 98 (99)
49 ....... 49 .......
@@ -92,6 +92,40 @@ void hal_send_midi(u8 port, u8 status, u8 data1, u8 data2);
92 */ 92 */
93void hal_send_sysex(u8 port, const u8* data, u16 length); 93void hal_send_sysex(u8 port, const u8* data, u16 length);
94 94
95/**
96 * Read some data from flash.
97 *
98 * Flash storage is in a single block, currently corresponding to one page.
99 * The block is always USER_AREA_SIZE bytes long. You can read/write any bytes
100 * within it - you do not need to worry about paging, that's handled by the HAL.
101 *
102 * The block size may increase to span multiple pages in future :)
103 *
104 * @param offset - how far into the USER_AREA_SIZE byte block to start reading
105 * @param data - buffer to receive data (must be at least length bytes long)
106 * @param length - bytes to read
107 *
108 * Attempts to read beyond the end of the block will fail silently.
109 *
110 * Note that your first ever read from a new device will contain 0xFF's until
111 * you overwrite them.
112 */
113void hal_read_flash(u32 offset, u8 *data, u32 length);
114
115/**
116 * Write data to flash
117 *
118 * Do take care to avoid thrashing it, as you can wear it out with excessive
119 * writes. The HAL does not currently do anything clever to mitigate this.
120 *
121 * @param offset - how far into the USER_AREA_SIZE byte block to start writing
122 * @param data - buffer to write (must be at least length bytes long)
123 * @param length - bytes to write
124 *
125 * Attempts to write beyond the end of the block will fail silently
126 */
127void hal_write_flash(u32 offset,const u8 *data, u32 length);
128
95// ____________________________________________________________________________ 129// ____________________________________________________________________________
96// 130//
97// Callbacks from the hardware (implemented in your app.c) 131// Callbacks from the hardware (implemented in your app.c)
diff --git a/include/app_defs.h b/include/app_defs.h
index 829f8a6..7a3efa1 100644
--- a/include/app_defs.h
+++ b/include/app_defs.h
@@ -100,5 +100,12 @@ typedef unsigned char u8;
100#define MIDI_OUT_CABLE 1 100#define MIDI_OUT_CABLE 1
101 101
102// ____________________________________________________________________________ 102// ____________________________________________________________________________
103//
104// Flash storage
105// ____________________________________________________________________________
106
107#define USER_AREA_SIZE 1024
108
109// ____________________________________________________________________________
103 110
104#endif 111#endif