summaryrefslogtreecommitdiff
path: root/n/es-2006/src/others.h
blob: 0e25348b1cd249ddb84fa77729485afa17392b90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#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 "common/io.h"

/* pin responsible for the color mode */
#define JACK_PIN                              0
#define SELECT_COLOR_PIN                      1
#define CONTACT_PIN                           2

/* (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);
}

/** 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)
{
    /* init DDRA (0 default) */
       
    /* DDR = 0 pin in mode IN */
    /* XXXX XXXX & 1111 1101 = XXXX XX0X */
    /* DDRA &= ~_BV(SELECT_COLOR_PIN); */

    /* pull up in mode in */
    PORTA |= _BV(SELECT_COLOR_PIN) | _BV(JACK_PIN) | _BV(CONTACT_PIN); 
}

#endif // others_h