summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Pinot <texitoi@texitoi.eu>2020-08-28 10:05:24 +0200
committerGuillaume Pinot <texitoi@texitoi.eu>2020-08-28 10:05:24 +0200
commitfe2909f2237d56a85154ab64abe020a7d3ba9188 (patch)
treec194a7bd1314e7fe136858d737457dc0a221e000
parent957968bf93a34cf70cf245a9a9e395a2fed018ed (diff)
more functionnal firmware for serial communication (but still doesn't work)
-rw-r--r--README.md8
-rw-r--r--firmware/src/main.rs21
2 files changed, 18 insertions, 11 deletions
diff --git a/README.md b/README.md
index 8080b49..cc3c0b0 100644
--- a/README.md
+++ b/README.md
@@ -42,5 +42,11 @@ To flash using dfu-util, first put the board in dfu mode by pressing
BOOT, pressing and releasing RESET and releasing BOOT. Then:
```shell
-dfu-util -d 0483:df11 -a 0 -s 0x08000000:force:unprotect:leave -D keyseebee.bin
+dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D keyseebee.bin
+```
+
+The fist time, if the write fail, your flash must protected. To unprotect:
+
+```shell
+dfu-util -d 0483:df11 -a 0 -s 0x08000000:force:unprotect -D keyseebee.bin
```
diff --git a/firmware/src/main.rs b/firmware/src/main.rs
index b97b72a..d16eb71 100644
--- a/firmware/src/main.rs
+++ b/firmware/src/main.rs
@@ -73,12 +73,12 @@ const CUT: Action = m(&[LShift, Delete]);
const COPY: Action = m(&[LCtrl, Insert]);
const PASTE: Action = m(&[LShift, Insert]);
const L2_ENTER: Action = HoldTap {
- timeout: 200,
+ timeout: 160,
hold: &l(2),
tap: &k(Enter),
};
const L1_SP: Action = HoldTap {
- timeout: 200,
+ timeout: 160,
hold: &l(1),
tap: &k(Space),
};
@@ -173,11 +173,12 @@ const APP: () = {
};
let (pa9, pa10) = (gpioa.pa9, gpioa.pa10);
- let (tx, rx) = cortex_m::interrupt::free(move |cs| {
+ let pins = cortex_m::interrupt::free(move |cs| {
(pa9.into_alternate_af1(cs), pa10.into_alternate_af1(cs))
});
- let (tx, rx) =
- serial::Serial::usart1(c.device.USART1, (tx, rx), 115_200.bps(), &mut rcc).split();
+ let mut serial = serial::Serial::usart1(c.device.USART1, pins, 115_200.bps(), &mut rcc);
+ serial.listen(serial::Event::Rxne);
+ let (tx, rx) = serial.split();
let pa15 = gpioa.pa15;
let matrix = cortex_m::interrupt::free(move |cs| {
@@ -264,11 +265,11 @@ const APP: () = {
#[task(binds = USART1, priority = 1, spawn = [handle_report], resources = [layout, rx])]
fn rx(mut c: rx::Context) {
static mut BUF: [u8; 4] = [0; 4];
- for b in &mut BUF[..] {
- *b = match nb::block!(c.resources.rx.read()) {
- Ok(o) => o,
- Err(_) => 255,
- };
+ while BUF[3] != b'\n' {
+ if let Ok(b) = nb::block!(c.resources.rx.read()) {
+ BUF.rotate_left(1);
+ BUF[3] = b;
+ }
}
if let Ok(event) = de(&BUF[..]) {
c.spawn