Skip to content

Commit 9bc357e

Browse files
authored
add optional FM & PTT LEDs for DVM-V1, simplify selftest LED pattern logic (#10)
1 parent a65c44a commit 9bc357e

File tree

3 files changed

+88
-44
lines changed

3 files changed

+88
-44
lines changed

IO.cpp

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ uint32_t IO::getWatchdog()
547547

548548
void IO::selfTest()
549549
{
550+
#define FLASH_DELAY 125
551+
550552
bool ledValue = false;
551553

552554
for (uint8_t i = 0; i < 6; i++) {
@@ -560,7 +562,12 @@ void IO::selfTest()
560562
setP25Int(ledValue);
561563
setNXDNInt(ledValue);
562564

563-
delayInt(250);
565+
#if defined(STM32F4_DVMV1)
566+
setFMInt(ledValue);
567+
setPTTLEDInt(ledValue);
568+
#endif
569+
570+
delayInt(FLASH_DELAY);
564571
}
565572

566573
// blinkin lights
@@ -569,71 +576,65 @@ void IO::selfTest()
569576
setDMRInt(false);
570577
setP25Int(false);
571578
setNXDNInt(false);
572-
delayInt(250);
579+
#if defined(STM32F4_DVMV1)
580+
setFMInt(false);
581+
setPTTLEDInt(false);
582+
#endif
583+
delayInt(FLASH_DELAY);
573584

574585
setLEDInt(true);
575-
setCOSInt(false);
576-
setDMRInt(false);
577-
setP25Int(false);
578-
delayInt(250);
586+
delayInt(FLASH_DELAY);
579587

580588
setLEDInt(false);
581589
setCOSInt(true);
582-
setDMRInt(false);
583-
setP25Int(false);
584-
delayInt(250);
590+
delayInt(FLASH_DELAY);
585591

586-
setLEDInt(false);
587592
setCOSInt(false);
588593
setDMRInt(true);
589-
setP25Int(false);
590-
delayInt(250);
594+
delayInt(FLASH_DELAY);
591595

592-
setLEDInt(false);
593-
setCOSInt(false);
594596
setDMRInt(false);
595597
setP25Int(true);
596-
delayInt(250);
598+
delayInt(FLASH_DELAY);
597599

598-
setLEDInt(false);
599-
setCOSInt(false);
600-
setDMRInt(false);
601600
setP25Int(false);
602601
setNXDNInt(true);
603-
delayInt(250);
602+
delayInt(FLASH_DELAY);
604603

605-
setLEDInt(false);
606-
setCOSInt(false);
607-
setDMRInt(false);
608-
setP25Int(true);
604+
#if defined(STM32F4_DVMV1)
609605
setNXDNInt(false);
610-
delayInt(250);
606+
setFMInt(true);
607+
delayInt(FLASH_DELAY);
608+
609+
setFMInt(false);
610+
setPTTLEDInt(true);
611+
delayInt(FLASH_DELAY);
612+
613+
setPTTLEDInt(false);
614+
setFMInt(true);
615+
delayInt(FLASH_DELAY);
616+
617+
setFMInt(false);
618+
setNXDNInt(true);
619+
delayInt(FLASH_DELAY);
620+
#endif
611621

612-
setLEDInt(false);
613-
setCOSInt(false);
614-
setDMRInt(true);
615-
setP25Int(false);
616622
setNXDNInt(false);
617-
delayInt(250);
623+
setP25Int(true);
624+
delayInt(FLASH_DELAY);
618625

619-
setLEDInt(false);
620-
setCOSInt(true);
621-
setDMRInt(false);
622626
setP25Int(false);
623-
setNXDNInt(false);
624-
delayInt(250);
627+
setDMRInt(true);
628+
delayInt(FLASH_DELAY);
625629

626-
setLEDInt(true);
627-
setCOSInt(false);
628630
setDMRInt(false);
629-
setP25Int(false);
630-
setNXDNInt(false);
631-
delayInt(250);
631+
setCOSInt(true);
632+
delayInt(FLASH_DELAY);
632633

633-
setLEDInt(false);
634634
setCOSInt(false);
635-
setDMRInt(false);
636-
setP25Int(false);
637-
setNXDNInt(false);
638-
delayInt(250);
635+
setLEDInt(true);
636+
delayInt(FLASH_DELAY);
637+
638+
setLEDInt(false);
639+
delayInt(FLASH_DELAY);
639640
}

IO.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@ class DSP_FW_API IO {
317317
*/
318318
void setNXDNInt(bool on);
319319

320+
#if defined(STM32F4_DVMV1)
321+
322+
void setFMInt(bool on);
323+
324+
void setPTTLEDInt(bool on);
325+
326+
#endif
327+
320328
/**
321329
* @brief
322330
* @param dly

IOSTM.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,23 @@ void IO::initInt()
654654
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
655655
GPIO_Init(PORT_NXDN, &GPIO_InitStruct);
656656

657+
// DVM-V1 LEDs
658+
#if defined(STM32F4_DVMV1)
659+
660+
// FM pin (never actually used since we don't do FM)
661+
RCC_AHB1PeriphClockCmd(RCC_Per_FM, ENABLE);
662+
GPIO_InitStruct.GPIO_Pin = PIN_FM;
663+
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
664+
GPIO_Init(PORT_FM, &GPIO_InitStruct);
665+
666+
// PTT LED pin (separate from the actual PTT pin for ESD reasons)
667+
RCC_AHB1PeriphClockCmd(RCC_Per_PTTLED, ENABLE);
668+
GPIO_InitStruct.GPIO_Pin = PIN_PTTLED;
669+
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
670+
GPIO_Init(PORT_PTTLED, &GPIO_InitStruct);
671+
672+
#endif
673+
657674
#if SPI_ENABLED
658675
// Init SPI Clock
659676
SPI_APB_CLK_INIT(SPI_APB_CLK, ENABLE);
@@ -883,6 +900,10 @@ void IO::setLEDInt(bool on)
883900
void IO::setPTTInt(bool on)
884901
{
885902
GPIO_WriteBit(PORT_PTT, PIN_PTT, on ? Bit_SET : Bit_RESET);
903+
#if defined(STM32F4_DVMV1)
904+
// We tie the PTT LED to PTT on the V1
905+
setPTTLEDInt(on);
906+
#endif
886907
}
887908

888909
/* */
@@ -915,6 +936,20 @@ void IO::setNXDNInt(bool on)
915936

916937
/* */
917938

939+
#if defined(STM32F4_DVMV1)
940+
941+
void IO::setFMInt(bool on)
942+
{
943+
GPIO_WriteBit(PORT_FM, PIN_FM, on ? Bit_SET : Bit_RESET);
944+
}
945+
946+
void IO::setPTTLEDInt(bool on)
947+
{
948+
GPIO_WriteBit(PORT_PTTLED, PIN_PTTLED, on ? Bit_SET : Bit_RESET);
949+
}
950+
951+
#endif
952+
918953
void IO::delayInt(unsigned int dly)
919954
{
920955
unsigned int loopsPerMillisecond = (SystemCoreClock / 1000) / 3;

0 commit comments

Comments
 (0)