Skip to content

Commit

Permalink
fix(eeprom): fix panic when write size is smaller than 4
Browse files Browse the repository at this point in the history
Signed-off-by: HaoboGu <haobogu@outlook.com>
  • Loading branch information
HaoboGu committed Jan 23, 2024
1 parent 17c0122 commit a5c3eca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rmk/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ impl<
let eeprom = match storage {
Some(s) => {
// TODO: Refactor Eeprom so that we don't need this anymore
let eeprom_storage_config = EepromStorageConfig {
let mut eeprom_storage_config = EepromStorageConfig {
start_addr: (F::ERASE_SIZE * (s.capacity() / F::ERASE_SIZE - 1)) as u32,
storage_size: F::ERASE_SIZE as u32,
page_size: F::WRITE_SIZE as u32,
};
// At least write 4 byte(1 record)
if eeprom_storage_config.page_size < 4 {
eeprom_storage_config.page_size = 4;
}
let e = Eeprom::new(s, eeprom_storage_config, eeconfig, &mut action_map);
// If eeprom is initialized, read keymap from it.
match e {
Expand Down

0 comments on commit a5c3eca

Please sign in to comment.