Beispiel #1
0
static void
send_IT_sync_HE(uint8_t mode)
{
    CC1100_SET_OUT;         // High
  	mode == DATATYPE_HE ? my_delay_us(heBit1) : my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  mode == DATATYPE_HE ? my_delay_us(hesync) : my_delay_us(heeusync);
}
Beispiel #2
0
// send belfox bit (low/high)
static void
send_bit(uint8_t bit)
{
  CC1100_OUT_PORT &= ~_BV(CC1100_OUT_PIN);        // Low
  my_delay_us(bit ? BELFOX_ONE_LOW  : BELFOX_ZERO_LOW );

  CC1100_OUT_PORT |= _BV(CC1100_OUT_PIN);         // High
  my_delay_us(bit ? BELFOX_ONE_HIGH : BELFOX_ZERO_HIGH );
}
Beispiel #3
0
static void
send_IT_latch_V3(void) {
 // int8_t k;
  CC1100_SET_OUT;         // High
	my_delay_us(itv3_bit);
  CC1100_CLEAR_OUT;       // Low
  //for(k = 0; k < 10; k++)  {
    my_delay_us(itv3_latch);
  //}
}
Beispiel #4
0
static void
send_IT_sync_V3(void) {
  //int8_t k;
  CC1100_SET_OUT;         // High
	my_delay_us(itv3_start_bit);
  CC1100_CLEAR_OUT;       // Low
  //for(k = 0; k < 40; k++)  {
    my_delay_us(itv3_sync);
  //}
}
Beispiel #5
0
void
it_tunein(void)
{
		  int8_t i;
		  
#ifdef USE_HAL
		  hal_CC_GDO_init(CC_INSTANCE,INIT_MODE_OUT_CS_IN);
		  hal_enable_CC_GDOin_int(CC_INSTANCE,FALSE); // disable INT - we'll poll...
#else
		  EIMSK &= ~_BV(CC1100_INT);
  		SET_BIT( CC1100_CS_DDR, CC1100_CS_PIN ); // CS as output
#endif

  		CC1100_DEASSERT;                           // Toggle chip select signal
  		my_delay_us(30);
  		CC1100_ASSERT;
  		my_delay_us(30);
  		CC1100_DEASSERT;
  		my_delay_us(45);

		  ccStrobe( CC1100_SRES );                   // Send SRES command
  		my_delay_us(100);

		  CC1100_ASSERT;                             // load configuration
  		cc1100_sendbyte( 0 | CC1100_WRITE_BURST );
  		for(uint8_t i = 0; i < 13; i++) {
    		cc1100_sendbyte(__LPM(CC1100_ITCFG+i));
  		}																										// Tune to standard IT-Frequency
  		cc1100_sendbyte(it_frequency[0]);										// Modify Freq. for 433.92MHZ, or whatever
	  	cc1100_sendbyte(it_frequency[1]);
	 		cc1100_sendbyte(it_frequency[2]);  		
 			for (i = 16; i<EE_CC1100_CFG_SIZE; i++) {
   			cc1100_sendbyte(__LPM(CC1100_ITCFG+i));
 			}
  		CC1100_DEASSERT;

  		uint8_t *pa = EE_CC1100_PA;
		  CC1100_ASSERT;                             // setup PA table
  		cc1100_sendbyte( CC1100_PATABLE | CC1100_WRITE_BURST );
  		for (uint8_t i = 0;i<8;i++) {
    		cc1100_sendbyte(erb(pa++));
  		}
  		CC1100_DEASSERT;

  		ccStrobe( CC1100_SCAL );
  		my_delay_ms(1);
#ifndef USE_RF_MODE
  		cc_on = 1;																	// Set CC_ON
#endif
}
Beispiel #6
0
static void
it_tunein(void)
{
		  int8_t i;
		  
#ifdef ARM
  		AT91C_BASE_AIC->AIC_IDCR = 1 << AT91C_ID_PIOA;	// disable INT - we'll poll...
  		AT91C_BASE_PIOA->PIO_PPUER = _BV(CC1100_CS_PIN); 		//Enable pullup
  		AT91C_BASE_PIOA->PIO_OER = _BV(CC1100_CS_PIN);			//Enable output
  		AT91C_BASE_PIOA->PIO_PER = _BV(CC1100_CS_PIN);			//Enable PIO control
#else
		  EIMSK &= ~_BV(CC1100_INT);
  		SET_BIT( CC1100_CS_DDR, CC1100_CS_PIN ); // CS as output
#endif

  		CC1100_DEASSERT;                           // Toggle chip select signal
  		my_delay_us(30);
  		CC1100_ASSERT;
  		my_delay_us(30);
  		CC1100_DEASSERT;
  		my_delay_us(45);

		  ccStrobe( CC1100_SRES );                   // Send SRES command
  		my_delay_us(100);

		  CC1100_ASSERT;                             // load configuration
  		cc1100_sendbyte( 0 | CC1100_WRITE_BURST );
  		for(uint8_t i = 0; i < 13; i++) {
    		cc1100_sendbyte(__LPM(CC1100_ITCFG+i));
  		}																										// Tune to standard IT-Frequency
  		cc1100_sendbyte(it_frequency[0]);										// Modify Freq. for 433.92MHZ, or whatever
	  	cc1100_sendbyte(it_frequency[1]);
	 		cc1100_sendbyte(it_frequency[2]);  		
 			for (i = 16; i<EE_CC1100_CFG_SIZE; i++) {
   			cc1100_sendbyte(__LPM(CC1100_ITCFG+i));
 			}
  		CC1100_DEASSERT;

  		uint8_t *pa = EE_CC1100_PA;
		  CC1100_ASSERT;                             // setup PA table
  		cc1100_sendbyte( CC1100_PATABLE | CC1100_WRITE_BURST );
  		for (uint8_t i = 0;i<8;i++) {
    		cc1100_sendbyte(erb(pa++));
  		}
  		CC1100_DEASSERT;

  		ccStrobe( CC1100_SCAL );
  		my_delay_ms(1);
  		cc_on = 1;																	// Set CC_ON	
}
Beispiel #7
0
void native_init(uint8_t mode) {

  EIMSK &= ~_BV(CC1100_INT);                 // disable INT - we'll poll...
  SET_BIT( CC1100_CS_DDR, CC1100_CS_PIN );   // CS as output

  native_on = 0;

  CC1100_DEASSERT;                           // Toggle chip select signal
  my_delay_us(30);
  CC1100_ASSERT;
  my_delay_us(30);
  CC1100_DEASSERT;
  my_delay_us(45);

  ccStrobe( CC1100_SRES );                   // Send SRES command
  my_delay_us(100);

  if (!mode || mode>MAX_MODES)
    return;
  
  // load configuration
  for (uint8_t i = 0; i<60; i += 2) {
       
    if (pgm_read_byte( &NATIVE_CFG[i] )>0x40)
      break;

    cc1100_writeReg( pgm_read_byte(&NATIVE_CFG[i]),
                     pgm_read_byte(&NATIVE_CFG[i+1]) );
  }

  // load special configuration
  for (uint8_t i = 0; i<20; i += 2) {
    
    if (pgm_read_byte( &MODE_CFG[mode-1][i] )>0x40)
      break;
    
    cc1100_writeReg( pgm_read_byte(&MODE_CFG[mode-1][i]),
                     pgm_read_byte(&MODE_CFG[mode-1][i+1]) );
  }

  
  ccStrobe( CC1100_SCAL );

  native_on = mode;
  checkFrequency(); 
  my_delay_ms(1);
}
Beispiel #8
0
void
ccInitChip(uint8_t *cfg)
{
#ifdef HAS_MORITZ
  moritz_on = 0; //loading this configuration overwrites moritz cfg
#endif

#ifdef ARM
  AT91C_BASE_AIC->AIC_IDCR = 1 << CC1100_IN_PIO_ID;
  CC1100_CS_BASE->PIO_PPUER = _BV(CC1100_CS_PIN); 	//Enable pullup
  CC1100_CS_BASE->PIO_OER = _BV(CC1100_CS_PIN);		//Enable output
  CC1100_CS_BASE->PIO_PER = _BV(CC1100_CS_PIN);		//Enable PIO control
#else
  EIMSK &= ~_BV(CC1100_INT);                 
  SET_BIT( CC1100_CS_DDR, CC1100_CS_PIN ); // CS as output
#endif

  CC1100_DEASSERT;                           // Toggle chip select signal
  my_delay_us(30);
  CC1100_ASSERT;
  my_delay_us(30);
  CC1100_DEASSERT;
  my_delay_us(45);

  ccStrobe( CC1100_SRES );                   // Send SRES command
  my_delay_us(100);

  CC1100_ASSERT;                             // load configuration
  cc1100_sendbyte( 0 | CC1100_WRITE_BURST );
  for(uint8_t i = 0; i < EE_CC1100_CFG_SIZE; i++) {
    cc1100_sendbyte(erb(cfg++));
  }
  CC1100_DEASSERT;

  uint8_t *pa = EE_CC1100_PA;
  CC1100_ASSERT;                             // setup PA table
  cc1100_sendbyte( CC1100_PATABLE | CC1100_WRITE_BURST );
  for (uint8_t i = 0;i<8;i++) {
    cc1100_sendbyte(erb(pa++));
  }
  CC1100_DEASSERT;

  ccStrobe( CC1100_SCAL );
  my_delay_ms(1);
}
Beispiel #9
0
static void my_delay_ms(uint16_t delay)
{
	while (delay != 0) {
		// experiments have shown that 1ms is in fact 970us
		// when using my_delay_us() (at least with the test
		// chip -- RC oszillators aren't very stable...)
		my_delay_us(970);
		delay--;
	}
}
Beispiel #10
0
static void
send_IT_bit_HE(uint8_t bit, uint8_t mode)
{
	if (bit == 1) {
    CC1100_SET_OUT;         // High
  	mode == DATATYPE_HE ? my_delay_us(heBit1) : my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  mode == DATATYPE_HE ? my_delay_us(heBit0) : my_delay_us(itv3_bit);
  } else {
    CC1100_SET_OUT;         // High
  	mode == DATATYPE_HE ? my_delay_us(heBit0) : my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  mode == DATATYPE_HE ? my_delay_us(heBit1) : my_delay_us(heeusync_low);
  }
}
Beispiel #11
0
//--------------------------------------------------------------------
void
ccRX(void)
{
  uint8_t cnt = 0xff;

  while(cnt-- &&
        (ccStrobe(CC1100_SRX) & CC1100_STATUS_STATE_BM) != CC1100_STATE_RX)
    my_delay_us(10);
#ifdef ARM
    AT91C_BASE_AIC->AIC_IECR = 1 << CC1100_IN_PIO_ID;
#else
  EIMSK |= _BV(CC1100_INT);
#endif
}
Beispiel #12
0
//--------------------------------------------------------------------
void
ccTX(void)
{
  uint8_t cnt = 0xff;
#ifdef ARM
  AT91C_BASE_AIC->AIC_IDCR = 1 << CC1100_IN_PIO_ID;
#else
  EIMSK  &= ~_BV(CC1100_INT);
#endif
  // Going from RX to TX does not work if there was a reception less than 0.5
  // sec ago. Due to CCA? Using IDLE helps to shorten this period(?)
  ccStrobe(CC1100_SIDLE);
  while(cnt-- &&
        (ccStrobe(CC1100_STX) & CC1100_STATUS_STATE_BM) != CC1100_STATE_TX)
    my_delay_us(10);
}
Beispiel #13
0
void
set_ccoff(void)
{
#ifdef BUSWARE_CUR
  uint8_t cnt = 0xff;
  while(cnt-- && (ccStrobe( CC1100_SIDLE ) & 0x70) != 0)
    my_delay_us(10);
  ccStrobe(CC1100_SPWD);
#else
  ccStrobe(CC1100_SIDLE);
#endif

  cc_on = 0;

#ifdef HAS_ASKSIN
  asksin_on = 0;
#endif

#ifdef HAS_MORITZ
  moritz_on = 0;
#endif
}
Beispiel #14
0
void
kopp_fc_init(void)
{
#ifdef ARM

  AT91C_BASE_AIC->AIC_IDCR = 1 << CC1100_IN_PIO_ID; // disable INT - we'll poll...

  CC1100_CS_BASE->PIO_PPUER = _BV(CC1100_CS_PIN);     //Enable pullup
  CC1100_CS_BASE->PIO_OER = _BV(CC1100_CS_PIN);     //Enable output
  CC1100_CS_BASE->PIO_PER = _BV(CC1100_CS_PIN);     //Enable PIO control

#else
  EIMSK &= ~_BV(CC1100_INT);                 	// disable INT - we'll poll...
  SET_BIT( CC1100_CS_DDR, CC1100_CS_PIN );   	// CS as output
#endif

// Toggle chip select signal (why?)
  CC1100_DEASSERT;                            	// Chip Select InActiv
  my_delay_us(30);
  CC1100_ASSERT;								// Chip Select Activ
  my_delay_us(30);
  CC1100_DEASSERT;								// Chip Select InActiv
  my_delay_us(45);

  ccStrobe( CC1100_SRES );                   	// Send SRES command (Reset CC110x)
  my_delay_us(100);


// load configuration (CC1100_Kopp_CFG[EE_CC1100_CFG_SIZE])
    CC1100_ASSERT;								// Chip Select Activ
	 cc1100_sendbyte( 0 | CC1100_WRITE_BURST );
	 for(uint8_t i = 0; i < EE_CC1100_CFG_SIZE; i++) 
	 {
	  cc1100_sendbyte(__LPM(CC1100_Kopp_CFG+i));
	 } 
	CC1100_DEASSERT;							// Chip Select InActiv
  
// If I don't missunderstand the code, in module cc1100.c the pa table is defined as 
// 00 and C2 what means power off and max. power.
// so following code (setup PA table) is not needed ?
// did a trial, but does not work


// setup PA table (-> Remove as soon as transmitting ok?), table see cc1100.c
// this initializes the PA table with the table defined at EE_Prom
// which table will be taken depends on command "x00 .... x09"
// x00 means -10dbm pa ramping
// x09 means +10dBm no pa ramping (see cc1100.c) and commandref.html

#ifdef PrintOn                                                                        //
     DS_P(PSTR("PA Table values: "));
#endif

	uint8_t *pa = EE_CC1100_PA;					//  EE_CC1100_PA+32 means max power???
	CC1100_ASSERT;
	cc1100_sendbyte( CC1100_PATABLE | CC1100_WRITE_BURST);

	for (uint8_t i = 0; i < 8; i++) 
	{
#ifdef PrintOn                                                                        //
	DU(erb(pa),0);								// ### Claus, mal sehen was im PA Table steht
    DS_P(PSTR(" "));
#endif
  
    cc1100_sendbyte(erb(pa++));				// fncollection.c "erb()"gibt einen EEPROM Wert zurück
 	}

#ifdef PrintOn 
    DS_P(PSTR("\r\n"));
#endif


 	CC1100_DEASSERT;


// Set CC_ON
	ccStrobe( CC1100_SCAL);						// Calibrate Synthesizer and turn it of. ##Claus brauchen wir das
	my_delay_ms(1);
	cc_on = 1;

  

  kopp_fc_on = 1;								//##Claus may be not needed in future (Tx Only)
  checkFrequency(); 
}
Beispiel #15
0
void setlow(uint16_t dur) { CC1100_CLEAR_OUT; my_delay_us(dur); }
Beispiel #16
0
void
rf_asksin_init(void)
{

#ifdef ARM
#ifndef CC_ID
  AT91C_BASE_AIC->AIC_IDCR = 1 << CC1100_IN_PIO_ID;	// disable INT - we'll poll...
#endif

  CC1100_CS_BASE->PIO_PPUER = _BV(CC1100_CS_PIN); 		//Enable pullup
  CC1100_CS_BASE->PIO_OER = _BV(CC1100_CS_PIN);			//Enable output
  CC1100_CS_BASE->PIO_PER = _BV(CC1100_CS_PIN);			//Enable PIO control

#else
  EIMSK &= ~_BV(CC1100_INT);                 // disable INT - we'll poll...
  SET_BIT( CC1100_CS_DDR, CC1100_CS_PIN );   // CS as output
#endif

  CC1100_DEASSERT;                           // Toggle chip select signal
  my_delay_us(30);
  CC1100_ASSERT;
  my_delay_us(30);
  CC1100_DEASSERT;
  my_delay_us(45);

  CCSTROBE( CC1100_SRES );                   // Send SRES command
  my_delay_us(100);

#ifdef CC_ID
  CC1100_ASSERT;
  uint8_t *cfg = EE_CC1100_CFG;
  for(uint8_t i = 0; i < EE_CC1100_CFG_SIZE; i++) {
      cc1100_sendbyte(erb(cfg++));
  }
  CC1100_DEASSERT;

  uint8_t *pa = EE_CC1100_PA;
    CC1100_ASSERT;                             // setup PA table
    cc1100_sendbyte( CC1100_PATABLE | CC1100_WRITE_BURST );
    for (uint8_t i = 0;i<8;i++) {
      cc1100_sendbyte(erb(pa++));
    }
    CC1100_DEASSERT;
#endif
  // load configuration
  for (uint8_t i = 0; i < sizeof(ASKSIN_CFG); i += 2) {
    CC1100_WRITEREG( pgm_read_byte(&ASKSIN_CFG[i]),
                     pgm_read_byte(&ASKSIN_CFG[i+1]) );
  }

#ifdef HAS_ASKSIN_FUP
  if (asksin_update_mode) {
    for (uint8_t i = 0; i < sizeof(ASKSIN_UPDATE_CFG); i += 2) {
      cc1100_writeReg( pgm_read_byte(&ASKSIN_UPDATE_CFG[i]),
                       pgm_read_byte(&ASKSIN_UPDATE_CFG[i+1]) );
    }
  }
#endif
  
  CCSTROBE( CC1100_SCAL );

  my_delay_ms(4);

  // enable RX, but don't enable the interrupt
  do {
    CCSTROBE(CC1100_SRX);
  } while (CC1100_READREG(CC1100_MARCSTATE) != MARCSTATE_RX);
}
Beispiel #17
0
// send sync flag
static void
send_sync(void)
{
  CC1100_OUT_PORT |= _BV(CC1100_OUT_PIN);         // High
  my_delay_us(BELFOX_ZERO_HIGH);
}
Beispiel #18
0
static void
it_send (char *in, uint8_t datatype) {	

    //while (rf_isreceiving()) {
      //_delay_ms(1);
    //}
	  int8_t i, j, k;

		LED_ON();

    #if defined (HAS_IRRX) || defined (HAS_IRTX) //Blockout IR_Reception for the moment
      cli(); 
    #endif
  
	// If NOT InterTechno mode
	if(!intertechno_on)  {
	#ifdef HAS_ASKSIN
		if (asksin_on) {
			restore_asksin = 1;
			asksin_on = 0;
			}
	#endif
	#ifdef HAS_MORITZ
		if(moritz_on) {
			restore_moritz = 1;
			moritz_on = 0;
		}
	#endif
	it_tunein();
	my_delay_ms(3);             // 3ms: Found by trial and error
    }
  	ccStrobe(CC1100_SIDLE);
  	ccStrobe(CC1100_SFRX );
  	ccStrobe(CC1100_SFTX );

	  ccTX();                       // Enable TX 
	
    int8_t sizeOfPackage = strlen(in)-1; // IT-V1 = 14, IT-V3 = 33, IT-V3-Dimm = 37
	  int8_t mode = 0; // IT V1
    //DU(sizeOfPackage, 3);
    if (sizeOfPackage == 33 || sizeOfPackage == 37) { 
      mode = 1; // IT V3
      
    }
		for(i = 0; i < it_repetition; i++)  {
      if (datatype == DATATYPE_IT) {
        if (mode == 1) {    
          send_IT_sync_V3();  
          send_IT_latch_V3();
        } else {
          // Sync-Bit for IT V1 send before package
          CC1100_SET_OUT;         // High
          my_delay_us(it_interval);
          CC1100_CLEAR_OUT;       // Low
          for(k = 0; k < 31; k++)  {
            my_delay_us(it_interval);
          }
        }
#ifdef HAS_HOMEEASY
      } else if (datatype == DATATYPE_HE) {
        send_IT_sync_HE(DATATYPE_HE);
      } else if (datatype == DATATYPE_HEEU) {
        send_IT_sync_HE(DATATYPE_HEEU);
#endif
      }
      uint8_t startCount = 1;
#ifdef HAS_HOMEEASY
      if (datatype == DATATYPE_HE || datatype == DATATYPE_HEEU) {
        startCount = 2;
      } 
#endif
		  for(j = startCount; j < sizeOfPackage; j++)  {
			  if(in[j+1] == '0') {
          if (datatype == DATATYPE_IT) {
            if (mode == 1) {
					    send_IT_bit_V3(0);
            } else {
					    send_IT_bit(0);
            }      
#ifdef HAS_HOMEEASY
          } else {
            send_IT_bit_HE(0, datatype);
#endif
          }
				} else if (in[j+1] == '1') {
          if (datatype == DATATYPE_IT) {
            if (mode == 1) {
					    send_IT_bit_V3(1);
            } else {
					    send_IT_bit(1);
            }
#ifdef HAS_HOMEEASY
          } else {
            send_IT_bit_HE(1, datatype);
#endif
          }
        } else if (in[j+1] == '2') {
          send_IT_bit_V3(2);
				} else {
          if (mode == 1) {
					  send_IT_bit_V3(3);
				  } else {
					  send_IT_bit(2);
				  }
			  }
			}
      //if (mode == 1) {  
      //  send_IT_sync_V3();
      //}
		} //Do it n Times
	
  	if(intertechno_on) {
			if(tx_report) {                               // Enable RX
	    	ccRX();
	  	} else {
		  	ccStrobe(CC1100_SIDLE);
			}
  	} 
  	#ifdef HAS_ASKSIN
   	  else if (restore_asksin) {
				restore_asksin = 0;
   			rf_asksin_init();
				asksin_on = 1;
   		 	ccRX();
  		}  
  	#endif
	#ifdef HAS_MORITZ
	else if (restore_moritz) {
		restore_moritz = 0;
		rf_moritz_init();
	}
	#endif
  	else {
    	set_txrestore();
  	}	

    #if defined (HAS_IRRX) || defined (HAS_IRTX) //Activate IR_Reception again
      sei(); 
    #endif		  

		LED_OFF();
	
		DC('i');DC('s');
#ifdef HAS_HOMEEASY
    if (datatype == DATATYPE_HE) {
      DC('h');
    } else if (datatype == DATATYPE_HEEU) {
      DC('e');
    }
#endif
		for(j = 1; j < sizeOfPackage; j++)  {
		 	if(in[j+1] == '0') {
				DC('0');
			} else if (in[j+1] == '1') {
				DC('1');
			} else if (in[j+1] == '2') {
				DC('2');
			} else {
        if (datatype == DATATYPE_IT) {
          if (mode == 1) {  
     				DC('D');
          } else {
				    DC('F');
          }
        }
			}
		}
		DNL();
}
Beispiel #19
0
static void
send_IT_bit_V3(uint8_t bit)
{
	if (bit == 1) {
  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_low);

  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_bit);
  } else if (bit == 0) {
  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_bit);

  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_low);
  } else if (bit == 2) {
  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_low);

  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_low);  
  } else {
  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_bit);

  	CC1100_SET_OUT;         // High
  	my_delay_us(itv3_bit);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(itv3_bit);  	
  }
}
Beispiel #20
0
static void
send_IT_bit(uint8_t bit)
{
	if (bit == 1) {
  	CC1100_SET_OUT;         // High
  	my_delay_us(it_interval * 3);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(it_interval);

  	CC1100_SET_OUT;         // High
  	my_delay_us(it_interval * 3);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(it_interval);
  } else if (bit == 0) {
  	CC1100_SET_OUT;         // High
  	my_delay_us(it_interval);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(it_interval * 3);

  	CC1100_SET_OUT;         // High
  	my_delay_us(it_interval);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(it_interval * 3);
  } else {
  	CC1100_SET_OUT;         // High
  	my_delay_us(it_interval);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(it_interval * 3);

  	CC1100_SET_OUT;         // High
  	my_delay_us(it_interval * 3);
 	  CC1100_CLEAR_OUT;       // Low
	  my_delay_us(it_interval);  	
  }
}
Beispiel #21
0
void
rf_moritz_init(void)
{
#ifdef ARM
#ifndef CC_ID
  AT91C_BASE_AIC->AIC_IDCR = 1 << AT91C_ID_PIOA;	// disable INT - we'll poll...
#endif

  CC1100_CS_BASE->PIO_PPUER = _BV(CC1100_CS_PIN); 		//Enable pullup
  CC1100_CS_BASE->PIO_OER = _BV(CC1100_CS_PIN);			//Enable output
  CC1100_CS_BASE->PIO_PER = _BV(CC1100_CS_PIN);			//Enable PIO control
#else
  EIMSK &= ~_BV(CC1100_INT);                 // disable INT - we'll poll...
  SET_BIT( CC1100_CS_DDR, CC1100_CS_PIN );   // CS as output
#endif

  CC1100_DEASSERT;                           // Toggle chip select signal
  my_delay_us(30);
  CC1100_ASSERT;
  my_delay_us(30);
  CC1100_DEASSERT;
  my_delay_us(45);

  CCSTROBE( CC1100_SRES );                   // Send SRES command
  my_delay_us(100);

#ifdef CC_ID
  CC1100_ASSERT;
  uint8_t *cfg = EE_CC1100_CFG;
  for(uint8_t i = 0; i < EE_CC1100_CFG_SIZE; i++) {
      cc1100_sendbyte(erb(cfg++));
  }
  CC1100_DEASSERT;

  uint8_t *pa = EE_CC1100_PA;
    CC1100_ASSERT;                             // setup PA table
    cc1100_sendbyte( CC1100_PATABLE | CC1100_WRITE_BURST );
    for (uint8_t i = 0;i<8;i++) {
      cc1100_sendbyte(erb(pa++));
    }
    CC1100_DEASSERT;
#endif

  // load configuration
  for (uint8_t i = 0; i<60; i += 2) {
    if (pgm_read_byte( &MORITZ_CFG[i] )>0x40)
      break;

    CC1100_WRITEREG( pgm_read_byte(&MORITZ_CFG[i]),
                     pgm_read_byte(&MORITZ_CFG[i+1]) );
  }

  CCSTROBE( CC1100_SCAL );

  my_delay_ms(4); // 4ms: Found by trial and error
  //This is ccRx() but without enabling the interrupt
  uint8_t cnt = 0xff;
  //Enable RX. Perform calibration first if coming from IDLE and MCSM0.FS_AUTOCAL=1.
  //Why do it multiple times?
  while(cnt-- && (CCSTROBE( CC1100_SRX ) & 0x70) != 1)
    my_delay_us(10);

  moritz_on = 1;
  //todo check multiCC
  checkFrequency(); 
}
Beispiel #22
0
void sethigh(uint16_t dur) { CC1100_SET_OUT; my_delay_us(dur); }