Remove MBED definitions.

This commit is contained in:
Jonathan Naylor 2016-10-20 18:26:04 +01:00
parent feef673878
commit 2238ad524e
9 changed files with 34 additions and 137 deletions

View File

@ -19,11 +19,7 @@
#if !defined(GLOBALS_H) #if !defined(GLOBALS_H)
#define GLOBALS_H #define GLOBALS_H
#if defined(__MBED__)
#include "mbed.h"
#else
#include <Arduino.h> #include <Arduino.h>
#endif
#if defined(__SAM3X8E__) || defined(__STM32F1__) || defined(__STM32F2__) #if defined(__SAM3X8E__) || defined(__STM32F1__) || defined(__STM32F2__)
#define ARM_MATH_CM3 #define ARM_MATH_CM3

55
IO.cpp
View File

@ -83,13 +83,6 @@ const uint16_t DC_OFFSET = 2048U;
#else #else
#error "Either ARDUINO_DUE_PAPA, ARDUINO_DUE_ZUM_V10_V12, or ARDUINO_DUE_NTH need to be defined" #error "Either ARDUINO_DUE_PAPA, ARDUINO_DUE_ZUM_V10_V12, or ARDUINO_DUE_NTH need to be defined"
#endif #endif
#elif defined(__MBED__)
// A generic MBED platform
#define PIN_COS PB_4 // D5
#define PIN_PTT PA_8 // D7
#define PIN_COSLED PB_10 // D6
#define PIN_ADC PA_0 // A0
#define PIN_DAC PA_4 // A2
#else #else
#error "Unknown hardware type" #error "Unknown hardware type"
#endif #endif
@ -100,22 +93,11 @@ extern "C" {
#if defined(__SAM3X8E__) #if defined(__SAM3X8E__)
if (ADC->ADC_ISR & ADC_ISR_EOC_Chan) // Ensure there was an End-of-Conversion and we read the ISR reg if (ADC->ADC_ISR & ADC_ISR_EOC_Chan) // Ensure there was an End-of-Conversion and we read the ISR reg
io.interrupt(); io.interrupt();
#elif defined(__MBED__)
io.interrupt();
#endif #endif
} }
} }
CIO::CIO() : CIO::CIO() :
#if defined(__MBED__)
m_pinPTT(PIN_PTT),
m_pinCOSLED(PIN_COSLED),
m_pinLED(LED1),
m_pinCOS(PIN_COS),
m_pinADC(PIN_ADC),
m_pinDAC(PIN_DAC),
m_ticker(),
#endif
m_started(false), m_started(false),
m_rxBuffer(RX_RINGBUFFER_SIZE), m_rxBuffer(RX_RINGBUFFER_SIZE),
m_txBuffer(TX_RINGBUFFER_SIZE), m_txBuffer(TX_RINGBUFFER_SIZE),
@ -151,7 +133,6 @@ m_lockout(false)
m_GMSKFilter.pState = m_GMSKState; m_GMSKFilter.pState = m_GMSKState;
m_GMSKFilter.pCoeffs = GMSK_FILTER; m_GMSKFilter.pCoeffs = GMSK_FILTER;
#if !defined(__MBED__)
// Set up the TX, COS and LED pins // Set up the TX, COS and LED pins
pinMode(PIN_PTT, OUTPUT); pinMode(PIN_PTT, OUTPUT);
pinMode(PIN_COSLED, OUTPUT); pinMode(PIN_COSLED, OUTPUT);
@ -165,7 +146,6 @@ m_lockout(false)
pinMode(PIN_YSF, OUTPUT); pinMode(PIN_YSF, OUTPUT);
pinMode(PIN_P25, OUTPUT); pinMode(PIN_P25, OUTPUT);
#endif #endif
#endif
} }
void CIO::start() void CIO::start()
@ -233,12 +213,6 @@ void CIO::start()
digitalWrite(PIN_PTT, m_pttInvert ? HIGH : LOW); digitalWrite(PIN_PTT, m_pttInvert ? HIGH : LOW);
digitalWrite(PIN_COSLED, LOW); digitalWrite(PIN_COSLED, LOW);
digitalWrite(PIN_LED, HIGH); digitalWrite(PIN_LED, HIGH);
#elif defined(__MBED__)
m_ticker.attach(&ADC_Handler, 1.0 / 24000.0);
m_pinPTT.write(m_pttInvert ? 1 : 0);
m_pinCOSLED.write(0);
m_pinLED.write(1);
#endif #endif
m_count = 0U; m_count = 0U;
@ -266,41 +240,25 @@ void CIO::process()
if (m_ledCount >= 24000U) { if (m_ledCount >= 24000U) {
m_ledCount = 0U; m_ledCount = 0U;
m_ledValue = !m_ledValue; m_ledValue = !m_ledValue;
#if defined(__MBED__)
m_pinLED.write(m_ledValue ? 1 : 0);
#else
digitalWrite(PIN_LED, m_ledValue ? HIGH : LOW); digitalWrite(PIN_LED, m_ledValue ? HIGH : LOW);
#endif
} }
} else { } else {
if (m_ledCount >= 240000U) { if (m_ledCount >= 240000U) {
m_ledCount = 0U; m_ledCount = 0U;
m_ledValue = !m_ledValue; m_ledValue = !m_ledValue;
#if defined(__MBED__)
m_pinLED.write(m_ledValue ? 1 : 0);
#else
digitalWrite(PIN_LED, m_ledValue ? HIGH : LOW); digitalWrite(PIN_LED, m_ledValue ? HIGH : LOW);
#endif
} }
return; return;
} }
#if defined(USE_COS_AS_LOCKOUT) #if defined(USE_COS_AS_LOCKOUT)
#if defined(__MBED__)
m_lockout = m_pinCOS.read() == 1;
#else
m_lockout = digitalRead(PIN_COS) == HIGH; m_lockout = digitalRead(PIN_COS) == HIGH;
#endif
#endif #endif
// Switch off the transmitter if needed // Switch off the transmitter if needed
if (m_txBuffer.getData() == 0U && m_tx) { if (m_txBuffer.getData() == 0U && m_tx) {
m_tx = false; m_tx = false;
#if defined(__MBED__)
m_pinPTT.write(m_pttInvert ? 1 : 0);
#else
digitalWrite(PIN_PTT, m_pttInvert ? HIGH : LOW); digitalWrite(PIN_PTT, m_pttInvert ? HIGH : LOW);
#endif
} }
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) { if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
@ -426,11 +384,7 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
// Switch the transmitter on if needed // Switch the transmitter on if needed
if (!m_tx) { if (!m_tx) {
m_tx = true; m_tx = true;
#if defined(__MBED__)
m_pinPTT.write(m_pttInvert ? 0 : 1);
#else
digitalWrite(PIN_PTT, m_pttInvert ? LOW : HIGH); digitalWrite(PIN_PTT, m_pttInvert ? LOW : HIGH);
#endif
} }
q15_t txLevel = 0; q15_t txLevel = 0;
@ -483,9 +437,6 @@ void CIO::interrupt()
#if defined(__SAM3X8E__) #if defined(__SAM3X8E__)
DACC->DACC_CDR = sample; DACC->DACC_CDR = sample;
sample = ADC->ADC_CDR[ADC_CDR_Chan]; sample = ADC->ADC_CDR[ADC_CDR_Chan];
#elif defined(__MBED__)
m_pinDAC.write_u16(sample);
sample = m_pinADC.read_u16();
#endif #endif
m_rxBuffer.put(sample, control); m_rxBuffer.put(sample, control);
@ -496,11 +447,7 @@ void CIO::interrupt()
void CIO::setDecode(bool dcd) void CIO::setDecode(bool dcd)
{ {
if (dcd != m_dcd) if (dcd != m_dcd)
#if defined(__MBED__)
m_pinCOSLED.write(dcd ? 1 : 0);
#else
digitalWrite(PIN_COSLED, dcd ? HIGH : LOW); digitalWrite(PIN_COSLED, dcd ? HIGH : LOW);
#endif
m_dcd = dcd; m_dcd = dcd;
} }
@ -512,7 +459,6 @@ void CIO::setADCDetection(bool detect)
void CIO::setMode() void CIO::setMode()
{ {
#if !defined(__MBED__)
#if defined(ARDUINO_MODE_PINS) #if defined(ARDUINO_MODE_PINS)
switch (m_modemState) { switch (m_modemState) {
case STATE_DSTAR: case STATE_DSTAR:
@ -547,7 +493,6 @@ switch (m_modemState) {
break; break;
} }
#endif #endif
#endif
} }
void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel) void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel)

