Added oregon v2.1 support to ArduinoTellstick along with some code cleanup
Former-commit-id: d05ee71fa4f2f91afd6452e894385bbcd7020917
This commit is contained in:
parent
c2d03347ca
commit
1c23a7c360
11 changed files with 391 additions and 116 deletions
|
|
@ -3,27 +3,30 @@
|
|||
#include "buffer.h"
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
* Timer2 interrupt in 16kHz. Samples the RF Rx data pin
|
||||
*/
|
||||
ISR(TIMER2_COMPA_vect) {
|
||||
|
||||
ISR(TIMER2_COMPA_vect) { //timer2 interrupt 16kHz. Samples the RF Rx data pin
|
||||
|
||||
if (!RFRX) { //if no Radio Rx should be performed
|
||||
if ( !IS_RADIO_RECIEVER_ON() ) { //if no Radio Rx should be performed
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t bit = digitalRead(RX_PIN); // optimized "digital_read(7)" = "PIND & 0x1"
|
||||
uint8_t bit = RX_PIN_READ();
|
||||
|
||||
//will store "lows" on even buffer addresses and "highs" on odd buffer addresses
|
||||
if ( ( ((int)bufferWriteP) & 0x1 ) != bit ) { //compare the bit and the buffer pointer address. true if one is odd and one is even.
|
||||
if ( ( ((uintptr_t)bufferWriteP) & 0x1 ) != bit ) { //compare the bit and the buffer pointer address. true if one is odd and one is even.
|
||||
//step the buffer pointer
|
||||
if ( bufferWriteP + 1 > RF_rxBufferEndP) {
|
||||
if ( bufferWriteP+1 > RF_rxBufferEndP ) {
|
||||
*RF_rxBufferStartP = 1; //reset the next data point before going there
|
||||
bufferWriteP = RF_rxBufferStartP;
|
||||
} else {
|
||||
*(bufferWriteP+1) = 1; //reset the next data point before going there
|
||||
++bufferWriteP;
|
||||
}
|
||||
*bufferWriteP = 1; //reset and step once on this addess
|
||||
} else {
|
||||
if (*bufferWriteP < 255) { //only values up to 255
|
||||
++(*bufferWriteP); //step the buffer
|
||||
if ( *bufferWriteP < 255 ) { //Do not step the value if it already is 255 (max value)
|
||||
++(*bufferWriteP); //step the buffer value
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,26 +37,27 @@ void setup() {
|
|||
|
||||
Serial.begin(9600);
|
||||
|
||||
pinMode(RX_PIN, INPUT); //set RX pin to input
|
||||
pinMode(TX_PIN, OUTPUT); //ser TX pin as output
|
||||
setupPins();
|
||||
|
||||
//setup timer2 interrupt at 16kHz for RF sampling
|
||||
cli();//stop interrupts
|
||||
TCCR2A = 0;// set entire TCCR2A register to 0
|
||||
TCCR2B = 0;// same for TCCR2B
|
||||
TCNT2 = 0;//initialize counter value to 0
|
||||
OCR2A = 124;// = ( (16*10^6) / (16000Hz*8pc) ) - 1 (must be <256)
|
||||
cli(); //stop interrupts
|
||||
TCCR2A = 0; // set entire TCCR2A register to 0
|
||||
TCCR2B = 0; // same for TCCR2B
|
||||
TCNT2 = 0; //initialize counter value to 0
|
||||
OCR2A = 124; // = ( (16000000Hz) / (16000Hz*8prescaler) ) - 1 (must be <256)
|
||||
TCCR2A |= (1 << WGM21); // turn on CTC mode
|
||||
TCCR2B |= (1 << CS21); // Set CS21 bit for 8 prescaler
|
||||
TIMSK2 |= (1 << OCIE2A); // enable timer compare interrupt
|
||||
sei();//allow interrupts
|
||||
sei(); //allow interrupts
|
||||
|
||||
//reset buffer just to be sure
|
||||
for (uint8_t* p = RF_rxBufferStartP; p <= RF_rxBufferEndP; ++p) {
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
Serial.println(F("+V2"));
|
||||
|
||||
RFRX = true; //start receiving radio data
|
||||
ACTIVATE_RADIO_RECEIVER();
|
||||
|
||||
};//end setup
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue