aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/chibios
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/chibios')
-rw-r--r--tmk_core/common/chibios/bootloader.c8
-rw-r--r--tmk_core/common/chibios/eeprom.c44
-rw-r--r--tmk_core/common/chibios/suspend.c18
3 files changed, 69 insertions, 1 deletions
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c
index 2dd3ade34..f9895237b 100644
--- a/tmk_core/common/chibios/bootloader.c
+++ b/tmk_core/common/chibios/bootloader.c
@@ -13,11 +13,19 @@ extern uint32_t __ram0_end__;
13#define MAGIC_ADDR (unsigned long*)(SYMVAL(__ram0_end__) - 4) 13#define MAGIC_ADDR (unsigned long*)(SYMVAL(__ram0_end__) - 4)
14 14
15 15
16/** \brief Jump to the bootloader
17 *
18 * FIXME: needs doc
19 */
16void bootloader_jump(void) { 20void bootloader_jump(void) {
17 *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader 21 *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader
18 NVIC_SystemReset(); 22 NVIC_SystemReset();
19} 23}
20 24
25/** \brief Enter bootloader mode if requested
26 *
27 * FIXME: needs doc
28 */
21void enter_bootloader_mode_if_requested(void) { 29void enter_bootloader_mode_if_requested(void) {
22 unsigned long* check = MAGIC_ADDR; 30 unsigned long* check = MAGIC_ADDR;
23 if(*check == BOOTLOADER_MAGIC) { 31 if(*check == BOOTLOADER_MAGIC) {
diff --git a/tmk_core/common/chibios/eeprom.c b/tmk_core/common/chibios/eeprom.c
index 5ff8ee86f..9061b790c 100644
--- a/tmk_core/common/chibios/eeprom.c
+++ b/tmk_core/common/chibios/eeprom.c
@@ -79,6 +79,10 @@
79 #define EEESIZE 0x39 79 #define EEESIZE 0x39
80#endif 80#endif
81 81
82/** \brief eeprom initialization
83 *
84 * FIXME: needs doc
85 */
82void eeprom_initialize(void) 86void eeprom_initialize(void)
83{ 87{
84 uint32_t count=0; 88 uint32_t count=0;
@@ -111,6 +115,10 @@ void eeprom_initialize(void)
111 115
112#define FlexRAM ((uint8_t *)0x14000000) 116#define FlexRAM ((uint8_t *)0x14000000)
113 117
118/** \brief eeprom read byte
119 *
120 * FIXME: needs doc
121 */
114uint8_t eeprom_read_byte(const uint8_t *addr) 122uint8_t eeprom_read_byte(const uint8_t *addr)
115{ 123{
116 uint32_t offset = (uint32_t)addr; 124 uint32_t offset = (uint32_t)addr;
@@ -119,6 +127,10 @@ uint8_t eeprom_read_byte(const uint8_t *addr)
119 return FlexRAM[offset]; 127 return FlexRAM[offset];
120} 128}
121 129
130/** \brief eeprom read word
131 *
132 * FIXME: needs doc
133 */
122uint16_t eeprom_read_word(const uint16_t *addr) 134uint16_t eeprom_read_word(const uint16_t *addr)
123{ 135{
124 uint32_t offset = (uint32_t)addr; 136 uint32_t offset = (uint32_t)addr;
@@ -127,6 +139,10 @@ uint16_t eeprom_read_word(const uint16_t *addr)
127 return *(uint16_t *)(&FlexRAM[offset]); 139 return *(uint16_t *)(&FlexRAM[offset]);
128} 140}
129 141
142/** \brief eeprom read dword
143 *
144 * FIXME: needs doc
145 */
130uint32_t eeprom_read_dword(const uint32_t *addr) 146uint32_t eeprom_read_dword(const uint32_t *addr)
131{ 147{
132 uint32_t offset = (uint32_t)addr; 148 uint32_t offset = (uint32_t)addr;
@@ -135,6 +151,10 @@ uint32_t eeprom_read_dword(const uint32_t *addr)
135 return *(uint32_t *)(&FlexRAM[offset]); 151 return *(uint32_t *)(&FlexRAM[offset]);
136} 152}
137 153
154/** \brief eeprom read block
155 *
156 * FIXME: needs doc
157 */
138void eeprom_read_block(void *buf, const void *addr, uint32_t len) 158void eeprom_read_block(void *buf, const void *addr, uint32_t len)
139{ 159{
140 uint32_t offset = (uint32_t)addr; 160 uint32_t offset = (uint32_t)addr;
@@ -148,11 +168,19 @@ void eeprom_read_block(void *buf, const void *addr, uint32_t len)
148 } 168 }
149} 169}
150 170
171/** \brief eeprom is ready
172 *
173 * FIXME: needs doc
174 */
151int eeprom_is_ready(void) 175int eeprom_is_ready(void)
152{ 176{
153 return (FTFL->FCNFG & FTFL_FCNFG_EEERDY) ? 1 : 0; 177 return (FTFL->FCNFG & FTFL_FCNFG_EEERDY) ? 1 : 0;
154} 178}
155 179
180/** \brief flexram wait
181 *
182 * FIXME: needs doc
183 */
156static void flexram_wait(void) 184static void flexram_wait(void)
157{ 185{
158 while (!(FTFL->FCNFG & FTFL_FCNFG_EEERDY)) { 186 while (!(FTFL->FCNFG & FTFL_FCNFG_EEERDY)) {
@@ -160,6 +188,10 @@ static void flexram_wait(void)
160 } 188 }
161} 189}
162 190
191/** \brief eeprom_write_byte
192 *
193 * FIXME: needs doc
194 */
163void eeprom_write_byte(uint8_t *addr, uint8_t value) 195void eeprom_write_byte(uint8_t *addr, uint8_t value)
164{ 196{
165 uint32_t offset = (uint32_t)addr; 197 uint32_t offset = (uint32_t)addr;
@@ -172,6 +204,10 @@ void eeprom_write_byte(uint8_t *addr, uint8_t value)
172 } 204 }
173} 205}
174 206
207/** \brief eeprom write word
208 *
209 * FIXME: needs doc
210 */
175void eeprom_write_word(uint16_t *addr, uint16_t value) 211void eeprom_write_word(uint16_t *addr, uint16_t value)
176{ 212{
177 uint32_t offset = (uint32_t)addr; 213 uint32_t offset = (uint32_t)addr;
@@ -199,6 +235,10 @@ void eeprom_write_word(uint16_t *addr, uint16_t value)
199#endif 235#endif
200} 236}
201 237
238/** \brief eeprom write dword
239 *
240 * FIXME: needs doc
241 */
202void eeprom_write_dword(uint32_t *addr, uint32_t value) 242void eeprom_write_dword(uint32_t *addr, uint32_t value)
203{ 243{
204 uint32_t offset = (uint32_t)addr; 244 uint32_t offset = (uint32_t)addr;
@@ -242,6 +282,10 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value)
242#endif 282#endif
243} 283}
244 284
285/** \brief eeprom write block
286 *
287 * FIXME: needs doc
288 */
245void eeprom_write_block(const void *buf, void *addr, uint32_t len) 289void eeprom_write_block(const void *buf, void *addr, uint32_t len)
246{ 290{
247 uint32_t offset = (uint32_t)addr; 291 uint32_t offset = (uint32_t)addr;
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index 7c3c75387..32ef773e2 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -12,11 +12,19 @@
12#include "suspend.h" 12#include "suspend.h"
13#include "wait.h" 13#include "wait.h"
14 14
15/** \brief suspend idle
16 *
17 * FIXME: needs doc
18 */
15void suspend_idle(uint8_t time) { 19void suspend_idle(uint8_t time) {
16 // TODO: this is not used anywhere - what units is 'time' in? 20 // TODO: this is not used anywhere - what units is 'time' in?
17 wait_ms(time); 21 wait_ms(time);
18} 22}
19 23
24/** \brief suspend power down
25 *
26 * FIXME: needs doc
27 */
20void suspend_power_down(void) { 28void suspend_power_down(void) {
21 // TODO: figure out what to power down and how 29 // TODO: figure out what to power down and how
22 // shouldn't power down TPM/FTM if we want a breathing LED 30 // shouldn't power down TPM/FTM if we want a breathing LED
@@ -28,6 +36,10 @@ void suspend_power_down(void) {
28 wait_ms(17); 36 wait_ms(17);
29} 37}
30 38
39/** \brief suspend wakeup condition
40 *
41 * FIXME: needs doc
42 */
31__attribute__ ((weak)) void matrix_power_up(void) {} 43__attribute__ ((weak)) void matrix_power_up(void) {}
32__attribute__ ((weak)) void matrix_power_down(void) {} 44__attribute__ ((weak)) void matrix_power_down(void) {}
33bool suspend_wakeup_condition(void) 45bool suspend_wakeup_condition(void)
@@ -41,7 +53,11 @@ bool suspend_wakeup_condition(void)
41 return false; 53 return false;
42} 54}
43 55
44// run immediately after wakeup 56/** \brief suspend wakeup condition
57 *
58 * run immediately after wakeup
59 * FIXME: needs doc
60 */
45void suspend_wakeup_init(void) 61void suspend_wakeup_init(void)
46{ 62{
47 // clear keyboard state 63 // clear keyboard state