Skip to content

Commit

Permalink
set up EEPROM on the MK66F18
Browse files Browse the repository at this point in the history
Perhaps we need to reduce CPU speed from 180MHz to 120MHz
for this to work reliably.

related to kinx-project/kint#10
related to kinx-project/kint#8
  • Loading branch information
stapelberg committed Aug 24, 2020
1 parent bb8ab07 commit 1f84198
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tmk_core/common/chibios/eeprom_teensy.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* SOFTWARE.
*/

#if defined(K20x) /* chip selection */
#if defined(K20x) || defined(MK66F18) /* chip selection */
/* Teensy 3.0, 3.1, 3.2; mchck; infinity keyboard */

// The EEPROM is really RAM with a hardware-based backup system to
Expand Down Expand Up @@ -99,9 +99,16 @@ void eeprom_initialize(void) {
if (FTFL->FCNFG & FTFL_FCNFG_RAMRDY) {
// FlexRAM is configured as traditional RAM
// We need to reconfigure for EEPROM usage
FTFL->FCCOB0 = 0x80; // PGMPART = Program Partition Command
FTFL->FCCOB0 = 0x80; // PGMPART = Program Partition Command

# if defined(MK66F18)
# define EEESPLIT 0x10 // best endurance: 0x10 = first 25%
FTFL->FCCOB4 = EEESPLIT | EEESIZE; // EEPROM Size
FTFL->FCCOB5 = 0x05; // 128K dataflash for EEPROM, 128K for data
# else
FTFL->FCCOB4 = EEESIZE; // EEPROM Size
FTFL->FCCOB5 = 0x03; // 0K for Dataflash, 32K for EEPROM backup
# endif
__disable_irq();
// do_flash_cmd() must execute from RAM. Luckily the C syntax is simple...
(*((void (*)(volatile uint8_t *))((uint32_t)do_flash_cmd | 1)))(&(FTFL->FSTAT));
Expand Down

0 comments on commit 1f84198

Please sign in to comment.