/* Copyright (c) 2007 The Information and Telecommunication Technology Center * (ITTC) at the University of Kansas * ALL RIGHTS RESERVED * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Alternatively, this software may be distributed under the terms of BSD * license. * * * Function definitions for reading data from the Parallax Sensors * * %Notes * * Author: Daniel Fokum, 20070529 */ /** * * @file Sensors.c * * @brief Function implementations for reading Parallax Sensors. * ****************************************************************************/ /* ---- Include Files ---------------------------------------------------- */ #include #include #include #include "Hardware.h" #include "Timer.h" #include "Delay.h" #include "Sensors.h" /* ---- Public Variables -------------------------------------------------- */ /* ---- Private Constants and Types --------------------------------------- */ /* ---- Private Variables ------------------------------------------------- */ /* ---- Private Function Prototypes --------------------------------------- */ /* ---- Functions --------------------------------------------------------- */ //*************************************************************************** /** * Reads data from the Parallax Ping Sensor */ uint8_t ReadPingSensor( uint8_t SensorIdx, uint16_t Dist[] ) { unsigned int ticks=0; SENSOR_ON( PING1 ); _delay_loop_1(26); //Pause for 5 microseconds SENSOR_OFF( PING1 ); DDRC = DDRC & (~(1<