mirror of https://github.com/g4klx/MMDVM.git
Simplify the I2C display support.
This commit is contained in:
parent
683c5afccb
commit
c83879d89d
3
Config.h
3
Config.h
|
@ -110,9 +110,6 @@
|
||||||
// Use the modem as a serial repeater for Nextion displays
|
// Use the modem as a serial repeater for Nextion displays
|
||||||
// #define SERIAL_REPEATER
|
// #define SERIAL_REPEATER
|
||||||
|
|
||||||
// Use the modem as an I2C repeater for an OLED display on I2C1
|
|
||||||
#define I2C_REPEATER
|
|
||||||
|
|
||||||
// To reduce CPU load, you can remove the DC blocker by commenting out the next line
|
// To reduce CPU load, you can remove the DC blocker by commenting out the next line
|
||||||
#define USE_DCBLOCKER
|
#define USE_DCBLOCKER
|
||||||
|
|
||||||
|
|
|
@ -148,10 +148,6 @@ extern CIO io;
|
||||||
extern CI2COLED oled;
|
extern CI2COLED oled;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(I2C_REPEATER)
|
|
||||||
extern CI2CPort i2C1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MODE_DSTAR)
|
#if defined(MODE_DSTAR)
|
||||||
extern CDStarRX dstarRX;
|
extern CDStarRX dstarRX;
|
||||||
extern CDStarTX dstarTX;
|
extern CDStarTX dstarTX;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2020,2021 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
@ -305,7 +305,7 @@ const uint8_t FONT[] = {
|
||||||
|
|
||||||
|
|
||||||
CI2COLED::CI2COLED() :
|
CI2COLED::CI2COLED() :
|
||||||
m_i2c(3U),
|
m_i2c(),
|
||||||
m_oledBuffer(NULL)
|
m_oledBuffer(NULL)
|
||||||
{
|
{
|
||||||
m_oledBuffer = new uint8_t[OLED_BUFFER_SIZE];
|
m_oledBuffer = new uint8_t[OLED_BUFFER_SIZE];
|
||||||
|
|
89
I2CPort.cpp
89
I2CPort.cpp
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#if defined(MODE_OLED) || defined(I2C_REPEATER)
|
#if defined(MODE_OLED)
|
||||||
|
|
||||||
#include "I2CPort.h"
|
#include "I2CPort.h"
|
||||||
|
|
||||||
|
@ -26,77 +26,39 @@
|
||||||
|
|
||||||
const uint16_t MAX_NBYTES_SIZE = 255U;
|
const uint16_t MAX_NBYTES_SIZE = 255U;
|
||||||
|
|
||||||
CI2CPort::CI2CPort(uint8_t n) :
|
CI2CPort::CI2CPort()
|
||||||
m_port(NULL),
|
|
||||||
m_clock(0x00U),
|
|
||||||
m_ok(true),
|
|
||||||
m_addr(0x00U)
|
|
||||||
{
|
{
|
||||||
switch (n) {
|
|
||||||
case 1U:
|
|
||||||
m_port = I2C1;
|
|
||||||
m_clock = RCC_APB1Periph_I2C1;
|
|
||||||
m_busSCL = RCC_AHB1Periph_GPIOB;
|
|
||||||
m_busSDA = RCC_AHB1Periph_GPIOB;
|
|
||||||
m_af = GPIO_AF4_I2C1;
|
|
||||||
m_gpioSCL = GPIOB;
|
|
||||||
m_gpioSDA = GPIOB;
|
|
||||||
m_pinSCL = GPIO_Pin_8;
|
|
||||||
m_pinSDA = GPIO_Pin_9;
|
|
||||||
m_pinSourceSCL = GPIO_PinSource8;
|
|
||||||
m_pinSourceSDA = GPIO_PinSource9;
|
|
||||||
break;
|
|
||||||
case 3U:
|
|
||||||
m_port = I2C3;
|
|
||||||
m_clock = RCC_APB1Periph_I2C3;
|
|
||||||
m_busSCL = RCC_AHB1Periph_GPIOA;
|
|
||||||
m_busSDA = RCC_AHB1Periph_GPIOC;
|
|
||||||
m_af = GPIO_AF4_I2C3;
|
|
||||||
m_gpioSCL = GPIOA;
|
|
||||||
m_gpioSDA = GPIOC;
|
|
||||||
m_pinSCL = GPIO_Pin_8;
|
|
||||||
m_pinSDA = GPIO_Pin_9;
|
|
||||||
m_pinSourceSCL = GPIO_PinSource8;
|
|
||||||
m_pinSourceSDA = GPIO_PinSource9;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CI2CPort::init()
|
bool CI2CPort::init()
|
||||||
{
|
{
|
||||||
if (!m_ok)
|
// Enable I2C3
|
||||||
return false;
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C3, ENABLE);
|
||||||
|
|
||||||
// Enable I2C
|
|
||||||
RCC_APB1PeriphClockCmd(m_clock, ENABLE);
|
|
||||||
|
|
||||||
// Reset the Peripheral
|
// Reset the Peripheral
|
||||||
RCC_APB1PeriphResetCmd(m_clock, ENABLE);
|
RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, ENABLE);
|
||||||
RCC_APB1PeriphResetCmd(m_clock, DISABLE);
|
RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, DISABLE);
|
||||||
|
|
||||||
// Enable the GPIOs for the SCL/SDA Pins
|
// Enable the GPIOs for the SCL/SDA Pins
|
||||||
RCC_AHB1PeriphClockCmd(m_busSCL | m_busSDA, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC, ENABLE);
|
||||||
|
|
||||||
// Configure and initialize the GPIOs
|
// Configure and initialize the GPIOs
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.GPIO_Pin = m_pinSCL;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_High_Speed;
|
GPIO_InitStructure.GPIO_Speed = GPIO_High_Speed;
|
||||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||||
GPIO_Init(m_gpioSCL, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = m_pinSDA;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
|
||||||
GPIO_Init(m_gpioSDA, &GPIO_InitStructure);
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
// Connect GPIO pins to peripheral
|
// Connect GPIO pins to I2C3
|
||||||
GPIO_PinAFConfig(m_gpioSCL, m_pinSourceSCL, m_af);
|
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF4_I2C3);
|
||||||
GPIO_PinAFConfig(m_gpioSDA, m_pinSourceSDA, m_af);
|
GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF4_I2C3);
|
||||||
|
|
||||||
// Configure and Initialize the I2C
|
// Configure and Initialize I2C3
|
||||||
I2C_InitTypeDef I2C_InitStructure;
|
I2C_InitTypeDef I2C_InitStructure;
|
||||||
I2C_InitStructure.I2C_Timing = 0x0010061AU; // 400kHz (Fast Mode)
|
I2C_InitStructure.I2C_Timing = 0x0010061AU; // 400kHz (Fast Mode)
|
||||||
I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable;
|
I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable;
|
||||||
|
@ -107,21 +69,16 @@ bool CI2CPort::init()
|
||||||
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
||||||
|
|
||||||
// Initialize the Peripheral
|
// Initialize the Peripheral
|
||||||
I2C_Init(m_port, &I2C_InitStructure);
|
I2C_Init(I2C3, &I2C_InitStructure);
|
||||||
|
|
||||||
// I2C Peripheral Enable
|
// I2C Peripheral Enable
|
||||||
I2C_Cmd(m_port, ENABLE);
|
I2C_Cmd(I2C3, ENABLE);
|
||||||
|
|
||||||
m_ok = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CI2CPort::write(uint8_t addr, const uint8_t* data, uint16_t length)
|
uint8_t CI2CPort::write(uint8_t addr, const uint8_t* data, uint16_t length)
|
||||||
{
|
{
|
||||||
if (!m_ok)
|
|
||||||
return 6U;
|
|
||||||
|
|
||||||
// Wait for the I2C transmitter to become free
|
// Wait for the I2C transmitter to become free
|
||||||
if (waitISRFlagsSet(I2C_ISR_BUSY))
|
if (waitISRFlagsSet(I2C_ISR_BUSY))
|
||||||
return 6U;
|
return 6U;
|
||||||
|
@ -141,7 +98,7 @@ uint8_t CI2CPort::write(uint8_t addr, const uint8_t* data, uint16_t length)
|
||||||
return 6U;
|
return 6U;
|
||||||
|
|
||||||
// Write the byte to the TXDR
|
// Write the byte to the TXDR
|
||||||
m_port->TXDR = *data++;
|
I2C3->TXDR = *data++;
|
||||||
length--;
|
length--;
|
||||||
size--;
|
size--;
|
||||||
|
|
||||||
|
@ -158,9 +115,9 @@ uint8_t CI2CPort::write(uint8_t addr, const uint8_t* data, uint16_t length)
|
||||||
if (waitISRFlagsSet(I2C_ISR_STOPF))
|
if (waitISRFlagsSet(I2C_ISR_STOPF))
|
||||||
return 6U;
|
return 6U;
|
||||||
|
|
||||||
m_port->ISR &= ~I2C_ISR_STOPF;
|
I2C3->ISR &= ~I2C_ISR_STOPF;
|
||||||
|
|
||||||
m_port->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN));
|
I2C3->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN));
|
||||||
|
|
||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +128,7 @@ bool CI2CPort::waitISRFlagsSet(uint32_t flags)
|
||||||
// More than 1 Flag can be "or"ed.
|
// More than 1 Flag can be "or"ed.
|
||||||
uint32_t timeOut = HSI_VALUE;
|
uint32_t timeOut = HSI_VALUE;
|
||||||
|
|
||||||
while ((m_port->ISR & flags) != flags) {
|
while ((I2C3->ISR & flags) != flags) {
|
||||||
if (!(timeOut--))
|
if (!(timeOut--))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -181,14 +138,14 @@ bool CI2CPort::waitISRFlagsSet(uint32_t flags)
|
||||||
|
|
||||||
void CI2CPort::configureDataTransfer(uint8_t size)
|
void CI2CPort::configureDataTransfer(uint8_t size)
|
||||||
{
|
{
|
||||||
m_port->CR2 &= ~(I2C_CR2_SADD |
|
I2C3->CR2 &= ~(I2C_CR2_SADD |
|
||||||
I2C_CR2_NBYTES |
|
I2C_CR2_NBYTES |
|
||||||
I2C_CR2_RELOAD |
|
I2C_CR2_RELOAD |
|
||||||
I2C_CR2_AUTOEND |
|
I2C_CR2_AUTOEND |
|
||||||
(I2C_CR2_RD_WRN & (uint32_t)(I2C_Generate_Start_Write >> (31U - I2C_CR2_RD_WRN_Pos))) |
|
(I2C_CR2_RD_WRN & (uint32_t)(I2C_Generate_Start_Write >> (31U - I2C_CR2_RD_WRN_Pos))) |
|
||||||
I2C_CR2_START |
|
I2C_CR2_START |
|
||||||
I2C_CR2_STOP);
|
I2C_CR2_STOP);
|
||||||
m_port->CR2 |= (uint32_t)(((uint32_t)m_addr & I2C_CR2_SADD) |
|
I2C3->CR2 |= (uint32_t)(((uint32_t)m_addr & I2C_CR2_SADD) |
|
||||||
(((uint32_t)size << I2C_CR2_NBYTES_Pos) & I2C_CR2_NBYTES) |
|
(((uint32_t)size << I2C_CR2_NBYTES_Pos) & I2C_CR2_NBYTES) |
|
||||||
(uint32_t)I2C_CR2_RELOAD |
|
(uint32_t)I2C_CR2_RELOAD |
|
||||||
(uint32_t)I2C_Generate_Start_Write);
|
(uint32_t)I2C_Generate_Start_Write);
|
||||||
|
|
18
I2CPort.h
18
I2CPort.h
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#if defined(MODE_OLED) || defined(I2C_REPEATER)
|
#if defined(MODE_OLED)
|
||||||
|
|
||||||
#if !defined(I2CPORT_H)
|
#if !defined(I2CPORT_H)
|
||||||
#define I2CPORT_H
|
#define I2CPORT_H
|
||||||
|
@ -31,27 +31,13 @@
|
||||||
|
|
||||||
class CI2CPort {
|
class CI2CPort {
|
||||||
public:
|
public:
|
||||||
CI2CPort(uint8_t n);
|
CI2CPort();
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
uint8_t write(uint8_t addr, const uint8_t* data, uint16_t length);
|
uint8_t write(uint8_t addr, const uint8_t* data, uint16_t length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
I2C_TypeDef* m_port;
|
|
||||||
uint32_t m_clock;
|
|
||||||
uint32_t m_busSCL;
|
|
||||||
uint32_t m_busSDA;
|
|
||||||
uint8_t m_af;
|
|
||||||
GPIO_TypeDef* m_gpioSCL;
|
|
||||||
GPIO_TypeDef* m_gpioSDA;
|
|
||||||
uint32_t m_pinSCL;
|
|
||||||
uint32_t m_pinSDA;
|
|
||||||
uint16_t m_pinSourceSCL;
|
|
||||||
uint16_t m_pinSourceSDA;
|
|
||||||
bool m_ok;
|
|
||||||
uint8_t m_addr;
|
|
||||||
|
|
||||||
bool waitISRFlagsSet(uint32_t flags);
|
bool waitISRFlagsSet(uint32_t flags);
|
||||||
void configureDataTransfer(uint8_t size);
|
void configureDataTransfer(uint8_t size);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* 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,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2017,2018,2020,2021 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2019,2020 by BG5HHP
|
* Copyright (C) 2019,2020 by BG5HHP
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -194,10 +194,6 @@ void CIO::initInt()
|
||||||
#if defined(MODE_OLED)
|
#if defined(MODE_OLED)
|
||||||
oled.init();
|
oled.init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(I2C_REPEATER)
|
|
||||||
i2C1.init();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIO::startInt()
|
void CIO::startInt()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016 by Jim McLaughlin KI6ZUM
|
* Copyright (C) 2016 by Jim McLaughlin KI6ZUM
|
||||||
* Copyright (C) 2016, 2017 by Andy Uribe CA6JAU
|
* Copyright (C) 2016, 2017 by Andy Uribe CA6JAU
|
||||||
* Copyright (C) 2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2017,2018,2020,2021 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2017 by Wojciech Krutnik N0CALL
|
* Copyright (C) 2017 by Wojciech Krutnik N0CALL
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -362,9 +362,6 @@ void CIO::initInt()
|
||||||
#if defined(MODE_OLED)
|
#if defined(MODE_OLED)
|
||||||
oled.init();
|
oled.init();
|
||||||
#endif
|
#endif
|
||||||
#if defined(I2C_REPEATER)
|
|
||||||
i2c1.init();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIO::startInt()
|
void CIO::startInt()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2016 by Mathis Schmieder DB9MAT
|
* Copyright (C) 2016 by Mathis Schmieder DB9MAT
|
||||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||||
*
|
*
|
||||||
|
@ -45,10 +45,6 @@ bool m_dcd = false;
|
||||||
CI2COLED oled;
|
CI2COLED oled;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(I2C_REPEATER)
|
|
||||||
CI2CPort i2C1(1U);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MODE_DSTAR)
|
#if defined(MODE_DSTAR)
|
||||||
CDStarRX dstarRX;
|
CDStarRX dstarRX;
|
||||||
CDStarTX dstarTX;
|
CDStarTX dstarTX;
|
||||||
|
|
|
@ -84,7 +84,6 @@ const uint8_t MMDVM_ACK = 0x70U;
|
||||||
const uint8_t MMDVM_NAK = 0x7FU;
|
const uint8_t MMDVM_NAK = 0x7FU;
|
||||||
|
|
||||||
const uint8_t MMDVM_SERIAL_DATA = 0x80U;
|
const uint8_t MMDVM_SERIAL_DATA = 0x80U;
|
||||||
const uint8_t MMDVM_I2C_DATA = 0x81U;
|
|
||||||
|
|
||||||
const uint8_t MMDVM_TRANSPARENT = 0x90U;
|
const uint8_t MMDVM_TRANSPARENT = 0x90U;
|
||||||
const uint8_t MMDVM_QSO_INFO = 0x91U;
|
const uint8_t MMDVM_QSO_INFO = 0x91U;
|
||||||
|
@ -1342,17 +1341,6 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(I2C_REPEATER)
|
|
||||||
case MMDVM_I2C_DATA: {
|
|
||||||
err = i2C1.write(buffer[0U], buffer + 1U, length - 1U);
|
|
||||||
if (err != 0U) {
|
|
||||||
DEBUG2("Received invalid I2C data", err);
|
|
||||||
sendNAK(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Handle this, send a NAK back
|
// Handle this, send a NAK back
|
||||||
sendNAK(1U);
|
sendNAK(1U);
|
||||||
|
|
98
mmdvmmenu.sh
98
mmdvmmenu.sh
|
@ -1,98 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# mmdvmmenu.sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2016 by Paul Nannery KC2VRJ
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# On a Linux based system, such as a Raspberry Pi, this script will perform
|
|
||||||
# Modification of the Config.h file for most options. It makes a Back up when
|
|
||||||
# you start the script if none is present. You must recompile and load firmware
|
|
||||||
# onto the Arduino Due if changes are made.
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# CONFIGURATION
|
|
||||||
#
|
|
||||||
# Location of Config.h
|
|
||||||
conf=Config.h
|
|
||||||
#Location of backup file
|
|
||||||
confbak=Config.h.bak
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
#
|
|
||||||
# Do not edit below here
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check for backup file and make one if not present
|
|
||||||
|
|
||||||
if [ ! -f $confbak ];then
|
|
||||||
|
|
||||||
cp -f $conf $confbak
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
clear
|
|
||||||
cat<<EOF
|
|
||||||
==============================================================
|
|
||||||
MMDVM Configuration Options
|
|
||||||
--------------------------------------------------------------
|
|
||||||
Please enter your choice:
|
|
||||||
|
|
||||||
(1) Enable 12.000 MHZ Clock
|
|
||||||
(2) Enable 12.288 MHZ Clock
|
|
||||||
(3) Enable 14.400 MHz Clock
|
|
||||||
(4) Enable 19.200 MHz Clock
|
|
||||||
(5) Use the COS to lockout the modem
|
|
||||||
(6) Use pins to output the current mode
|
|
||||||
(7) Use layout for the PAPA board
|
|
||||||
(8) Use layout for ZUM V1.0 and V1.0.1 boards
|
|
||||||
(9) Use layout for SP8NTH board
|
|
||||||
(0) Use modem as display driver
|
|
||||||
(A) Return to Default
|
|
||||||
|
|
||||||
(Q)uit
|
|
||||||
---------------------------------------------------------------
|
|
||||||
EOF
|
|
||||||
read -n1 -s
|
|
||||||
case "$REPLY" in
|
|
||||||
"1") sed -e 's/\/\/ #define EXTERNAL_OSC 12000000/#define EXTERNAL_OSC 12000000/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "12.000 MHz clock enabled";;
|
|
||||||
"2") sed -e 's/\/\/ #define EXTERNAL_OSC 12288000/#define EXTERNAL_OSC 12288000/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "12.288 MHz clock enabled";;
|
|
||||||
"3") sed -e 's/\/\/ #define EXTERNAL_OSC 14400000/#define EXTERNAL_OSC 14400000/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "14.400 MHz clock enabled";;
|
|
||||||
"4") sed -e 's/\/\/ #define EXTERNAL_OSC 19200000/#define EXTERNAL_OSC 19200000/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "19.200 MHz clock enabled";;
|
|
||||||
"5") sed -e 's/\/\/ #define USE_COS_AS_LOCKOUT /#define USE_COS_AS_LOCKOUT/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "COS as Lockout enabled";;
|
|
||||||
"6") sed -e 's/\/\/ #define MODE_LEDS/#define MODE_LEDS/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "Mode pins enabled";;
|
|
||||||
"7") sed -e 's/\/\/ #define ARDUINO_DUE_PAPA/#define ARDUINO_DUE_PAPA/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "Layout for the PAPA board enabled";;
|
|
||||||
"8") sed -e 's/\/\/ #define ARDUINO_DUE_ZUM_V10/#define ARDUINO_DUE_ZUM_V10/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "Layout for ZUM V1.0 and V1.0.1 boards enabled";;
|
|
||||||
"9") sed -e 's/\/\/ #define ARDUINO_DUE_NTH/#define ARDUINO_DUE_NTH/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "Layout for SP8NTH board enabled";;
|
|
||||||
"0") sed -e 's/\/\/ #define SERIAL_REPEATER/#define SERIAL_REPEATER/' $conf > $conf.tmp && mv -f $conf.tmp $conf && echo "Modem display driver enabled";;
|
|
||||||
"A") mv -f $confbak $conf ;;
|
|
||||||
"a") mv -f $confbak $conf ;;
|
|
||||||
"Q") echo "If any changes are made you need to (re-)upload the firmware to MMDVM" && exit;;
|
|
||||||
"q") echo "If any changes are made you need to (re-)upload the firmware to MMDVM" && exit;;
|
|
||||||
* ) echo "invalid option" ;;
|
|
||||||
esac
|
|
||||||
sleep 1
|
|
||||||
done
|
|
Loading…
Reference in New Issue