From 70e1fd4264482f3e8dbe208ea49414163089eed6 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Mon, 28 Aug 2017 00:43:24 -0300 Subject: [PATCH 1/7] Adding LEDs selftest at start-up --- IO.cpp | 32 ++++++++++++++++++++++++++++++++ IO.h | 4 ++++ IODue.cpp | 5 +++++ IOSTM.cpp | 19 +++++++++++++++++++ IOTeensy.cpp | 7 ++++++- 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/IO.cpp b/IO.cpp index d7a6ec9..16d46fe 100644 --- a/IO.cpp +++ b/IO.cpp @@ -94,6 +94,38 @@ m_lockout(false) m_boxcarFilter.pCoeffs = BOXCAR_FILTER; initInt(); + + selfTest(); +} + +void CIO::selfTest() +{ + bool ledValue = false; + uint32_t ledCount = 0; + uint32_t blinks = 0; + + while(true) { + ledCount++; + delayInt(100); + + if(ledCount >= 2U) { + ledCount = 0U; + ledValue = !ledValue; + + setLEDInt(ledValue); + setPTTInt(ledValue); + setDStarInt(ledValue); + setDMRInt(ledValue); + setYSFInt(ledValue); + setP25Int(ledValue); + setCOSInt(ledValue); + + blinks++; + + if(blinks > 5) + break; + } + } } void CIO::start() diff --git a/IO.h b/IO.h index 6c2fe7d..64fb1d9 100644 --- a/IO.h +++ b/IO.h @@ -53,6 +53,8 @@ public: void resetWatchdog(); uint32_t getWatchdog(); + + void selfTest(); private: bool m_started; @@ -107,6 +109,8 @@ private: void setDMRInt(bool on); void setYSFInt(bool on); void setP25Int(bool on); + + void delayInt(unsigned int dly); }; #endif diff --git a/IODue.cpp b/IODue.cpp index 8d1e034..6eeeb82 100644 --- a/IODue.cpp +++ b/IODue.cpp @@ -226,4 +226,9 @@ void CIO::setP25Int(bool on) digitalWrite(PIN_P25, on ? HIGH : LOW); } +void CIO::delayInt(unsigned int dly) +{ + delay(dly); +} + #endif diff --git a/IOSTM.cpp b/IOSTM.cpp index 3abf820..8082cfb 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -764,4 +764,23 @@ void CIO::setP25Int(bool on) #endif } +void CIO::delayInt(unsigned int dly) +{ + unsigned int loopsPerMillisecond = (SystemCoreClock/1000) / 3; //3 clock cycles per loop + for (; dly > 0; dly--) + { + asm volatile //this routine waits (approximately) one millisecond + ( + "mov r3, %[loopsPerMillisecond] \n\t" //load the initial loop counter + "loop: \n\t" + "subs r3, #1 \n\t" + "bne loop \n\t" + + : //empty output list + : [loopsPerMillisecond] "r" (loopsPerMillisecond) //input to the asm routine + : "r3", "cc" //clobber list + ); + } +} + #endif diff --git a/IOTeensy.cpp b/IOTeensy.cpp index 3f4d9b9..de0651a 100644 --- a/IOTeensy.cpp +++ b/IOTeensy.cpp @@ -210,4 +210,9 @@ void CIO::setP25Int(bool on) digitalWrite(PIN_P25, on ? HIGH : LOW); } -#endif +void CIO::delayInt(unsigned int dly) +{ + delay(dly); +} + +#endif From 595f38b7965b221d029b5027934b2abbeb77c1cd Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 28 Aug 2017 07:48:25 +0200 Subject: [PATCH 2/7] Refactor variable initialization in YSFRX.h --- YSFRX.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YSFRX.h b/YSFRX.h index 556280a..f8abfc2 100644 --- a/YSFRX.h +++ b/YSFRX.h @@ -43,9 +43,9 @@ private: uint16_t m_dataPtr; uint16_t m_startPtr; uint16_t m_endPtr; + uint16_t m_syncPtr; uint16_t m_minSyncPtr; uint16_t m_maxSyncPtr; - uint16_t m_syncPtr; q31_t m_maxCorr; uint16_t m_lostCount; uint8_t m_countdown; From a244b86f36d346528563f16a46fce67ac5b81496 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Mon, 28 Aug 2017 13:49:52 -0300 Subject: [PATCH 3/7] Exclude PTT to avoid trigger the transmitter --- IO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IO.cpp b/IO.cpp index 16d46fe..2536a92 100644 --- a/IO.cpp +++ b/IO.cpp @@ -112,8 +112,8 @@ void CIO::selfTest() ledCount = 0U; ledValue = !ledValue; + // We exclude PTT to avoid trigger the transmitter setLEDInt(ledValue); - setPTTInt(ledValue); setDStarInt(ledValue); setDMRInt(ledValue); setYSFInt(ledValue); From eb4cd221b2e8506e2d81eaaf946c756d4769e639 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Tue, 29 Aug 2017 00:57:52 -0300 Subject: [PATCH 4/7] Changing LEDs sequence --- IO.cpp | 64 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/IO.cpp b/IO.cpp index 2536a92..0de4129 100644 --- a/IO.cpp +++ b/IO.cpp @@ -101,31 +101,53 @@ m_lockout(false) void CIO::selfTest() { bool ledValue = false; - uint32_t ledCount = 0; - uint32_t blinks = 0; - while(true) { - ledCount++; - delayInt(100); + for (uint8_t i = 0; i < 6; i++) { + ledValue = !ledValue; - if(ledCount >= 2U) { - ledCount = 0U; - ledValue = !ledValue; + // We exclude PTT to avoid trigger the transmitter + setLEDInt(ledValue); + setDStarInt(ledValue); + setDMRInt(ledValue); + setYSFInt(ledValue); + setP25Int(ledValue); + setCOSInt(ledValue); - // We exclude PTT to avoid trigger the transmitter - setLEDInt(ledValue); - setDStarInt(ledValue); - setDMRInt(ledValue); - setYSFInt(ledValue); - setP25Int(ledValue); - setCOSInt(ledValue); - - blinks++; - - if(blinks > 5) - break; - } + delayInt(250); } + + setDStarInt(true); + setDMRInt(false); + setYSFInt(false); + setP25Int(false); + + delayInt(500); + + setDStarInt(false); + setDMRInt(true); + setYSFInt(false); + setP25Int(false); + + delayInt(500); + + setDStarInt(false); + setDMRInt(false); + setYSFInt(true); + setP25Int(false); + + delayInt(500); + + setDStarInt(false); + setDMRInt(false); + setYSFInt(false); + setP25Int(true); + + delayInt(500); + + setDStarInt(false); + setDMRInt(false); + setYSFInt(false); + setP25Int(false); } void CIO::start() From a805652f48e04d7c9cbb34031f7913e45a20613d Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Tue, 29 Aug 2017 08:48:20 -0300 Subject: [PATCH 5/7] Change the LED sequence --- IO.cpp | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/IO.cpp b/IO.cpp index 0de4129..c1633db 100644 --- a/IO.cpp +++ b/IO.cpp @@ -121,28 +121,49 @@ void CIO::selfTest() setYSFInt(false); setP25Int(false); - delayInt(500); + delayInt(250); - setDStarInt(false); + setDStarInt(true); setDMRInt(true); setYSFInt(false); setP25Int(false); - delayInt(500); + delayInt(250); - setDStarInt(false); - setDMRInt(false); + setDStarInt(true); + setDMRInt(true); setYSFInt(true); setP25Int(false); - delayInt(500); + delayInt(250); - setDStarInt(false); - setDMRInt(false); - setYSFInt(false); + setDStarInt(true); + setDMRInt(true); + setYSFInt(true); setP25Int(true); - delayInt(500); + delayInt(250); + + setDStarInt(true); + setDMRInt(true); + setYSFInt(true); + setP25Int(false); + + delayInt(250); + + setDStarInt(true); + setDMRInt(true); + setYSFInt(false); + setP25Int(false); + + delayInt(250); + + setDStarInt(true); + setDMRInt(false); + setYSFInt(false); + setP25Int(false); + + delayInt(250); setDStarInt(false); setDMRInt(false); From ea37f67b911002d8fad8482eda2085c07ad08ee7 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Tue, 29 Aug 2017 14:39:16 -0300 Subject: [PATCH 6/7] Adding conditional compilation for LED selftest --- IO.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/IO.cpp b/IO.cpp index c1633db..068a2e1 100644 --- a/IO.cpp +++ b/IO.cpp @@ -107,15 +107,17 @@ void CIO::selfTest() // We exclude PTT to avoid trigger the transmitter setLEDInt(ledValue); + setCOSInt(ledValue); +#if defined(ARDUINO_MODE_PINS) setDStarInt(ledValue); setDMRInt(ledValue); setYSFInt(ledValue); setP25Int(ledValue); - setCOSInt(ledValue); - +#endif delayInt(250); } +#if defined(ARDUINO_MODE_PINS) setDStarInt(true); setDMRInt(false); setYSFInt(false); @@ -169,6 +171,7 @@ void CIO::selfTest() setDMRInt(false); setYSFInt(false); setP25Int(false); +#endif } void CIO::start() From 990bf2a16a8a2775a28263fb0f209a687971fd7d Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Tue, 29 Aug 2017 14:51:20 -0300 Subject: [PATCH 7/7] Fix delay function for F767 --- IOSTM.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/IOSTM.cpp b/IOSTM.cpp index 8082cfb..e2f9b00 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -764,9 +764,16 @@ void CIO::setP25Int(bool on) #endif } +// Simple delay function for STM32 +// Example from: http://thehackerworkshop.com/?p=1209 void CIO::delayInt(unsigned int dly) { - unsigned int loopsPerMillisecond = (SystemCoreClock/1000) / 3; //3 clock cycles per loop +#if defined(STM32F7_NUCLEO) + unsigned int loopsPerMillisecond = (SystemCoreClock/1000); +#else + unsigned int loopsPerMillisecond = (SystemCoreClock/1000) / 3; +#endif + for (; dly > 0; dly--) { asm volatile //this routine waits (approximately) one millisecond