/* * POWER.c * * * Author: Jason Jenks * Date: created 12/03/01 * * Modified from MOIST.c which was modified from PHOTO.c * *================================================================= * Header from PHOTO.c *================================================================= * PHOTO.c - TOS abstraction of asynchronous digital photo sensor * * "Copyright (c) 1000 and The Regents of the University * of California. All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * * Authors: Jason Hill * modified: DEC 10/4/2000 function commented * */ #include "tos.h" #include "POWER.h" #define POWER_PORT 4 #define ROBOT_PIN 32 #define TOS_FRAME_TYPE POWER_frame TOS_FRAME_BEGIN(POWER_frame) { } TOS_FRAME_END(POWER_frame); char TOS_COMMAND(POWER_GET_DATA)(){ printf("Getting ADC Data\n"); return TOS_CALL_COMMAND(SUB_ADC_GET_DATA)(POWER_PORT); } char TOS_COMMAND(POWER_GET_BOT_HERE)(){ // return bit_is_set(PORTA, 5); printf("Retrieving BOT's presence\n"); return (inp(PINA) & ROBOT_PIN); } char TOS_COMMAND(POWER_INIT)(){ //ADC 4 cbi(PORTA, 4); // set pin to read cbi(DDRA, 4); // set port to be input cbi(PORTA, 5); // set pin to read for robot presence cbi(DDRA, 5); // Set pin to be input printf("Initialized power, about to init ADC\n"); return TOS_CALL_COMMAND(SUB_ADC_INIT)(); }