Exemplo n.º 1
0
void config_IMU(void){
	if (twi_init() == TWI_SUCCESS){
		adxl_init();
		itg_init();
		} else {
		while(1){
			gpio_toggle_pin(LED2_GPIO);
			mdelay(5000);	//Delay 500.0 ms
		}
	}
}
Exemplo n.º 2
0
int main( void )
{
	int x = 0, y = 0, z = 0;
	double xyz[3] = {0};
	double ax = 0, ay = 0, az = 0;

	int led1_fd = open( LED1, O_WRONLY);
	int led2_fd = open( LED2, O_WRONLY);
	int led3_fd = open( LED3, O_WRONLY);
	int boot_fd = open( BOOT, O_WRONLY);

	if( adxl_init() < 0 )
	{
		perror( "ADXL initialization failed." );
		exit( 1 );
	}

	while( 1 )
	{
		write( led1_fd, "1", 2 );
		write( led2_fd, "0", 2 );
		write( led3_fd, "1", 2 );
		write( boot_fd, "0", 2 );

		usleep( 100 * 1000 );

		write( led1_fd, "0", 2 );
		write( led2_fd, "1", 2 );
		write( led3_fd, "0", 2 );
		write( boot_fd, "1", 2 );

		usleep( 100 * 1000 );

		/* Read & print RAW values from ADXL */
		adxl.readXYZ(&x, &y, &z);
		printf( "Raw values of X = %d, Y = %d, Z = %d\n\r", x, y, z );

		/* Calculate & print acceleration */
		adxl.getAcceleration(xyz);

		ax = xyz[0];
		ay = xyz[1];
		az = xyz[2];

		printf( "Acceleration of X = %lg, Y = %lg, Z = %lg\n\r", ax, ay, az );

		puts( "------------------------------------------------------\n\r" );
	}
}
Exemplo n.º 3
0
status_code_t configIMU(void){
	status_code_t status;
	
	if (twi_init() != TWI_SUCCESS){
		printf_mux("TWI init Error!");
		return -1;
	}
	
	status = adxl_init(ADXL_Low);
	if (status != STATUS_OK){
		printf_mux("ADXL init Error!");
		return status;
	}
	
	status = itg_init(ITG_Low);
	if (status != STATUS_OK){
		printf_mux("ITG init Error!");
		return status;
	}
	
	return status;
}