Skip to content
Snippets Groups Projects
Commit 8f740492 authored by Samuel Tardieu's avatar Samuel Tardieu
Browse files

Add RESET command

parent b39f3f3a
No related branches found
No related tags found
No related merge requests found
......@@ -125,6 +125,10 @@ Multibyte values are exchanged in little endian format.
duration in 10th of seconds on 1 byte. This cannot be used if the
motor is moving.
** [IMPLEMENTED] 0xE0 Reset (W)
- Reset the device. Used mainly for testing.
** 0xF0-0xF7 Unique device ID (R)
- Unique device ID as found in addresses 0x1FFFF7E8-0x1FFFF7EF
......
......@@ -22,6 +22,7 @@ class Controller:
MOTOR_SPEED = 0x30
ENCODER_TICKS = 0x32
STATUS = 0x36
RESET = 0xE0
def __init__(self, i2cbus=8):
import smbus
......@@ -161,3 +162,7 @@ class Controller:
"""Return the PWM frequency in Hz."""
a, b, c = self._read(self.PWM_FREQUENCY, 3, "BBB")
return a | (b << 8) | (c << 16)
def reset(self):
"""Reset the device. Used mainly for testing."""
self._write(self.RESET, [])
......@@ -60,6 +60,7 @@ const CMD_MOTOR_SHUTDOWN_TIMEOUT: u8 = 0x28;
const CMD_MOTOR_SPEED: u8 = 0x30;
const CMD_ENCODER_TICKS: u8 = 0x32;
const CMD_STATUS: u8 = 0x36;
const CMD_RESET: u8 = 0xe0;
include!(concat!(env!("OUT_DIR"), "/version.rs"));
......@@ -153,6 +154,10 @@ fn process_command(
.push_back(u8::from(motor_control::is_moving()))
.unwrap();
}
[CMD_RESET] => {
defmt::info!("resetting device after receiving the RESET command");
cortex_m::peripheral::SCB::sys_reset();
}
_ => {
defmt::warn!("unknown command or args {:#04x}", command);
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment