#ifndef others_h #define others_h // others.h // es - Input/Output general purpose board. {{{ // // Copyright (C) 2006 Patrick Goncalves - (Dufour Jérémy) // // Robot APB Team/Efrei 2004. // Web: http://assos.efrei.fr/robot/ // Email: robot AT efrei DOT fr // // This program 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 of the License, or // (at your option) any later version. // // This program 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 this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // }}} #include "io.h" #include "common.h" #include "ack.h" /* pin responsible for the color mode */ #define JACK_PIN 0 #define SELECT_COLOR_PIN 1 #define CONTACT_PIN 2 // XXX Disable /* (to be set 1 <-> 0) */ #define BLUE_COLOR_GAME_MODE _BV(0) /* 0000 0000 = 0 */ #define RED_COLOR_GAME_MODE _BV(SELECT_COLOR_PIN) /* 0000 0010 = 2 */ /* READ PINA */ /* access to value of pins of PORTA */ #define GET_PIN_OF_PORTA(n) ( PINA & _BV(n) ) /** return the value of pin select color */ inline uint8_t others_selectcoul (void) { return GET_PIN_OF_PORTA (SELECT_COLOR_PIN); } /** return the value of pin jack */ inline uint8_t others_jack (void) { return !GET_PIN_OF_PORTA (JACK_PIN); } /** return the value of pin contact */ inline uint8_t others_contact (void) { return !GET_PIN_OF_PORTA (CONTACT_PIN); } /** Update ack if some contact happened ! */ inline void others_contact_update (void) { return; // XXX Remove useless part XXX // if (others_contact ()) // ack_set (ACK_CONTACT_FRONT); } /** Return the jack and the select_colour at the same time */ inline uint8_t other_jack_color (void) { return (PINA & 0x03); } /** Initialisation of color button (put select color pin in mode 'IN') */ inline void others_init(void) { /* pull up in mode in */ PORTA |= _BV(SELECT_COLOR_PIN) | _BV(JACK_PIN) | _BV(CONTACT_PIN); } #endif // others_h