diff --git a/IO.cpp b/IO.cpp index 8d10c89..a009403 100644 --- a/IO.cpp +++ b/IO.cpp @@ -547,6 +547,8 @@ uint32_t IO::getWatchdog() void IO::selfTest() { + #define FLASH_DELAY 125 + bool ledValue = false; for (uint8_t i = 0; i < 6; i++) { @@ -560,7 +562,12 @@ void IO::selfTest() setP25Int(ledValue); setNXDNInt(ledValue); - delayInt(250); + #if defined(STM32F4_DVMV1) + setFMInt(ledValue); + setPTTLEDInt(ledValue); + #endif + + delayInt(FLASH_DELAY); } // blinkin lights @@ -569,71 +576,65 @@ void IO::selfTest() setDMRInt(false); setP25Int(false); setNXDNInt(false); - delayInt(250); + #if defined(STM32F4_DVMV1) + setFMInt(false); + setPTTLEDInt(false); + #endif + delayInt(FLASH_DELAY); setLEDInt(true); - setCOSInt(false); - setDMRInt(false); - setP25Int(false); - delayInt(250); + delayInt(FLASH_DELAY); setLEDInt(false); setCOSInt(true); - setDMRInt(false); - setP25Int(false); - delayInt(250); + delayInt(FLASH_DELAY); - setLEDInt(false); setCOSInt(false); setDMRInt(true); - setP25Int(false); - delayInt(250); + delayInt(FLASH_DELAY); - setLEDInt(false); - setCOSInt(false); setDMRInt(false); setP25Int(true); - delayInt(250); + delayInt(FLASH_DELAY); - setLEDInt(false); - setCOSInt(false); - setDMRInt(false); setP25Int(false); setNXDNInt(true); - delayInt(250); + delayInt(FLASH_DELAY); - setLEDInt(false); - setCOSInt(false); - setDMRInt(false); - setP25Int(true); + #if defined(STM32F4_DVMV1) setNXDNInt(false); - delayInt(250); + setFMInt(true); + delayInt(FLASH_DELAY); + + setFMInt(false); + setPTTLEDInt(true); + delayInt(FLASH_DELAY); + + setPTTLEDInt(false); + setFMInt(true); + delayInt(FLASH_DELAY); + + setFMInt(false); + setNXDNInt(true); + delayInt(FLASH_DELAY); + #endif - setLEDInt(false); - setCOSInt(false); - setDMRInt(true); - setP25Int(false); setNXDNInt(false); - delayInt(250); + setP25Int(true); + delayInt(FLASH_DELAY); - setLEDInt(false); - setCOSInt(true); - setDMRInt(false); setP25Int(false); - setNXDNInt(false); - delayInt(250); + setDMRInt(true); + delayInt(FLASH_DELAY); - setLEDInt(true); - setCOSInt(false); setDMRInt(false); - setP25Int(false); - setNXDNInt(false); - delayInt(250); + setCOSInt(true); + delayInt(FLASH_DELAY); - setLEDInt(false); setCOSInt(false); - setDMRInt(false); - setP25Int(false); - setNXDNInt(false); - delayInt(250); + setLEDInt(true); + delayInt(FLASH_DELAY); + + setLEDInt(false); + delayInt(FLASH_DELAY); } diff --git a/IO.h b/IO.h index c0a4ece..2ce0e7a 100644 --- a/IO.h +++ b/IO.h @@ -317,6 +317,14 @@ class DSP_FW_API IO { */ void setNXDNInt(bool on); + #if defined(STM32F4_DVMV1) + + void setFMInt(bool on); + + void setPTTLEDInt(bool on); + + #endif + /** * @brief * @param dly diff --git a/IOSTM.cpp b/IOSTM.cpp index 80b5d28..395de3f 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -654,6 +654,23 @@ void IO::initInt() GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_Init(PORT_NXDN, &GPIO_InitStruct); + // DVM-V1 LEDs + #if defined(STM32F4_DVMV1) + + // FM pin (never actually used since we don't do FM) + RCC_AHB1PeriphClockCmd(RCC_Per_FM, ENABLE); + GPIO_InitStruct.GPIO_Pin = PIN_FM; + GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; + GPIO_Init(PORT_FM, &GPIO_InitStruct); + + // PTT LED pin (separate from the actual PTT pin for ESD reasons) + RCC_AHB1PeriphClockCmd(RCC_Per_PTTLED, ENABLE); + GPIO_InitStruct.GPIO_Pin = PIN_PTTLED; + GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; + GPIO_Init(PORT_PTTLED, &GPIO_InitStruct); + + #endif + #if SPI_ENABLED // Init SPI Clock SPI_APB_CLK_INIT(SPI_APB_CLK, ENABLE); @@ -883,6 +900,10 @@ void IO::setLEDInt(bool on) void IO::setPTTInt(bool on) { GPIO_WriteBit(PORT_PTT, PIN_PTT, on ? Bit_SET : Bit_RESET); + #if defined(STM32F4_DVMV1) + // We tie the PTT LED to PTT on the V1 + setPTTLEDInt(on); + #endif } /* */ @@ -915,6 +936,20 @@ void IO::setNXDNInt(bool on) /* */ +#if defined(STM32F4_DVMV1) + +void IO::setFMInt(bool on) +{ + GPIO_WriteBit(PORT_FM, PIN_FM, on ? Bit_SET : Bit_RESET); +} + +void IO::setPTTLEDInt(bool on) +{ + GPIO_WriteBit(PORT_PTTLED, PIN_PTTLED, on ? Bit_SET : Bit_RESET); +} + +#endif + void IO::delayInt(unsigned int dly) { unsigned int loopsPerMillisecond = (SystemCoreClock / 1000) / 3;