Skip to content

Commit

Permalink
Removed some legacy EXP1HCE support
Browse files Browse the repository at this point in the history
  • Loading branch information
dc42 committed Aug 7, 2024
1 parent c817eec commit 70883e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
34 changes: 2 additions & 32 deletions src/BoardType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ constexpr bool LedActiveHigh[] =
constexpr Pin CanResetPins[] =
{
CanResetPin_Tool1LC,
CanResetPin_Exp1HCE,
NoPin, // was CanResetPin_1HCE
NoPin,
CanResetPin_SZP,
CanResetPin_Exp1XD,
Expand Down Expand Up @@ -380,30 +380,6 @@ constexpr uint16_t BoardId2DecisionPoints[] =

static_assert(ARRAY_SIZE(BoardId2DecisionPoints) + 1 == ARRAY_SIZE(BoardType2Fractions));

// Buttons pin ADC handling for EXP1HCE board

constexpr float BothButtonsDownRgnd = (4.7 * 10.0)/(4.7 + 10.0);

constexpr float ButtonsExpectedFractions[] =
{
BothButtonsDownRgnd/(BothButtonsDownRgnd + 10.0),
4.7/(4.7 + 10.0),
10.0/(1.00 + 10.0),
1.0
};

static_assert(IsIncreasing(ButtonsExpectedFractions, ARRAY_SIZE(ButtonsExpectedFractions)));

// Table of halfway points that we use to decide what board type a reading corresponds to
constexpr uint16_t ButtonsDecisionPoints[] =
{
(uint16_t)((ButtonsExpectedFractions[0] + ButtonsExpectedFractions[1]) * (AdcRange/2)),
(uint16_t)((ButtonsExpectedFractions[1] + ButtonsExpectedFractions[2]) * (AdcRange/2)),
(uint16_t)((ButtonsExpectedFractions[2] + ButtonsExpectedFractions[3]) * (AdcRange/2))
};

static_assert(ARRAY_SIZE(ButtonsDecisionPoints) + 1 == ARRAY_SIZE(ButtonsExpectedFractions));

// Function to read a pin and scan a table of decision points to find the corresponding index
static unsigned int ReadAndQuantise(uint8_t chan, const uint16_t decisionPoints[], size_t numDecisionPoints)
{
Expand Down Expand Up @@ -462,14 +438,8 @@ bool IdentifyBoard(CanAddress& defaultAddress, bool& doHardwareReset, bool& useA
defaultAddress = CanId::Exp1XDBoardDefaultAddress;
break;

case BoardId::exp1hce_v0:
case BoardId::exp1hce_v0: // no longer supported
defaultAddress = CanId::Exp1HCLBoardDefaultAddress;

SetPinFunction(ButtonsPin_Exp1HCE, GpioPinFunction::B); // both buttons are on a single analog pin
{
const unsigned int buttonState = ReadAndQuantise(ButtonsAdcChannel_Exp1HCE, ButtonsDecisionPoints, ARRAY_SIZE(ButtonsDecisionPoints));
doHardwareReset = (buttonState == 0);
}
break;

case BoardId::szp:
Expand Down
3 changes: 0 additions & 3 deletions src/Config/SAMC21config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ constexpr Pin BoardTypePin = PortAPin(5);
constexpr uint8_t BoardTypeAdcChannel = 5;
constexpr Pin BoardType2Pin = PortAPin(4); // second board type pin used on some boards
constexpr uint8_t BoardType2AdcChannel = 4;
constexpr Pin ButtonsPin_Exp1HCE = PortAPin(9);
constexpr uint8_t ButtonsAdcChannel_Exp1HCE = 9;

constexpr Pin GlobalTmc22xxEnablePin_Tool1LC = PortBPin(2);
constexpr Pin OutPins_Tool1LC[] = { PortAPin(11), PortAPin(10), PortBPin(11) };
Expand All @@ -38,7 +36,6 @@ constexpr Pin ButtonPins_Tool1LC[] = { PortBPin(22), PortBPin(23) };
constexpr Pin CanResetPin_Tool1LC = PortBPin(22); // first button pin
constexpr Pin CanResetPin_SZP = PortAPin(18);
constexpr Pin CanResetPin_Exp1XD = PortAPin(27);
constexpr Pin CanResetPin_Exp1HCE = NoPin;
constexpr Pin CanResetPin_AteCM = NoPin; // the CAN jumper on the ATECM is connected between AteCmJumperPin and AteCmZeroPin
constexpr Pin CanResetPin_AteIO_v01 = PortAPin(16);
constexpr Pin CanResetPin_AteIO_v02 = PortBPin(11);
Expand Down

0 comments on commit 70883e1

Please sign in to comment.