Beispiel #1
0
/*____________________________________________________________________________*/
int main (void)
{
    /*** LOCAL VARIABLES ***/    

    /*** CONFIGURE OSCILLATOR ***/
    SET_FreqOsc( FRCDIV_1MHZ );                         //Set frequency of 1 MHZ
    
    /*** CONFIGURE HARDWARE ****/
    Hardware_INIT();                                    //Initialise Hardware functions
    Hardware.ConfigPins_Default();                      //Configure Default Hardware for ELB

    /*** INITIALIZE PERIPHERAL ***/
    TIMER23_INIT(100, TMR_INT_PRI1);                    //Proivde timer period in millisecond
    UART1_INIT( M_9600Hz , M_BRGH_High , TX_INT_PRI0);  //Initialise UART1
    I2C1_INIT(400000, MI2C_INT_PRI0 );                  //Inilialize I2C1

    /*** APPLICATION CODE BEGINS ***/ 
    AMGP_INIT(READ_HEADER1,SEND_UART1USB);              //Select Header to mount sensor card and...
                                                        //...UART port to send data out (To be implemented, Modify this in AMGPSensor.h)
    AMGP.Config(Acc|Mag|Gyro|Pres);                        //Select the sensors to work with eg.(Acc|Mag|Pres)
    /*** ENTER ETERNITY ***/
    while(1)
    {
        /*** READ SENSOR DATA AFTER TIMER PERIOD ELAPSED ***/
        if(V_T23IntFlag_U8)                             // Timer period defined in the Timer init function...
        {                                               // ...the timer interrupt flag is set in ELB_ISR.c
            V_T23IntFlag_U8 = 0;                        // Clear the TIMER Interrupt flag variable
            AMGP.Read(Acc|Mag|Gyro|Pres|TempPres);      // Read selected Sensors Data
            AMGP.Send(Acc|Mag|Gyro|Pres|TempPres);      // Send sensors data Packet through selected UART

            V_Pitch_F32 = atan(AMGP.Data.AccY/AMGP.Data.AccZ); // Use sensors Data perfrom calcualtions
        }
    }
}
Beispiel #2
0
void ee24LCxx_hw_init(void)
{
	uint32_t delay, i;
	I2C1_INIT();

	for (i =0; i < 4; i++)
	{
		delay = 0xFFFFF;
		while (delay--);
	}

	ee_dev.init 	= ee24LCxx_init;
	ee_dev.open 	= ee24LCxx_open;
	ee_dev.close	= ee24LCxx_close;
	ee_dev.read 	= ee24LCxx_read;
	ee_dev.write	= ee24LCxx_write;
	ee_dev.control	= ee24LCxx_control;
	ee_dev.type 	= RT_Device_Class_Unknown;

	rt_device_register(&ee_dev, "eeprom", RT_DEVICE_FLAG_RDWR);
}