aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/test
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/test')
-rw-r--r--tmk_core/common/test/eeprom.c83
-rw-r--r--tmk_core/common/test/suspend.c2
-rw-r--r--tmk_core/common/test/timer.c8
3 files changed, 43 insertions, 50 deletions
diff --git a/tmk_core/common/test/eeprom.c b/tmk_core/common/test/eeprom.c
index 61cc039ef..44a0bf4d7 100644
--- a/tmk_core/common/test/eeprom.c
+++ b/tmk_core/common/test/eeprom.c
@@ -21,78 +21,75 @@
21static uint8_t buffer[EEPROM_SIZE]; 21static uint8_t buffer[EEPROM_SIZE];
22 22
23uint8_t eeprom_read_byte(const uint8_t *addr) { 23uint8_t eeprom_read_byte(const uint8_t *addr) {
24 uintptr_t offset = (uintptr_t)addr; 24 uintptr_t offset = (uintptr_t)addr;
25 return buffer[offset]; 25 return buffer[offset];
26} 26}
27 27
28void eeprom_write_byte(uint8_t *addr, uint8_t value) { 28void eeprom_write_byte(uint8_t *addr, uint8_t value) {
29 uintptr_t offset = (uintptr_t)addr; 29 uintptr_t offset = (uintptr_t)addr;
30 buffer[offset] = value; 30 buffer[offset] = value;
31} 31}
32 32
33uint16_t eeprom_read_word(const uint16_t *addr) { 33uint16_t eeprom_read_word(const uint16_t *addr) {
34 const uint8_t *p = (const uint8_t *)addr; 34 const uint8_t *p = (const uint8_t *)addr;
35 return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8); 35 return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8);
36} 36}
37 37
38uint32_t eeprom_read_dword(const uint32_t *addr) { 38uint32_t eeprom_read_dword(const uint32_t *addr) {
39 const uint8_t *p = (const uint8_t *)addr; 39 const uint8_t *p = (const uint8_t *)addr;
40 return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8) 40 return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24);
41 | (eeprom_read_byte(p+2) << 16) | (eeprom_read_byte(p+3) << 24);
42} 41}
43 42
44void eeprom_read_block(void *buf, const void *addr, uint32_t len) { 43void eeprom_read_block(void *buf, const void *addr, uint32_t len) {
45 const uint8_t *p = (const uint8_t *)addr; 44 const uint8_t *p = (const uint8_t *)addr;
46 uint8_t *dest = (uint8_t *)buf; 45 uint8_t * dest = (uint8_t *)buf;
47 while (len--) { 46 while (len--) {
48 *dest++ = eeprom_read_byte(p++); 47 *dest++ = eeprom_read_byte(p++);
49 } 48 }
50} 49}
51 50
52void eeprom_write_word(uint16_t *addr, uint16_t value) { 51void eeprom_write_word(uint16_t *addr, uint16_t value) {
53 uint8_t *p = (uint8_t *)addr; 52 uint8_t *p = (uint8_t *)addr;
54 eeprom_write_byte(p++, value); 53 eeprom_write_byte(p++, value);
55 eeprom_write_byte(p, value >> 8); 54 eeprom_write_byte(p, value >> 8);
56} 55}
57 56
58void eeprom_write_dword(uint32_t *addr, uint32_t value) { 57void eeprom_write_dword(uint32_t *addr, uint32_t value) {
59 uint8_t *p = (uint8_t *)addr; 58 uint8_t *p = (uint8_t *)addr;
60 eeprom_write_byte(p++, value); 59 eeprom_write_byte(p++, value);
61 eeprom_write_byte(p++, value >> 8); 60 eeprom_write_byte(p++, value >> 8);
62 eeprom_write_byte(p++, value >> 16); 61 eeprom_write_byte(p++, value >> 16);
63 eeprom_write_byte(p, value >> 24); 62 eeprom_write_byte(p, value >> 24);
64} 63}
65 64
66void eeprom_write_block(const void *buf, void *addr, uint32_t len) { 65void eeprom_write_block(const void *buf, void *addr, uint32_t len) {
67 uint8_t *p = (uint8_t *)addr; 66 uint8_t * p = (uint8_t *)addr;
68 const uint8_t *src = (const uint8_t *)buf; 67 const uint8_t *src = (const uint8_t *)buf;
69 while (len--) { 68 while (len--) {
70 eeprom_write_byte(p++, *src++); 69 eeprom_write_byte(p++, *src++);
71 } 70 }
72} 71}
73 72
74void eeprom_update_byte(uint8_t *addr, uint8_t value) { 73void eeprom_update_byte(uint8_t *addr, uint8_t value) { eeprom_write_byte(addr, value); }
75 eeprom_write_byte(addr, value);
76}
77 74
78void eeprom_update_word(uint16_t *addr, uint16_t value) { 75void eeprom_update_word(uint16_t *addr, uint16_t value) {
79 uint8_t *p = (uint8_t *)addr; 76 uint8_t *p = (uint8_t *)addr;
80 eeprom_write_byte(p++, value); 77 eeprom_write_byte(p++, value);
81 eeprom_write_byte(p, value >> 8); 78 eeprom_write_byte(p, value >> 8);
82} 79}
83 80
84void eeprom_update_dword(uint32_t *addr, uint32_t value) { 81void eeprom_update_dword(uint32_t *addr, uint32_t value) {
85 uint8_t *p = (uint8_t *)addr; 82 uint8_t *p = (uint8_t *)addr;
86 eeprom_write_byte(p++, value); 83 eeprom_write_byte(p++, value);
87 eeprom_write_byte(p++, value >> 8); 84 eeprom_write_byte(p++, value >> 8);
88 eeprom_write_byte(p++, value >> 16); 85 eeprom_write_byte(p++, value >> 16);
89 eeprom_write_byte(p, value >> 24); 86 eeprom_write_byte(p, value >> 24);
90} 87}
91 88
92void eeprom_update_block(const void *buf, void *addr, uint32_t len) { 89void eeprom_update_block(const void *buf, void *addr, uint32_t len) {
93 uint8_t *p = (uint8_t *)addr; 90 uint8_t * p = (uint8_t *)addr;
94 const uint8_t *src = (const uint8_t *)buf; 91 const uint8_t *src = (const uint8_t *)buf;
95 while (len--) { 92 while (len--) {
96 eeprom_write_byte(p++, *src++); 93 eeprom_write_byte(p++, *src++);
97 } 94 }
98} 95}
diff --git a/tmk_core/common/test/suspend.c b/tmk_core/common/test/suspend.c
index 01d1930ea..76b705967 100644
--- a/tmk_core/common/test/suspend.c
+++ b/tmk_core/common/test/suspend.c
@@ -13,5 +13,3 @@
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16
17
diff --git a/tmk_core/common/test/timer.c b/tmk_core/common/test/timer.c
index 19e79e1f5..3c786ae29 100644
--- a/tmk_core/common/test/timer.c
+++ b/tmk_core/common/test/timer.c
@@ -18,9 +18,9 @@
18 18
19static uint32_t current_time = 0; 19static uint32_t current_time = 0;
20 20
21void timer_init(void) {current_time = 0;} 21void timer_init(void) { current_time = 0; }
22 22
23void timer_clear(void) {current_time = 0;} 23void timer_clear(void) { current_time = 0; }
24 24
25uint16_t timer_read(void) { return current_time & 0xFFFF; } 25uint16_t timer_read(void) { return current_time & 0xFFFF; }
26uint32_t timer_read32(void) { return current_time; } 26uint32_t timer_read32(void) { return current_time; }
@@ -30,6 +30,4 @@ uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), l
30void set_time(uint32_t t) { current_time = t; } 30void set_time(uint32_t t) { current_time = t; }
31void advance_time(uint32_t ms) { current_time += ms; } 31void advance_time(uint32_t ms) { current_time += ms; }
32 32
33void wait_ms(uint32_t ms) { 33void wait_ms(uint32_t ms) { advance_time(ms); } \ No newline at end of file
34 advance_time(ms);
35} \ No newline at end of file