diff --git a/sw/airborne/srf08.c b/sw/airborne/srf08.c deleted file mode 100644 index 440d8aeb03..0000000000 --- a/sw/airborne/srf08.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2005 Pascal Brisset, Antoine Drouin - * Copyright (C) 2002 Chris efstathiou hendrix@otenet.gr - * - * This file is part of paparazzi. - * - * paparazzi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * paparazzi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ -/** \file srf08.c - * \brief Basic library for SRF08 telemeter - * - */ - -#include "i2c_ap.h" -#include "srf08.h" - - -uint16_t srf08_range; - -/* Global Variables */ -static unsigned char address=SRF08_UNIT_0; - -static bool_t dummy_bool; - -/*###########################################################################*/ - -void srf08_init(void) -{ - unsigned int range=0; - i2c0_init(); - I2C_START_TX(address); - i2c0_transmit(0); - i2c0_transmit(0x51); - - do{ - i2c0_start(); - range=i2c_sla(address); - i2c0_stop(); - } while(range != I2C_NO_ERROR); /** !!!!!!!!!!!! WARNING : blocking wait */ - - - /** Setting the gain to the minimun value (to avoid echos ?) */ - i2c0_buf[0]=SRF08_SET_GAIN; - i2c0_buf[1]=SRF08_MIN_GAIN; - i2c0_send(address, 2, &dummy_bool); - - return; -} -/*###########################################################################*/ - -void srf08_initiate_ranging(void) { - i2c0_buf[0]=SRF08_COMMAND; - i2c0_buf[1]=SRF08_CENTIMETERS; - i2c0_send(address, 2, &dummy_bool); -} - -bool_t srf08_received, srf08_got; - -/** Ask the value to the device */ -void srf08_receive(void) { - i2c0_buf[0]=SRF08_ECHO_1; - srf08_received = FALSE; - i2c0_send(address, 1, &srf08_received); -} - -/** Read values on the bus */ -void srf08_read(void) { - srf08_got = FALSE; - i2c0_get(address, 2, &srf08_got); -} - -/** Copy the I2C buffer */ -void srf08_copy(void) { - srf08_range = i2c0_buf[0] << 8 | i2c0_buf[1]; -} - -void srf08_ping() -{ - uint8_t byte; - - srf08_initiate_ranging(); - while (!i2c0_idle); - - do { - i2c0_start(); - byte=i2c_sla(address); - i2c0_stop(); - } while(byte != I2C_NO_ERROR); - - - srf08_receive(); -} -/*###########################################################################*/ - -unsigned int srf08_read_register(unsigned char srf08_register) -{ - union i2c_union { - unsigned int rx_word; - unsigned char rx_byte[2]; - } i2c; - - - I2C_START_TX(address); - i2c0_transmit(srf08_register); - I2C_START_RX(address); - - /* get high byte msb first */ - if(srf08_register>=2) { - i2c.rx_byte[1]=i2c0_receive(I2C_CONTINUE); - } - - /* get low byte msb first */ - i2c.rx_byte[0]=i2c0_receive(I2C_QUIT); - - i2c0_stop(); - - return(i2c.rx_word); -} - diff --git a/sw/airborne/srf08.h b/sw/airborne/srf08.h deleted file mode 100644 index afb74f354c..0000000000 --- a/sw/airborne/srf08.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2005 Pascal Brisset, Antoine Drouin - * Copyright (C) 2002 Chris efstathiou hendrix@otenet.gr - * - * This file is part of paparazzi. - * - * paparazzi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * paparazzi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ -/** \file srf08.h - * \brief Basic library for SRF08 telemeter - * - */ - - -#ifndef SRF08_H -#define SRF08_H 1 - -/*###########################################################################*/ -/* START OF CONFIGURATION BLOCK */ -/*###########################################################################*/ -/* Normally you shouldn't need to change anything */ - -#define SRF08_UNIT_0 0xE0 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_1 0xE2 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_2 0xE4 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_3 0xE6 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_4 0xE8 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_5 0xEA /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_6 0xEC /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_7 0xEE /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_8 0xF0 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_9 0xF2 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_10 0xF4 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_11 0xF6 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_12 0xF8 /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_13 0xFA /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_14 0xFC /* the SRF08 MODULE I2C address */ -#define SRF08_UNIT_15 0xFE /* the SRF08 MODULE I2C address */ - -/*###########################################################################*/ -/* END OF CONFIGURATION BLOCK */ -/*###########################################################################*/ - -#define SRF08_I2C_BROADCAST_ADDRESS 0X00 - -#define SRF08_MIN_GAIN 0 /* sets gain to 94 */ -#define SRF08_MAX_GAIN 31 /* sets gain to 1025 */ -#define SRF08_MIN_RANGE 0 /* in millimeters */ -#define SRF08_MAX_RANGE 11008 /* in millimeters */ - -#define SRF08_INCHES 0X50 -#define SRF08_CENTIMETERS 0X51 -#define SRF08_MICROSECONDS 0X52 - -/* register positions */ -#define SRF08_COMMAND 0 -#define SRF08_SET_GAIN 1 -#define SRF08_LIGHT 1 -#define SRF08_ECHO_1 2 -#define SRF08_ECHO_2 4 -#define SRF08_ECHO_3 6 -#define SRF08_ECHO_4 8 -#define SRF08_ECHO_5 10 -#define SRF08_ECHO_6 12 -#define SRF08_ECHO_7 14 -#define SRF08_ECHO_8 16 -#define SRF08_ECHO_9 18 -#define SRF08_ECHO_10 20 -#define SRF08_ECHO_11 22 -#define SRF08_ECHO_12 24 -#define SRF08_ECHO_13 26 -#define SRF08_ECHO_14 28 -#define SRF08_ECHO_15 30 -#define SRF08_ECHO_16 32 -#define SRF08_ECHO_17 34 - -/* Function Declaration */ - -extern void srf08_select_unit(unsigned char srf08_address); -extern void srf08_init(void); - -extern void srf08_set_gain(unsigned char gain); -extern void srf08_set_range(unsigned int millimeters); - -extern void srf08_ping(void); -extern uint16_t srf08_read_register(unsigned char srf08_register); - -extern void srf08_change_i2c_address(unsigned char new_i2c_address); - -extern void srf08_initiate_ranging(void); -extern void srf08_receive(void); - -extern uint16_t srf08_range; -extern bool_t srf08_received, srf08_got; -/** Read values on the bus */ -extern void srf08_read(void); -/** Copy the I2C buffer */ -extern void srf08_copy(void); - -#endif /* #ifndef SRF08_H */ -