diff options
| author | Andrew Kannan <andrew.kannan@klaviyo.com> | 2019-01-28 19:40:02 -0500 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-01-28 16:40:02 -0800 |
| commit | 0f507f01696eae0e8fe808d17a19db3f6d9e2ce4 (patch) | |
| tree | 986c78fbb09b6bf5e33df6c28158e6877af64960 /tmk_core/common | |
| parent | d9120412d3d81fc688a7e5346711cf716518dc34 (diff) | |
| download | qmk_firmware-0f507f01696eae0e8fe808d17a19db3f6d9e2ce4.tar.gz qmk_firmware-0f507f01696eae0e8fe808d17a19db3f6d9e2ce4.zip | |
Practice60 RGB and PWM Backlight (#4929)
* Update Practice60 to enable RGB via SPI DMA and use PWM backlight breathing
* Correct stm32f103c8t6 flash size in eeprom definition
* Remove unused files and improve ifdef checks
* Update quantum/rgblight.c
Co-Authored-By: awkannan <andrew.kannan@klaviyo.com>
* Update quantum/rgblight.c
Co-Authored-By: awkannan <andrew.kannan@klaviyo.com>
* EEPROM implementation fix and updated p60 code
* Update define
* Remove dead code
* Update keymap to remove test key
* Update keymap again
Diffstat (limited to 'tmk_core/common')
| -rwxr-xr-x | tmk_core/common/chibios/eeprom_stm32.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tmk_core/common/chibios/eeprom_stm32.c b/tmk_core/common/chibios/eeprom_stm32.c index a15430d67..17d38af6a 100755 --- a/tmk_core/common/chibios/eeprom_stm32.c +++ b/tmk_core/common/chibios/eeprom_stm32.c | |||
| @@ -75,17 +75,13 @@ uint16_t EEPROM_WriteDataByte (uint16_t Address, uint8_t DataByte) { | |||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | // calculate which page is affected (Pagenum1/Pagenum2...PagenumN) | 77 | // calculate which page is affected (Pagenum1/Pagenum2...PagenumN) |
| 78 | page = (FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address)) & 0x00000FFF; | 78 | page = FEE_ADDR_OFFSET(Address) / FEE_PAGE_SIZE; |
| 79 | |||
| 80 | if (page % FEE_PAGE_SIZE) page = page + FEE_PAGE_SIZE; | ||
| 81 | page = (page / FEE_PAGE_SIZE) - 1; | ||
| 82 | 79 | ||
| 83 | // if current data is 0xFF, the byte is empty, just overwrite with the new one | 80 | // if current data is 0xFF, the byte is empty, just overwrite with the new one |
| 84 | if ((*(__IO uint16_t*)(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address))) == FEE_EMPTY_WORD) { | 81 | if ((*(__IO uint16_t*)(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address))) == FEE_EMPTY_WORD) { |
| 85 | 82 | ||
| 86 | FlashStatus = FLASH_ProgramHalfWord(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address), (uint16_t)(0x00FF & DataByte)); | 83 | FlashStatus = FLASH_ProgramHalfWord(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address), (uint16_t)(0x00FF & DataByte)); |
| 87 | } | 84 | } else { |
| 88 | else { | ||
| 89 | 85 | ||
| 90 | // Copy Page to a buffer | 86 | // Copy Page to a buffer |
| 91 | memcpy(DataBuf, (uint8_t*)FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE), FEE_PAGE_SIZE); // !!! Calculate base address for the desired page | 87 | memcpy(DataBuf, (uint8_t*)FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE), FEE_PAGE_SIZE); // !!! Calculate base address for the desired page |
| @@ -96,18 +92,17 @@ uint16_t EEPROM_WriteDataByte (uint16_t Address, uint8_t DataByte) { | |||
| 96 | } | 92 | } |
| 97 | 93 | ||
| 98 | // manipulate desired data byte in temp data array if new byte is differ to the current | 94 | // manipulate desired data byte in temp data array if new byte is differ to the current |
| 99 | DataBuf[FEE_ADDR_OFFSET(Address)] = DataByte; | 95 | DataBuf[FEE_ADDR_OFFSET(Address) % FEE_PAGE_SIZE] = DataByte; |
| 100 | 96 | ||
| 101 | //Erase Page | 97 | //Erase Page |
| 102 | FlashStatus = FLASH_ErasePage(FEE_PAGE_BASE_ADDRESS + page); | 98 | FlashStatus = FLASH_ErasePage(FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE)); |
| 103 | 99 | ||
| 104 | // Write new data (whole page) to flash if data has beed changed | 100 | // Write new data (whole page) to flash if data has been changed |
| 105 | for(i = 0; i < (FEE_PAGE_SIZE / 2); i++) { | 101 | for(i = 0; i < (FEE_PAGE_SIZE / 2); i++) { |
| 106 | if ((__IO uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)]) != 0xFFFF) { | 102 | if ((__IO uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)]) != 0xFFFF) { |
| 107 | FlashStatus = FLASH_ProgramHalfWord((FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE)) + (i * 2), (uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)])); | 103 | FlashStatus = FLASH_ProgramHalfWord((FEE_PAGE_BASE_ADDRESS + (page * FEE_PAGE_SIZE)) + (i * 2), (uint16_t)(0xFF00 | DataBuf[FEE_ADDR_OFFSET(i)])); |
| 108 | } | 104 | } |
| 109 | } | 105 | } |
| 110 | |||
| 111 | } | 106 | } |
| 112 | return FlashStatus; | 107 | return FlashStatus; |
| 113 | } | 108 | } |
| @@ -168,7 +163,7 @@ void eeprom_update_word (uint16_t *Address, uint16_t Value) | |||
| 168 | uint32_t eeprom_read_dword (const uint32_t *Address) | 163 | uint32_t eeprom_read_dword (const uint32_t *Address) |
| 169 | { | 164 | { |
| 170 | const uint16_t p = (const uint32_t) Address; | 165 | const uint16_t p = (const uint32_t) Address; |
| 171 | return EEPROM_ReadDataByte(p) | (EEPROM_ReadDataByte(p+1) << 8) | 166 | return EEPROM_ReadDataByte(p) | (EEPROM_ReadDataByte(p+1) << 8) |
| 172 | | (EEPROM_ReadDataByte(p+2) << 16) | (EEPROM_ReadDataByte(p+3) << 24); | 167 | | (EEPROM_ReadDataByte(p+2) << 16) | (EEPROM_ReadDataByte(p+3) << 24); |
| 173 | } | 168 | } |
| 174 | 169 | ||
