diff --git a/src/config/config.h b/src/config/config.h index 2df9597..ff33a59 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -2,6 +2,10 @@ #include #include "axis.h" +/// Define Debug mode to add additional serial output + +//#define DEBUG_FINDA + /// Wrangler for assorted compile-time configuration and constants. namespace config { diff --git a/src/main.cpp b/src/main.cpp index 30794ae..2c8e415 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -171,6 +171,15 @@ void ReportCommandAccepted(const mp::RequestMsg &rq, mp::ResponseMsgParamCodes s } void ReportFINDA(const mp::RequestMsg &rq) { + #ifdef DEBUG_FINDA + using namespace hal; + hu::usart1.puts("FINDA:"); + if (hal::gpio::ReadPin(FINDA_PIN) == hal::gpio::Level::high) { + hu::usart1.puts(" TIRGGERED\n"); + } else { + hu::usart1.puts(" NOT TRIGGERED\n"); + } + #endif //DEBUG_FINDA uint8_t rsp[maxMsgLen]; uint8_t len = protocol.EncodeResponseReadFINDA(rq, mf::finda.Pressed(), rsp); WriteToUSART(rsp, len); diff --git a/src/modules/finda.cpp b/src/modules/finda.cpp index f289f91..47dd1cc 100644 --- a/src/modules/finda.cpp +++ b/src/modules/finda.cpp @@ -1,6 +1,7 @@ #include "finda.h" -#include "../hal/adc.h" #include "timebase.h" +#include "../hal/gpio.h" +#include "../pins.h" namespace modules { namespace finda { @@ -8,7 +9,8 @@ namespace finda { FINDA finda; void FINDA::Step() { - debounce::Debouncer::Step(mt::timebase.Millis(), hal::adc::ReadADC(config::findaADCIndex) > config::findaADCDecisionLevel); + + debounce::Debouncer::Step(mt::timebase.Millis(), hal::gpio::ReadPin(FINDA_PIN) == hal::gpio::Level::high); } } // namespace finda diff --git a/src/pins.h b/src/pins.h index bc72c3e..7f52c57 100644 --- a/src/pins.h +++ b/src/pins.h @@ -25,3 +25,5 @@ static constexpr hal::gpio::GPIO_pin SELECTOR_STEP_PIN = { GPIOD, 4 }; static constexpr hal::gpio::GPIO_pin IDLER_CS_PIN = { GPIOB, 7 }; static constexpr hal::gpio::GPIO_pin IDLER_SG_PIN = { GPIOF, 0 }; static constexpr hal::gpio::GPIO_pin IDLER_STEP_PIN = { GPIOD, 6 }; + +static constexpr hal::gpio::GPIO_pin FINDA_PIN = { GPIOF, 6 }; /// PF6 A1 ADC6/TDI