diff --git a/ADF7021.h b/ADF7021.h index cb355db..81fe166 100644 --- a/ADF7021.h +++ b/ADF7021.h @@ -2,6 +2,9 @@ * Copyright (C) 2016 by Jim McLaughlin KI6ZUM * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * + * Some of the code is based on work of Guus Van Dooren PE1PLM: + * https://github.com/ki6zum/gmsk-dstar/blob/master/firmware/dvmega/dvmega.ino + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/BitRB.cpp b/BitRB.cpp index 8faee51..891d3dc 100644 --- a/BitRB.cpp +++ b/BitRB.cpp @@ -1,6 +1,7 @@ /* TX fifo control - Copyright (C) KI6ZUM 2015 Copyright (C) 2015,2016 by Jonathan Naylor G4KLX +Copyright (C) 2016, 2017 by Andy Uribe CA6JAU This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public diff --git a/BitRB.h b/BitRB.h index 0a9c952..3b191b2 100644 --- a/BitRB.h +++ b/BitRB.h @@ -1,7 +1,8 @@ /* Serial fifo control - Copyright (C) KI6ZUM 2015 Copyright (C) 2015,2016 by Jonathan Naylor G4KLX - +Copyright (C) 2016, 2017 by Andy Uribe CA6JAU + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/Config.h b/Config.h index dd726db..8201462 100644 --- a/Config.h +++ b/Config.h @@ -19,11 +19,14 @@ #if !defined(CONFIG_H) #define CONFIG_H +// Enable ADF7021 support: #define ADF7021 +// Host communication selection: //#define STM32_USART1_HOST #define STM32_USB_HOST -//#define SERIAL_REPEATER +// Enable Nextion LCD serial port repeater: +#define SERIAL_REPEATER #endif diff --git a/DMRDMORX.cpp b/DMRDMORX.cpp index abbec8c..ea942de 100644 --- a/DMRDMORX.cpp +++ b/DMRDMORX.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/DMRDMORX.h b/DMRDMORX.h index 8afcb91..0a549f3 100644 --- a/DMRDMORX.h +++ b/DMRDMORX.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/DMRDMOTX.cpp b/DMRDMOTX.cpp index 093b660..6f77627 100644 --- a/DMRDMOTX.cpp +++ b/DMRDMOTX.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2009-2016 by Jonathan Naylor G4KLX * Copyright (C) 2016 by Colin Durbridge G4EML + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/DMRDMOTX.h b/DMRDMOTX.h index 84234af..ce8459a 100644 --- a/DMRDMOTX.h +++ b/DMRDMOTX.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2016 by Colin Durbridge G4EML + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/DStarRX.cpp b/DStarRX.cpp index 56ca601..04e1ae3 100644 --- a/DStarRX.cpp +++ b/DStarRX.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/DStarRX.h b/DStarRX.h index 2490c37..34404fd 100644 --- a/DStarRX.h +++ b/DStarRX.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/DStarTX.cpp b/DStarTX.cpp index d4fda70..e5670f6 100644 --- a/DStarTX.cpp +++ b/DStarTX.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/DStarTX.h b/DStarTX.h index 5f3957f..ee7666c 100644 --- a/DStarTX.h +++ b/DStarTX.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/Globals.h b/Globals.h index 1e01060..bf3b072 100644 --- a/Globals.h +++ b/Globals.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/IO.cpp b/IO.cpp index 79541ff..d2a1eed 100644 --- a/IO.cpp +++ b/IO.cpp @@ -78,6 +78,9 @@ void CIO::process() void CIO::interrupt() { uint8_t bit = 0; + + if (!m_started) + return; if(m_tx) { m_txBuffer.get(bit); @@ -98,6 +101,23 @@ void CIO::interrupt() } +void CIO::start() +{ + if (m_started) + return; + + ifConf(); + + delay_rx(); + setRX(); + + startInt(); + + m_started = true; + + setMode(); +} + void CIO::write(uint8_t* data, uint16_t length) { if (!m_started) diff --git a/IO.h b/IO.h index 3f66c61..c8fdd8c 100644 --- a/IO.h +++ b/IO.h @@ -71,7 +71,8 @@ public: void setTX(); void setRX(); void ifConf(); - void ifInit(); + void start(); + void startInt(); // Misc functions void dlybit(void); diff --git a/IOArduino.cpp b/IOArduino.cpp index fdd72ff..381a467 100644 --- a/IOArduino.cpp +++ b/IOArduino.cpp @@ -99,21 +99,16 @@ void CIO::Init() pinMode(PIN_P25_LED, OUTPUT); pinMode(PIN_PTT_LED, OUTPUT); pinMode(PIN_COS_LED, OUTPUT); + } -void CIO::ifInit() +void CIO::startInt() { - m_started = true; - #if defined (__STM32F1__) attachInterrupt(PIN_TXRX_CLK, EXT_IRQHandler, RISING); #else attachInterrupt(digitalPinToInterrupt(PIN_TXRX_CLK), EXT_IRQHandler, RISING); #endif - - ifConf(); - delay_rx();; - setRX(); } void CIO::SCLK_pin(bool on) diff --git a/IOSTM.cpp b/IOSTM.cpp index 2af5d45..e6e95c5 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -92,7 +92,7 @@ void CIO::dlybit(void) } void CIO::Init() -{ +{ // USB Conf IO: RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); @@ -101,6 +101,8 @@ void CIO::Init() RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); + EXTI_InitTypeDef EXTI_InitStructure; + GPIO_InitTypeDef GPIO_InitStruct; GPIO_StructInit(&GPIO_InitStruct); @@ -201,14 +203,6 @@ void CIO::Init() GPIO_InitStruct.GPIO_Pin = PIN_COS_LED; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(PORT_COS_LED, &GPIO_InitStruct); -} - -void CIO::ifInit() -{ - EXTI_InitTypeDef EXTI_InitStructure; - NVIC_InitTypeDef NVIC_InitStructure; - - m_started = true; // Connect EXTI15 Line GPIO_EXTILineConfig(PORT_TXRX_CLK_INT, PIN_TXRX_CLK_INT); @@ -220,16 +214,18 @@ void CIO::ifInit() EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); +} + +void CIO::startInt() +{ + NVIC_InitTypeDef NVIC_InitStructure; + // Enable and set EXTI15 Interrupt NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); - - ifConf(); - delay_rx();; - setRX(); } void CIO::SCLK_pin(bool on) diff --git a/MMDVM_HS.cpp b/MMDVM_HS.cpp index ccf2fef..2dcdae0 100644 --- a/MMDVM_HS.cpp +++ b/MMDVM_HS.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2016 by Mathis Schmieder DB9MAT * Copyright (C) 2016 by Colin Durbridge G4EML + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/MMDVM_HS.ino b/MMDVM_HS.ino index 74214ff..9bd112b 100644 --- a/MMDVM_HS.ino +++ b/MMDVM_HS.ino @@ -1,6 +1,7 @@ /* * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2016 by Colin Durbridge G4EML + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/P25RX.cpp b/P25RX.cpp index 0739b61..77c1343 100644 --- a/P25RX.cpp +++ b/P25RX.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/P25RX.h b/P25RX.h index 514ad95..611b18d 100644 --- a/P25RX.h +++ b/P25RX.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/P25TX.cpp b/P25TX.cpp index 781c207..b1bff2e 100644 --- a/P25TX.cpp +++ b/P25TX.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/P25TX.h b/P25TX.h index 1f239ce..bd14c7c 100644 --- a/P25TX.h +++ b/P25TX.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/SerialArduino.cpp b/SerialArduino.cpp old mode 100755 new mode 100644 index f3334f2..c2c4c8d --- a/SerialArduino.cpp +++ b/SerialArduino.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,14 +28,17 @@ void CSerialPort::beginInt(uint8_t n, int speed) { switch (n) { case 1U: + #if defined(STM32_USART1_HOST) && defined(__STM32F1__) + Serial1.begin(speed); + #else Serial.begin(speed); + #endif break; -/* case 2U: + case 3U: + #if defined(SERIAL_REPEATER) && defined(__STM32F1__) Serial2.begin(speed); + #endif break; - case 3U: - Serial3.begin(speed); - break;*/ default: break; } @@ -44,11 +48,15 @@ int CSerialPort::availableInt(uint8_t n) { switch (n) { case 1U: + #if defined(STM32_USART1_HOST) && defined(__STM32F1__) + return Serial1.available(); + #else return Serial.available(); -/* case 2U: - return Serial2.available(); + #endif case 3U: - return Serial3.available();*/ + #if defined(SERIAL_REPEATER) && defined(__STM32F1__) + return Serial2.available(); + #endif default: return false; } @@ -58,11 +66,15 @@ uint8_t CSerialPort::readInt(uint8_t n) { switch (n) { case 1U: + #if defined(STM32_USART1_HOST) && defined(__STM32F1__) + return Serial1.read(); + #else return Serial.read(); -/* case 2U: - return Serial2.read(); + #endif case 3U: - return Serial3.read();*/ + #if defined(SERIAL_REPEATER) && defined(__STM32F1__) + return Serial2.read(); + #endif default: return 0U; } @@ -72,20 +84,20 @@ void CSerialPort::writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool { switch (n) { case 1U: + #if defined(STM32_USART1_HOST) && defined(__STM32F1__) + Serial1.write(data, length); + break; + #else Serial.write(data, length); if (flush) Serial.flush(); break; -/* case 2U: + #endif + case 3U: + #if defined(SERIAL_REPEATER) && defined(__STM32F1__) Serial2.write(data, length); - if (flush) - Serial2.flush(); break; - case 3U: - Serial3.write(data, length); - if (flush) - Serial3.flush(); - break;*/ + #endif default: break; } diff --git a/SerialPort.cpp b/SerialPort.cpp index 65b2e07..e240250 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2013,2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2016 by Colin Durbridge G4EML + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -227,7 +228,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length) dmrDMORX.setColorCode(colorCode); - io.ifInit(); + io.start(); return 0U; } diff --git a/SerialSTM.cpp b/SerialSTM.cpp index 2a54646..75f9309 100644 --- a/SerialSTM.cpp +++ b/SerialSTM.cpp @@ -41,11 +41,11 @@ USART2 - TXD PA2 - RXD PA3 */ -#if defined(STM32_USART1_HOST) - #define TX_SERIAL_FIFO_SIZE 256U #define RX_SERIAL_FIFO_SIZE 256U +#if defined(STM32_USART1_HOST) + extern "C" { void USART1_IRQHandler(); } @@ -174,8 +174,8 @@ void InitUSART1(int speed) // USART IRQ init NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_Init(&NVIC_InitStructure); // Configure USART as alternate function @@ -363,8 +363,8 @@ void InitUSART2(int speed) // USART IRQ init NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_Init(&NVIC_InitStructure); // Configure USART as alternate function @@ -498,7 +498,7 @@ void CSerialPort::writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool usbserial.flush(); break; #endif - #if defined(SERIAL_REPEATER) + #if defined(SERIAL_REPEATER) case 3U: WriteUSART2(data, length); if (flush) diff --git a/YSFRX.cpp b/YSFRX.cpp index a3e9a46..5079cd4 100644 --- a/YSFRX.cpp +++ b/YSFRX.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/YSFRX.h b/YSFRX.h index 51c95fa..0cee0af 100644 --- a/YSFRX.h +++ b/YSFRX.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/YSFTX.cpp b/YSFTX.cpp index 8cbb58b..92829c1 100644 --- a/YSFTX.cpp +++ b/YSFTX.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2016 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/YSFTX.h b/YSFTX.h index 21bd1a6..96f958f 100644 --- a/YSFTX.h +++ b/YSFTX.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by