Revert "Fix parity calculation"

This reverts commit 27b3c69e8e.
This commit is contained in:
Unknown
2020-01-01 19:47:27 -05:00
parent 27b3c69e8e
commit bb31f042da
4 changed files with 11 additions and 17 deletions
+6 -2
View File
@@ -366,7 +366,7 @@ uint8_t parity(uint16_t v){
v ^= v >> 4;
v ^= v >> 2;
v ^= v >> 1;
return (~v) & 1;
return v & 1;
}
void Encoder::abs_spi_cb(){
HAL_GPIO_WritePin(abs_spi_cs_port_, abs_spi_cs_pin_, GPIO_PIN_SET);
@@ -379,7 +379,11 @@ void Encoder::abs_spi_cb(){
if (parity_calc == parity_bit) {
pos_abs_ = rawVal & 0x3FFF;
abs_spi_pos_updated_ = true;
// We are going to ignore values all high or low
// This might happen in normal operation, but its unlikely
// The filter will handle these cases
if (pos_abs_ != 0 && pos_abs_ != 0x3FFF)
abs_spi_pos_updated_ = true;
}
} break;
case MODE_SPI_ABS_AEAT: {
+3 -6
View File
@@ -295,7 +295,7 @@ TEST_SUITE("vel_ramp") {
v ^= v >> 4;
v ^= v >> 2;
v ^= v >> 1;
return (~v) & 1;
return v & 1;
}
TEST_CASE("Blah") {
@@ -321,10 +321,7 @@ TEST_SUITE("vel_ramp") {
}
TEST_CASE("Parity") {
CHECK(parity(0x0DDF & 0x7FFF) == 1);
CHECK(parity(0x8DDF & 0x7FFF) == 1);
CHECK(parity(0x5BFF & 0x7FFF) == 0);
CHECK(parity(0x0 & 0x7FFF) == 1);
CHECK(__builtin_parity(0x5BFF & 0x7FFF) == 1);
CHECK(parity(0x0DDF) == 0);
CHECK(parity(0x8DDF) == 1);
}
}
+1 -1
View File
@@ -191,6 +191,6 @@ build{
if tup.getconfig('DOCTEST') == 'true' then
TEST_INCLUDES = '-IC:/Tools/doctest/doctest'
tup.frule{inputs='Tests/test_runner.cpp', command='g++ -O3 -std=gnu++17 '..TEST_INCLUDES..' %f -o %o', outputs='Tests/test_runner.exe'}
tup.frule{inputs='Tests/test_runner.cpp', command='g++ -std=gnu++17 '..TEST_INCLUDES..' %f -o %o', outputs='Tests/test_runner.exe'}
tup.frule{inputs='Tests/test_runner.exe', command='%f'}
end
+1 -8
View File
@@ -57,14 +57,7 @@
"fstream": "cpp",
"iomanip": "cpp",
"optional": "cpp",
"sstream": "cpp",
"atomic": "cpp",
"iterator": "cpp",
"memory_resource": "cpp",
"ratio": "cpp",
"string": "cpp",
"mutex": "cpp",
"thread": "cpp"
"sstream": "cpp"
}
}
}