Skip to content

Commit

Permalink
fix(rp2040): fix incompatible code
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Oct 31, 2023
1 parent d8e703d commit 4721dad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions boards/rp2040/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ usbd-hid = "0.6.1"
# avoid having to use --allow-multiple-definition linker flag
# on macOS with Apple Silicon at least
default = ["rp-pico/disable-intrinsics"]

[[bin]]
name = "rmk-rp2040"
test = false
bench = false
8 changes: 6 additions & 2 deletions boards/rp2040/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ mod app {
use defmt::*;
use embedded_hal::digital::v2::{OutputPin, ToggleableOutputPin};
use rmk::{
config::KEYBOARD_CONFIG, initialize_keyboard_and_usb_device, keyboard::Keyboard,
usb::KeyboardUsbDevice,
config::KEYBOARD_CONFIG, eeprom::EepromStorageConfig, flash::EmptyFlashWrapper,
initialize_keyboard_and_usb_device, keyboard::Keyboard, usb::KeyboardUsbDevice,
};
use rp_pico::{
hal::{
Expand All @@ -41,6 +41,8 @@ mod app {
keyboard: Keyboard<
Pin<DynPinId, FunctionSio<SioInput>, PullDown>,
Pin<DynPinId, FunctionSio<SioOutput>, PullDown>,
EmptyFlashWrapper,
0,
4,
3,
2,
Expand Down Expand Up @@ -122,6 +124,8 @@ mod app {
let (keyboard, usb_device) = initialize_keyboard_and_usb_device(
unsafe { USB_BUS.as_ref().unwrap() },
&KEYBOARD_CONFIG,
None,
EepromStorageConfig::default(),
input_pins,
output_pins,
crate::keymap::KEYMAP,
Expand Down
11 changes: 7 additions & 4 deletions rmk/src/eeprom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl EepromRecord {
}

/// Configuration of eeprom's backend storage.
#[derive(Default)]
pub struct EepromStorageConfig {
/// The start address in the backend storage.
pub start_addr: u32,
Expand Down Expand Up @@ -298,10 +299,12 @@ impl<F: NorFlash, const EEPROM_SIZE: usize> Eeprom<F, EEPROM_SIZE> {

fn consolidate_records(&mut self) {
// Lock the eeprom when reconstructing
match self.lock.compare_exchange(false, true, SeqCst, SeqCst) {
Ok(_) => (),
Err(_) => return,
};
// Some targets doesn't support CAS operation, so we cannot use `self.lock.compare_exchange`
let locked = self.lock.load(SeqCst);
if locked {
return;
}
self.lock.store(true, SeqCst);

// Erase the flash page first
match self.storage.erase(
Expand Down

0 comments on commit 4721dad

Please sign in to comment.