12
IO.h
View File

@ -57,18 +57,6 @@ public:
#endif #endif
private: private:
#if defined(__MBED__)
DigitalOut m_pinPTT;
DigitalOut m_pinCOSLED;
DigitalOut m_pinLED;
DigitalIn m_pinCOS;
AnalogIn m_pinADC;
AnalogOut m_pinDAC;
Ticker m_ticker;
#endif
bool m_started; bool m_started;
CSampleRB m_rxBuffer; CSampleRB m_rxBuffer;

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if defined(__MBED__) #if defined(notdef)
#include "Config.h" #include "Config.h"
#include "Globals.h" #include "Globals.h"

View File

@ -21,11 +21,7 @@ Boston, MA 02110-1301, USA.
#if !defined(SAMPLERB_H) #if !defined(SAMPLERB_H)
#define SAMPLERB_H #define SAMPLERB_H
#if defined(__MBED__)
#include "mbed.h"
#else
#include <Arduino.h> #include <Arduino.h>
#endif
class CSampleRB { class CSampleRB {
public: public:

View File

@ -77,9 +77,6 @@ const uint8_t PROTOCOL_VERSION = 1U;
CSerialPort::CSerialPort() : CSerialPort::CSerialPort() :
#if defined(__MBED__)
m_serial(SERIAL_TX, SERIAL_RX),
#endif
m_buffer(), m_buffer(),
m_ptr(0U), m_ptr(0U),
m_len(0U) m_len(0U)
@ -385,26 +382,17 @@ void CSerialPort::setMode(MMDVM_STATE modemState)
void CSerialPort::start() void CSerialPort::start()
{ {
#if defined(__MBED__)
m_serial.baud(115200);
#else
Serial.begin(115200); Serial.begin(115200);
#if defined(SERIAL_REPEATER) #if defined(SERIAL_REPEATER)
Serial3.begin(9600); Serial3.begin(9600);
#endif #endif
#endif
} }
void CSerialPort::process() void CSerialPort::process()
{ {
#if defined(__MBED__)
while (m_serial.readable()) {
uint8_t c = m_serial.getc();
#else
while (Serial.available()) { while (Serial.available()) {
uint8_t c = Serial.read(); uint8_t c = Serial.read();
#endif
if (m_ptr == 0U && c == MMDVM_FRAME_START) { if (m_ptr == 0U && c == MMDVM_FRAME_START) {
// Handle the frame start correctly // Handle the frame start correctly
@ -908,15 +896,10 @@ void CSerialPort::writeCalData(const uint8_t* data, uint8_t length)
void CSerialPort::write(const uint8_t* data, uint16_t length, bool flush) void CSerialPort::write(const uint8_t* data, uint16_t length, bool flush)
{ {
#if defined(__MBED__)
for (uint16_t i = 0U; i < length; i++)
m_serial.putc(data[i]);
// No explicit flush function
#else
Serial.write(data, length); Serial.write(data, length);
if (flush) if (flush)
Serial.flush(); Serial.flush();
#endif
} }
void CSerialPort::writeDebug(const char* text) void CSerialPort::writeDebug(const char* text)

View File

@ -57,9 +57,6 @@ public:
void writeAssert(bool cond, const char* text, const char* file, long line); void writeAssert(bool cond, const char* text, const char* file, long line);
private: private:
#if defined(__MBED__)
Serial m_serial;
#endif
uint8_t m_buffer[250U]; uint8_t m_buffer[250U];
uint8_t m_ptr; uint8_t m_ptr;
uint8_t m_len; uint8_t m_len;

View File

@ -21,11 +21,7 @@ Boston, MA 02110-1301, USA.
#if !defined(SERIALRB_H) #if !defined(SERIALRB_H)
#define SERIALRB_H #define SERIALRB_H
#if defined(__MBED__)
#include "mbed.h"
#else
#include <Arduino.h> #include <Arduino.h>
#endif
const uint16_t SERIAL_RINGBUFFER_SIZE = 370U; const uint16_t SERIAL_RINGBUFFER_SIZE = 370U;

View File

@ -19,11 +19,7 @@
#if !defined(UTILS_H) #if !defined(UTILS_H)
#define UTILS_H #define UTILS_H
#if defined(__MBED__)
#include "mbed.h"
#else
#include <Arduino.h> #include <Arduino.h>
#endif
uint8_t countBits8(uint8_t bits); uint8_t countBits8(uint8_t bits);