mirror of
https://github.com/juribeparada/MMDVM_HS.git
synced 2026-04-07 15:23:43 +00:00
First commit
This commit is contained in:
commit
587fe63a47
46 changed files with 6893 additions and 0 deletions
178
IOArduino.cpp
Normal file
178
IOArduino.cpp
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
#include "Globals.h"
|
||||
#include "IO.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if defined (__STM32F1__)
|
||||
|
||||
// STM32F1 pin definitions, using STM32duino
|
||||
#define PIN_SCLK PB5
|
||||
#define PIN_SREAD PB7
|
||||
#define PIN_SDATA PB6
|
||||
#define PIN_SLE PB8
|
||||
#define PIN_RXD PB4
|
||||
#define PIN_TXD PB3
|
||||
#define PIN_TXRX_CLK PA15
|
||||
#define PIN_LED PC13
|
||||
#define PIN_DEB PB9
|
||||
#define PIN_DSTAR_LED PB12
|
||||
#define PIN_DMR_LED PB13
|
||||
#define PIN_YSF_LED PB1
|
||||
#define PIN_P25_LED PB0
|
||||
#define PIN_PTT_LED PB14
|
||||
#define PIN_COS_LED PB15
|
||||
|
||||
#else
|
||||
|
||||
// Arduino pin definitions (Due and Zero)
|
||||
#define PIN_SCLK 3
|
||||
#define PIN_SDATA 4 // 2 in Arduino Zero Pro
|
||||
#define PIN_SREAD 5
|
||||
#define PIN_SLE 6
|
||||
#define PIN_RXD 7
|
||||
#define PIN_TXD 8
|
||||
#define PIN_TXRX_CLK 2 // 4 in Arduino Zero Pro
|
||||
#define PIN_LED 13
|
||||
#define PIN_DEB 11
|
||||
#define PIN_DSTAR_LED 14
|
||||
#define PIN_DMR_LED 15
|
||||
#define PIN_YSF_LED 16
|
||||
#define PIN_P25_LED 17
|
||||
#define PIN_PTT_LED 9
|
||||
#define PIN_COS_LED 10
|
||||
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
void EXT_IRQHandler(void) {
|
||||
io.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void CIO::delay_rx() {
|
||||
delayMicroseconds(1);
|
||||
}
|
||||
|
||||
void CIO::Init()
|
||||
{
|
||||
#if defined (__STM32F1__)
|
||||
afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY);
|
||||
#endif
|
||||
|
||||
pinMode(PIN_SCLK, OUTPUT);
|
||||
pinMode(PIN_SDATA, OUTPUT);
|
||||
pinMode(PIN_SLE, OUTPUT);
|
||||
pinMode(PIN_RXD, INPUT);
|
||||
pinMode(PIN_TXD, OUTPUT);
|
||||
pinMode(PIN_TXRX_CLK, INPUT);
|
||||
pinMode(PIN_LED, OUTPUT);
|
||||
pinMode(PIN_DEB, OUTPUT);
|
||||
pinMode(PIN_DSTAR_LED, OUTPUT);
|
||||
pinMode(PIN_DMR_LED, OUTPUT);
|
||||
pinMode(PIN_YSF_LED, OUTPUT);
|
||||
pinMode(PIN_P25_LED, OUTPUT);
|
||||
pinMode(PIN_PTT_LED, OUTPUT);
|
||||
pinMode(PIN_COS_LED, OUTPUT);
|
||||
}
|
||||
|
||||
void CIO::ifInit()
|
||||
{
|
||||
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)
|
||||
{
|
||||
digitalWrite(PIN_SCLK, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::SDATA_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_SDATA, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::SLE_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_SLE, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
bool CIO::RXD_pin()
|
||||
{
|
||||
return digitalRead(PIN_RXD) == HIGH;
|
||||
}
|
||||
|
||||
void CIO::TXD_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_TXD, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::LED_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_LED, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::DEB_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_DEB, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::DSTAR_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_DSTAR_LED, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::DMR_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_DMR_LED, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::YSF_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_YSF_LED, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::P25_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_P25_LED, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::PTT_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_PTT_LED, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void CIO::COS_pin(bool on)
|
||||
{
|
||||
digitalWrite(PIN_COS_LED, on ? HIGH : LOW);
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue