fix KISS TNC
This commit is contained in:
		
							parent
							
								
									ca5f4002ea
								
							
						
					
					
						commit
						d365fee768
					
				
							
								
								
									
										14
									
								
								src/KISS.cpp
								
								
								
								
							
							
						
						
									
										14
									
								
								src/KISS.cpp
								
								
								
								
							| 
						 | 
					@ -11,11 +11,11 @@ uint16_t kissLen = 0;
 | 
				
			||||||
// KISS equipment, and look if we have anything to relay along
 | 
					// KISS equipment, and look if we have anything to relay along
 | 
				
			||||||
void KISS::loop() {
 | 
					void KISS::loop() {
 | 
				
			||||||
  static bool currentlySending = false;
 | 
					  static bool currentlySending = false;
 | 
				
			||||||
  if(afsk.decoder.read() || afsk.rxPacketCount()) {
 | 
					  if(afsk->decoder.read() || afsk->rxPacketCount()) {
 | 
				
			||||||
     // A true return means something was put onto the packet FIFO
 | 
					     // A true return means something was put onto the packet FIFO
 | 
				
			||||||
     // If we actually have data packets in the buffer, process them all now
 | 
					     // If we actually have data packets in the buffer, process them all now
 | 
				
			||||||
     while(afsk.rxPacketCount()) {
 | 
					     while(afsk->rxPacketCount()) {
 | 
				
			||||||
       AFSK::Packet *packet = afsk.getRXPacket();
 | 
					       AFSK::Packet *packet = afsk->getRXPacket();
 | 
				
			||||||
       if(packet) {
 | 
					       if(packet) {
 | 
				
			||||||
         writePacket(packet);
 | 
					         writePacket(packet);
 | 
				
			||||||
         AFSK::PacketBuffer::freePacket(packet);
 | 
					         AFSK::PacketBuffer::freePacket(packet);
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ void KISS::loop() {
 | 
				
			||||||
           packet->appendFCS(kissBuffer[i]);
 | 
					           packet->appendFCS(kissBuffer[i]);
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
         packet->finish();
 | 
					         packet->finish();
 | 
				
			||||||
         afsk.encoder.putPacket(packet);
 | 
					         afsk->encoder.putPacket(packet);
 | 
				
			||||||
       }
 | 
					       }
 | 
				
			||||||
       kissLen = 0;
 | 
					       kissLen = 0;
 | 
				
			||||||
       inFrame = false;
 | 
					       inFrame = false;
 | 
				
			||||||
| 
						 | 
					@ -57,15 +57,15 @@ void KISS::loop() {
 | 
				
			||||||
         inFrame = true;
 | 
					         inFrame = true;
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
   if(afsk.txReady()) {
 | 
					   if(afsk->txReady()) {
 | 
				
			||||||
     radio->setModeTransmit();
 | 
					     radio->setModeTransmit();
 | 
				
			||||||
     currentlySending = true;
 | 
					     currentlySending = true;
 | 
				
			||||||
     if(!afsk.txStart()) { // Unable to start for some reason
 | 
					     if(!afsk->txStart()) { // Unable to start for some reason
 | 
				
			||||||
       radio->setModeReceive();
 | 
					       radio->setModeReceive();
 | 
				
			||||||
       currentlySending = false;
 | 
					       currentlySending = false;
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
   if(currentlySending && afsk.encoder.isDone()) {
 | 
					   if(currentlySending && afsk->encoder.isDone()) {
 | 
				
			||||||
    radio->setModeReceive();
 | 
					    radio->setModeReceive();
 | 
				
			||||||
    currentlySending = false;
 | 
					    currentlySending = false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								src/KISS.h
								
								
								
								
							
							
						
						
									
										15
									
								
								src/KISS.h
								
								
								
								
							| 
						 | 
					@ -11,26 +11,15 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class KISS {
 | 
					class KISS {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  KISS(Stream *_io, HamShield *h, DDS *d) : io(_io), radio(h), dds(d) {}
 | 
					  KISS(Stream *_io, HamShield *h, DDS *d, AFSK *a) : io(_io), radio(h), dds(d), afsk(a) {}
 | 
				
			||||||
  bool read();
 | 
					  bool read();
 | 
				
			||||||
  AFSK afsk;
 | 
					 | 
				
			||||||
  void writePacket(AFSK::Packet *);
 | 
					  void writePacket(AFSK::Packet *);
 | 
				
			||||||
  void loop();
 | 
					  void loop();
 | 
				
			||||||
  inline void isr() {
 | 
					 | 
				
			||||||
    static uint8_t tcnt = 0;
 | 
					 | 
				
			||||||
    TIFR1 = _BV(ICF1); // Clear the timer flag
 | 
					 | 
				
			||||||
    dds->clockTick();
 | 
					 | 
				
			||||||
    if(++tcnt == (DDS_REFCLK_DEFAULT/9600)) {
 | 
					 | 
				
			||||||
      //PORTD |= _BV(2); // Diagnostic pin (D2)
 | 
					 | 
				
			||||||
      afsk.timer();
 | 
					 | 
				
			||||||
      tcnt = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    //PORTD &= ~(_BV(2));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  Stream *io;
 | 
					  Stream *io;
 | 
				
			||||||
  HamShield *radio;
 | 
					  HamShield *radio;
 | 
				
			||||||
  DDS *dds;
 | 
					  DDS *dds;
 | 
				
			||||||
 | 
					  AFSK *afsk;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* _KISS_H_ */
 | 
					#endif /* _KISS_H_ */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue