Merge pull request #49 from sq6pog/nth_rssi

RSSI readout support for NTH board @Arduino Due
This commit is contained in:
Jonathan Naylor 2016-12-21 08:43:00 +00:00 committed by GitHub
commit 773cda818d
2 changed files with 12 additions and 5 deletions

View File

@ -62,4 +62,3 @@
// #define SERIAL_REPEATER // #define SERIAL_REPEATER
#endif #endif

View File

@ -64,6 +64,8 @@
#define ADC_CDR_Chan 7 #define ADC_CDR_Chan 7
#define DACC_MR_USER_SEL_Chan DACC_MR_USER_SEL_CHANNEL0 // DAC on Due DAC0 #define DACC_MR_USER_SEL_Chan DACC_MR_USER_SEL_CHANNEL0 // DAC on Due DAC0
#define DACC_CHER_Chan DACC_CHER_CH0 #define DACC_CHER_Chan DACC_CHER_CH0
#define RSSI_CHER_Chan (1<<1) // ADC on Due pin A6 - Due AD1 - (1 << 1)
#define RSSI_CDR_Chan 1
#else #else
#error "Either ARDUINO_DUE_PAPA, ARDUINO_DUE_ZUM_V10, or ARDUINO_DUE_NTH need to be defined" #error "Either ARDUINO_DUE_PAPA, ARDUINO_DUE_ZUM_V10, or ARDUINO_DUE_NTH need to be defined"
#endif #endif
@ -104,7 +106,10 @@ void CIO::startInt()
ADC->ADC_IDR = 0xFFFFFFFF; // Disable interrupts ADC->ADC_IDR = 0xFFFFFFFF; // Disable interrupts
ADC->ADC_IER = ADC_CHER_Chan; // Enable End-Of-Conv interrupt ADC->ADC_IER = ADC_CHER_Chan; // Enable End-Of-Conv interrupt
ADC->ADC_CHDR = 0xFFFF; // Disable all channels ADC->ADC_CHDR = 0xFFFF; // Disable all channels
ADC->ADC_CHER = ADC_CHER_Chan; // Enable just one channel ADC->ADC_CHER = ADC_CHER_Chan; // Enable rx input channel
#if defined(RSSI_CHER_Chan)
ADC->ADC_CHER |= RSSI_CHER_Chan; // and RSSI input
#endif
ADC->ADC_CGR = 0x15555555; // All gains set to x1 ADC->ADC_CGR = 0x15555555; // All gains set to x1
ADC->ADC_COR = 0x00000000; // All offsets off ADC->ADC_COR = 0x00000000; // All offsets off
ADC->ADC_MR = (ADC->ADC_MR & 0xFFFFFFF0) | (1 << 1) | ADC_MR_TRGEN; // 1 = trig source TIO from TC0 ADC->ADC_MR = (ADC->ADC_MR & 0xFFFFFFF0) | (1 << 1) | ADC_MR_TRGEN; // 1 = trig source TIO from TC0
@ -169,7 +174,11 @@ void CIO::interrupt(uint8_t source)
sample = ADC->ADC_CDR[ADC_CDR_Chan]; sample = ADC->ADC_CDR[ADC_CDR_Chan];
m_rxBuffer.put(sample, control); m_rxBuffer.put(sample, control);
#if defined(RSSI_CDR_Chan) && defined(SEND_RSSI_DATA)
m_rssiBuffer.put(ADC->ADC_CDR[RSSI_CDR_Chan]);
#else
m_rssiBuffer.put(0U); m_rssiBuffer.put(0U);
#endif
m_watchdog++; m_watchdog++;
} }
@ -200,7 +209,7 @@ void CIO::setDStarInt(bool on)
digitalWrite(PIN_DSTAR, on ? HIGH : LOW); digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
} }
void CIO::setDMRInt(bool on) void CIO::setDMRInt(bool on)
{ {
digitalWrite(PIN_DMR, on ? HIGH : LOW); digitalWrite(PIN_DMR, on ? HIGH : LOW);
} }
@ -210,10 +219,9 @@ void CIO::setYSFInt(bool on)
digitalWrite(PIN_YSF, on ? HIGH : LOW); digitalWrite(PIN_YSF, on ? HIGH : LOW);
} }
void CIO::setP25Int(bool on) void CIO::setP25Int(bool on)
{ {
digitalWrite(PIN_P25, on ? HIGH : LOW); digitalWrite(PIN_P25, on ? HIGH : LOW);
} }
#endif #endif