Exemplo n.º 1
0
u_int16_t flash_read16(char *p)
{
	unsigned char read1 = 1;
	unsigned char read2 = 1;
	unsigned char read3 = 1;
	unsigned char read4 = 1;
	read1 = *p++;
	read2 = *p++;
	read3 = *p++;
	read4 = *p;
	sleep_jiffies (50* TIMER1_JIFFIES_PER_MS);
	return ((((u_int16_t)read1)<<12)|(((u_int16_t)read2)<<8))|(((u_int16_t)(read3)<<4)|(read4));
}
Exemplo n.º 2
0
void
nRFCMD_Init (void)
{
	/* update CPU default pin settings */
	CONFIG_PIN_CSN = 1;
	CONFIG_PIN_CE = 0;
	CONFIG_PIN_MOSI = 0;
	CONFIG_PIN_SCK = 0;

	sleep_jiffies (JIFFIES_PER_MS (2));

	/* send initialization macro to RF chip */
	nRFCMD_Macro (g_MacroInitialization);
}
Exemplo n.º 3
0
void flash_store(unsigned char fb[8])
{
	FCTL2 = FWKEY + FSSEL1 + FN1;     // MCLK/3 for Flash Timing Generator
	flash_clear();            // Block must always be cleared before writing
	
	char *Flash_ptr;
	Flash_ptr = (char *) 0x1001;      //Point to Info Flash segment D
	
	FCTL3 = FWKEY;                            // Clear Lock bit
	FCTL1 = FWKEY + WRT;                      // Set WRT bit for write operation
	
	*Flash_ptr++ = fb[0];  //OID 
	*Flash_ptr++ = fb[1];
	*Flash_ptr++ = fb[2];
	*Flash_ptr++ = fb[3];  //OID
	*Flash_ptr++ = fb[4];  //CodeBlock
	*Flash_ptr++ = fb[5];
	*Flash_ptr++ = fb[6];
	*Flash_ptr++ = fb[7];  //CodeBlock
	
	FCTL1 = FWKEY;                            // Clear WRT bit
	FCTL3 = FWKEY + LOCK;                     // Set LOCK bit
	sleep_jiffies (100* TIMER1_JIFFIES_PER_MS);
}
Exemplo n.º 4
0
void
nRFCMD_StartRX (void)
{
	nRFCMD_Macro (g_MacroStartRX);
	sleep_jiffies (TIMER1_JIFFIES_PER_MS);
}
Exemplo n.º 5
0
void
main (void)
{
	uint8_t j;

	/* configure CPU peripherals */
	OSCCON = CONFIG_CPU_OSCCON_SLOW;
	OPTION_REG = CONFIG_CPU_OPTION;
	PORTA = CONFIG_CPU_PORTA;
	PORTC = CONFIG_CPU_PORTC;
	TRISA = CONFIG_CPU_TRISA;
	TRISC = CONFIG_CPU_TRISC;
	WPUA = CONFIG_CPU_WPUA;
	WPUC = CONFIG_CPU_WPUC;
	ANSELA = CONFIG_CPU_ANSELA;
	ANSELC = CONFIG_CPU_ANSELC;

	INTE = 0;
	CONFIG_PIN_SENSOR = 0;
	CONFIG_PIN_TX_POWER = 0;

	/* initalize hardware */
	timer_init ();

	/* verify RF chip */
	nRFCMD_Init ();
	while(1)
	{
		nRFCMD_Channel (23);
		if(nRFCMD_RegGet (NRF_REG_RF_CH)==23)
		{
			nRFCMD_Channel (42);
			if(nRFCMD_RegGet (NRF_REG_RF_CH)==42)
				break;
		}

		CONFIG_PIN_LED = 1;
		sleep_jiffies (JIFFIES_PER_MS (25));
		CONFIG_PIN_LED = 0;
		sleep_jiffies (JIFFIES_PER_MS (25));
	}

	/* blink to show readyiness */
	for (j = 0; j <= 10; j++)
	{
		CONFIG_PIN_LED = j & 1;
		sleep_jiffies (JIFFIES_PER_MS (25));
	}

	// switch to listening channel
	nRFCMD_Channel (CONFIG_TRACKER_CHANNEL);

	while (1)
	{
/*
		nRFCMD_Listen (JIFFIES_PER_MS (500));

		if (!CONFIG_PIN_IRQ)
		{
			while ((nRFCMD_RegGet (NRF_REG_FIFO_STATUS) &
					NRF_FIFO_RX_EMPTY) == 0)
			{
				// receive raw data
				nRFCMD_RegRead (RD_RX_PLOAD, pkt, sizeof (pkt));
				nRFCMD_RegPut (NRF_REG_STATUS | WRITE_REG,
							   NRF_CONFIG_MASK_RX_DR);

				CONFIG_PIN_LED = 1;
				sleep_jiffies (JIFFIES_PER_MS (100));
			}
		}

		CONFIG_PIN_LED = 1;

		// blink for 1ms
		sleep_jiffies (JIFFIES_PER_MS (1));

		// disable LED
		CONFIG_PIN_LED = 0;
*/

		for(j=0;j<200;j++)
			pwm(10);

		for(j=0;j<200;j++)
			pwm(30);
	}
}
Exemplo n.º 6
0
void
sleep_2ms (void)
{
  sleep_jiffies (JIFFIES_PER_MS(2));
}
Exemplo n.º 7
0
void
nRFCMD_StartRX (void)
{
  nRFCMD_Macro (g_MacroStartRX);
  sleep_jiffies ( JIFFIES_PER_MS(1) );
}