Exemple #1
0
void main(void)
{
	int i = 0;
	InitMicrocontroller();

	//initialize variables to known state
	for(i=0;i<8;i++){
		if(i%2)
			sensors.sensor[i] = 1988;
		else
			sensors.sensor[i] = 7705;
	}
	flags.bit.start_new_transmit = 1;
	flags.bit.wait_for_master = 1;
	init_fcu_packet(&sensor_tx_packet, RAW_SENSOR_DATA);
	fcu_tx_packet = &sensor_tx_packet;

	InitGpio(); //set gpio for general i/o pins, not peripheral pins.	
	InitSpi();  //sets gpio and all registers for spiA and spiB
	
	IER |= M_INT6; //turn on group 6 interrupts
	PieCtrlRegs.PIEIER6.all = 0x0F; // turn on all spi interrupts
	EINT;   // Enable Global interrupt INTM
	ERTM;   // Enable Global realtime interrupt DBGM //not sure what this is for

//	IMU_PWR_ON();
//	//wait for IMU_SENSE to power up
//	while(ADC_DRDY())
//		;

	//loop forever
	for(;;){
		if(flags.bit.start_new_transmit){
			SpiaRegs.SPITXBUF = 0xFA00;
			while(!SpiaRegs.SPISTS.bit.INT_FLAG){} //wait for tranfer to finish
			SpiaRegs.SPIRXBUF; //throw away data, clear INT_FLAG
			SpiaRegs.SPITXBUF = 0xCE00; //finish sending FACE
			while(!SpiaRegs.SPISTS.bit.INT_FLAG){} //wait for tranfer to finish
			SpiaRegs.SPIRXBUF; //throw away data, clear INT_FLAG
			
			SpiaRegs.SPICTL.bit.SPIINTENA = 1; //enable interrupts, the rest is interrupt driven.
			SpiaRegs.SPITXBUF = 0x0000; //start next transmission, will cause interrupt at finish.
			flags.bit.start_new_transmit = 0;
		}
		//only modify packet when we want to make a new packet and the SPI FIFO is 
		//disabled(means we are not in the middle of a transmission)
//		if(flags.bit.make_new_fcu_packet && flags.bit.wait_for_master){
//			flags.bit.make_new_fcu_packet = 0;	
//			make_fcu_packet(&sensor_tx_packet);
//		}
	}
}
Exemple #2
0
void main(void)
{
	int i = 0;
	InitMicrocontroller();

	//initialize variables to known state
	for(i=0;i<8;i++){
		sensors.sensor[i] = i;
	}
	flags.all = 0x0000; //clear flags
	flags.bit.want_new_adc_data = 1;
	flags.bit.wait_for_master = 1;
	
	init_fcu_packet(&sensor_tx_packet, RAW_SENSOR_DATA);
	fcu_tx_packet = &sensor_tx_packet;

	InitGpio(); //set gpio for general i/o pins, not peripheral pins.	
	InitSpi();  //sets gpio and all registers for spiA and spiB
	
	IER |= M_INT6 | M_INT11; //turn on group 6 and 11 interrupts
	PieCtrlRegs.PIEIER6.all = 0x0F; // turn on all spi interrupts
	PieCtrlRegs.PIEIER11.all = 0x03; // turn on CLA INT1 and INT2
	EINT;   // Enable Global interrupt INTM
	ERTM;   // Enable Global realtime interrupt DBGM //not sure what this is for

	IMU_PWR_ON();
	//wait for IMU_SENSE to power up
	while(ADC_DRDY())
		;

	//loop forever
	for(;;){
		if(flags.bit.want_new_adc_data && ADC_DRDY()){
			//load SPI TX FIFO to get ADC data.
			SpiaRegs.SPITXBUF = 0x0000;	
			SpiaRegs.SPITXBUF = 0x0000;	
			SpiaRegs.SPITXBUF = 0x0000;	
			SpiaRegs.SPITXBUF = 0x0000;	
		}
		//only modify packet when we want to make a new packet and we are not tx with master
		if(flags.bit.make_new_fcu_packet && flags.bit.wait_for_master){
			flags.bit.make_new_fcu_packet = 0;	
			make_fcu_packet(&sensor_tx_packet);
		}
	}
}
Exemple #3
0
int main(void)
{

/*~~~~~~~~~~~~~~~~*/

/*
 */

    DDRB = 0xFF;
    PORTB = 0xFF;
    DDRA = 0xFF;
    PORTA =0xFF;

    InitSpi();
    LcdInit();
    _delay_ms(1000);


    while(1)
    ;

    return 0;

}