Changes for ZUM dual band board

pull/107/head
Abad-Vera 7 years ago
parent e9b89208cc
commit fbeb5a39b7

@ -1,8 +1,8 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU * Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU
* Copyright (C) 2017 by Danilo DB4PLE * Copyright (C) 2017 by Danilo DB4PLE
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -105,9 +105,9 @@ void CIO::process()
uint8_t bit; uint8_t bit;
uint32_t scantime; uint32_t scantime;
uint8_t control; uint8_t control;
m_ledCount++; m_ledCount++;
if (m_started) { if (m_started) {
// Two seconds timeout // Two seconds timeout
if (m_watchdog >= 19200U) { if (m_watchdog >= 19200U) {
@ -194,7 +194,7 @@ void CIO::process()
if (m_rxBuffer.getData() >= 1U) { if (m_rxBuffer.getData() >= 1U) {
m_rxBuffer.get(bit, control); m_rxBuffer.get(bit, control);
switch (m_modemState_prev) { switch (m_modemState_prev) {
case STATE_DSTAR: case STATE_DSTAR:
dstarRX.databit(bit); dstarRX.databit(bit);
@ -229,9 +229,9 @@ void CIO::process()
} }
void CIO::start() void CIO::start()
{ {
m_TotalModes = 0U; m_TotalModes = 0U;
if(m_dstarEnable) { if(m_dstarEnable) {
m_Modes[m_TotalModes] = STATE_DSTAR; m_Modes[m_TotalModes] = STATE_DSTAR;
m_TotalModes++; m_TotalModes++;
@ -252,7 +252,7 @@ void CIO::start()
m_Modes[m_TotalModes] = STATE_NXDN; m_Modes[m_TotalModes] = STATE_NXDN;
m_TotalModes++; m_TotalModes++;
} }
#if defined(ENABLE_SCAN_MODE) #if defined(ENABLE_SCAN_MODE)
if(m_TotalModes > 1U) if(m_TotalModes > 1U)
m_scanEnable = true; m_scanEnable = true;
@ -267,9 +267,9 @@ void CIO::start()
if (m_started) if (m_started)
return; return;
startInt(); startInt();
m_started = true; m_started = true;
} }
@ -284,7 +284,7 @@ void CIO::write(uint8_t* data, uint16_t length, const uint8_t* control)
else else
m_txBuffer.put(data[i], control[i]); m_txBuffer.put(data[i], control[i]);
} }
// Switch the transmitter on if needed // Switch the transmitter on if needed
if (!m_tx) { if (!m_tx) {
setTX(); setTX();
@ -338,6 +338,24 @@ uint8_t CIO::setFreq(uint32_t frequency_rx, uint32_t frequency_tx, uint8_t rf_po
return 4U; return 4U;
#endif #endif
// Check if we have a single, dualband or duplex board
#if defined (ZUMSPOT_ADF7021)
if (!(io.hasSingleADF7021())) {
// There are two ADF7021s on the board
if (io.isDualBand()) {
// Dual band
if ((frequency_tx <= VHF2_MAX) && (frequency_rx <= VHF2_MAX)) {
// Turn on VHF side
io.setBandVHF(true);
} else if ((frequency_tx >= UHF1_MIN) && (frequency_rx >= UHF1_MIN)) {
// Turn on UHF side
io.setBandVHF(false);
}
}
}
#endif
// Configure frequency // Configure frequency
m_frequency_rx = frequency_rx; m_frequency_rx = frequency_rx;
m_frequency_tx = frequency_tx; m_frequency_tx = frequency_tx;

@ -1,8 +1,8 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU * Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU
* Copyright (C) 2017 by Danilo DB4PLE * Copyright (C) 2017 by Danilo DB4PLE
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -124,6 +124,9 @@ public:
uint32_t getWatchdog(void); uint32_t getWatchdog(void);
void getIntCounter(uint16_t &int1, uint16_t &int2); void getIntCounter(uint16_t &int1, uint16_t &int2);
void selfTest(void); void selfTest(void);
void setBandVHF(bool vhf_on);
bool hasSingleADF7021(void);
bool isDualBand(void);
// RF interface API // RF interface API
void setTX(void); void setTX(void);
@ -164,7 +167,7 @@ private:
uint16_t m_RX_F_divider; uint16_t m_RX_F_divider;
uint8_t m_TX_N_divider; uint8_t m_TX_N_divider;
uint16_t m_TX_F_divider; uint16_t m_TX_F_divider;
bool m_started; bool m_started;
CBitRB m_rxBuffer; CBitRB m_rxBuffer;
CBitRB m_txBuffer; CBitRB m_txBuffer;

@ -1,8 +1,8 @@
/* /*
* Copyright (C) 2016 by Jim McLaughlin KI6ZUM * Copyright (C) 2016 by Jim McLaughlin KI6ZUM
* Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU * Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU
* Copyright (C) 2017 by Danilo DB4PLE * Copyright (C) 2017 by Danilo DB4PLE
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -115,6 +115,15 @@
#define PIN_RXD GPIO_Pin_4 #define PIN_RXD GPIO_Pin_4
#define PORT_RXD GPIOB #define PORT_RXD GPIOB
#define PIN_SGL_DBL GPIO_Pin_12
#define PORT_SGL_DBL GPIOA
#define PIN_DL_DPX GPIO_Pin_15
#define PORT_DL_DPX GPIOC
#define PIN_SET_BAND GPIO_Pin_15
#define PORT_SET_BAND GPIOA
// TXD used in SPI Data mode of ADF7021 // TXD used in SPI Data mode of ADF7021
// TXD is TxRxCLK of ADF7021, standard TX/RX data interface // TXD is TxRxCLK of ADF7021, standard TX/RX data interface
#define PIN_TXD GPIO_Pin_3 #define PIN_TXD GPIO_Pin_3
@ -301,13 +310,37 @@ void CIO::Init()
#endif #endif
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
#if defined(PI_HAT_7021_REV_02) #if defined(PI_HAT_7021_REV_02)
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
#elif defined(ZUMSPOT_ADF7021) || defined(LIBRE_KIT_ADF7021) || defined(MMDVM_HS_HAT_REV12) || defined(MMDVM_HS_DUAL_HAT_REV10) || defined(NANO_HOTSPOT) || defined(NANO_DV_REV11) #elif defined(ZUMSPOT_ADF7021) || defined(LIBRE_KIT_ADF7021) || defined(MMDVM_HS_HAT_REV12) || defined(MMDVM_HS_DUAL_HAT_REV10) || defined(NANO_HOTSPOT) || defined(NANO_DV_REV11)
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
#endif #endif
#if defined(ZUMSPOT_ADF7021)
// Pin defines if the board has a single ADF7021 or double
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_SGL_DBL;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(PORT_SGL_DBL, &GPIO_InitStruct);
// Pin defines if the board is dual band or duplex
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_DL_DPX;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(PORT_DL_DPX, &GPIO_InitStruct);
// Pin will set UHF or VHF
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_SET_BAND;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_SET_BAND, &GPIO_InitStruct);
// TODO: Remove this line
// GPIO_WriteBit(PORT_SET_BAND, PIN_SET_BAND, Bit_RESET);
#endif
#if defined(STM32_USB_HOST)
// Pin PA11,PA12 = LOW, USB Reset // Pin PA11,PA12 = LOW, USB Reset
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
@ -316,6 +349,8 @@ void CIO::Init()
GPIO_WriteBit(GPIOA, GPIO_Pin_11, Bit_RESET); GPIO_WriteBit(GPIOA, GPIO_Pin_11, Bit_RESET);
GPIO_WriteBit(GPIOA, GPIO_Pin_12, Bit_RESET); GPIO_WriteBit(GPIOA, GPIO_Pin_12, Bit_RESET);
#endif
#if defined(LONG_USB_RESET) #if defined(LONG_USB_RESET)
// 10 ms delay // 10 ms delay
delay_us(10000U); delay_us(10000U);
@ -343,7 +378,7 @@ void CIO::Init()
GPIO_InitStruct.GPIO_Pin = PIN_SDATA; GPIO_InitStruct.GPIO_Pin = PIN_SDATA;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_SDATA, &GPIO_InitStruct); GPIO_Init(PORT_SDATA, &GPIO_InitStruct);
// Pin SREAD // Pin SREAD
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_SREAD; GPIO_InitStruct.GPIO_Pin = PIN_SREAD;
@ -355,14 +390,14 @@ void CIO::Init()
GPIO_InitStruct.GPIO_Pin = PIN_SLE; GPIO_InitStruct.GPIO_Pin = PIN_SLE;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_SLE, &GPIO_InitStruct); GPIO_Init(PORT_SLE, &GPIO_InitStruct);
#if defined(DUPLEX) #if defined(DUPLEX)
// Pin SLE2 // Pin SLE2
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_SLE2; GPIO_InitStruct.GPIO_Pin = PIN_SLE2;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_SLE2, &GPIO_InitStruct); GPIO_Init(PORT_SLE2, &GPIO_InitStruct);
// Pin RXD2 // Pin RXD2
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_RXD2; GPIO_InitStruct.GPIO_Pin = PIN_RXD2;
@ -403,7 +438,7 @@ void CIO::Init()
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(PORT_CLKOUT, &GPIO_InitStruct); GPIO_Init(PORT_CLKOUT, &GPIO_InitStruct);
#endif #endif
// Pin LED // Pin LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_LED; GPIO_InitStruct.GPIO_Pin = PIN_LED;
@ -416,37 +451,37 @@ void CIO::Init()
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_DEB, &GPIO_InitStruct); GPIO_Init(PORT_DEB, &GPIO_InitStruct);
// D-Star LED // D-Star LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_DSTAR_LED; GPIO_InitStruct.GPIO_Pin = PIN_DSTAR_LED;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_DSTAR_LED, &GPIO_InitStruct); GPIO_Init(PORT_DSTAR_LED, &GPIO_InitStruct);
// DMR LED // DMR LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_DMR_LED; GPIO_InitStruct.GPIO_Pin = PIN_DMR_LED;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_DMR_LED, &GPIO_InitStruct); GPIO_Init(PORT_DMR_LED, &GPIO_InitStruct);
// YSF LED // YSF LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_YSF_LED; GPIO_InitStruct.GPIO_Pin = PIN_YSF_LED;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_YSF_LED, &GPIO_InitStruct); GPIO_Init(PORT_YSF_LED, &GPIO_InitStruct);
// P25 LED // P25 LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_P25_LED; GPIO_InitStruct.GPIO_Pin = PIN_P25_LED;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_P25_LED, &GPIO_InitStruct); GPIO_Init(PORT_P25_LED, &GPIO_InitStruct);
// NXDN LED // NXDN LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_NXDN_LED; GPIO_InitStruct.GPIO_Pin = PIN_NXDN_LED;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_NXDN_LED, &GPIO_InitStruct); GPIO_Init(PORT_NXDN_LED, &GPIO_InitStruct);
// POCSAG LED // POCSAG LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_POCSAG_LED; GPIO_InitStruct.GPIO_Pin = PIN_POCSAG_LED;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
@ -458,7 +493,7 @@ void CIO::Init()
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(PORT_PTT_LED, &GPIO_InitStruct); GPIO_Init(PORT_PTT_LED, &GPIO_InitStruct);
// COS LED // COS LED
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_COS_LED; GPIO_InitStruct.GPIO_Pin = PIN_COS_LED;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
@ -505,7 +540,7 @@ void CIO::Init()
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure); EXTI_Init(&EXTI_InitStructure);
#if defined(DUPLEX) #if defined(DUPLEX)
EXTI_InitStructure2.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure2.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure2.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure2.EXTI_Trigger = EXTI_Trigger_Rising;
@ -517,7 +552,7 @@ void CIO::Init()
void CIO::startInt() void CIO::startInt()
{ {
NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitTypeDef NVIC_InitStructure;
#if defined(DUPLEX) #if defined(DUPLEX)
NVIC_InitTypeDef NVIC_InitStructure2; NVIC_InitTypeDef NVIC_InitStructure2;
#endif #endif
@ -546,7 +581,7 @@ void CIO::startInt()
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 15; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 15;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure); NVIC_Init(&NVIC_InitStructure);
#if defined(DUPLEX) #if defined(DUPLEX)
NVIC_InitStructure2.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure2.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure2.NVIC_IRQChannelSubPriority = 15; NVIC_InitStructure2.NVIC_IRQChannelSubPriority = 15;
@ -557,18 +592,18 @@ void CIO::startInt()
#if defined(BIDIR_DATA_PIN) #if defined(BIDIR_DATA_PIN)
// RXD pin is bidirectional in standard interfaces // RXD pin is bidirectional in standard interfaces
void CIO::Data_dir_out(bool dir) void CIO::Data_dir_out(bool dir)
{ {
GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin = PIN_RXD; GPIO_InitStruct.GPIO_Pin = PIN_RXD;
if(dir) if(dir)
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
else else
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(PORT_RXD, &GPIO_InitStruct); GPIO_Init(PORT_RXD, &GPIO_InitStruct);
} }
#endif #endif
@ -696,6 +731,17 @@ void CIO::COS_pin(bool on)
GPIO_WriteBit(PORT_COS_LED, PIN_COS_LED, on ? Bit_SET : Bit_RESET); GPIO_WriteBit(PORT_COS_LED, PIN_COS_LED, on ? Bit_SET : Bit_RESET);
} }
void CIO::setBandVHF(bool vhf_on) {
GPIO_WriteBit(PORT_SET_BAND, PIN_SET_BAND, vhf_on ? Bit_SET : Bit_RESET);
}
bool CIO::hasSingleADF7021() {
return GPIO_ReadInputDataBit(PORT_SGL_DBL, PIN_SGL_DBL) == Bit_SET;
}
bool CIO::isDualBand() {
return GPIO_ReadInputDataBit(PORT_DL_DPX, PIN_DL_DPX) == Bit_SET;
}
/** /**
* Function delay_us() from stm32duino project * Function delay_us() from stm32duino project

Loading…
Cancel
Save

Powered by TurnKey Linux.