OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [Atmel/] [at91lib/] [peripherals/] [pio/] [pio.h] - Blame information for rev 608

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/* ----------------------------------------------------------------------------
2
 *         ATMEL Microcontroller Software Support
3
 * ----------------------------------------------------------------------------
4
 * Copyright (c) 2008, Atmel Corporation
5
 *
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions are met:
10
 *
11
 * - Redistributions of source code must retain the above copyright notice,
12
 * this list of conditions and the disclaimer below.
13
 *
14
 * Atmel's name may not be used to endorse or promote products derived from
15
 * this software without specific prior written permission.
16
 *
17
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20
 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 * ----------------------------------------------------------------------------
28
 */
29
 
30
//------------------------------------------------------------------------------
31
/// \dir
32
/// !Purpose
33
///
34
///     Definition of methods and structures for using PIOs in a transparent
35
///     way. The main purpose is to allow portability between several boards.
36
///
37
/// !Usage
38
///
39
///     -# To configure and use pins, see pio.h.
40
///     -# To enable and use interrupt generation on PIO status change, see
41
///      pio_it.h.
42
//------------------------------------------------------------------------------
43
 
44
//------------------------------------------------------------------------------
45
/// \unit
46
/// !Purpose
47
/// 
48
/// Simple & portable usage of PIO pins.
49
/// 
50
/// !Usage
51
/// 
52
/// -# Define a constant pin description array such as the following one:
53
///    \code
54
///       const Pin at91board_dbgu[] = {
55
///            {AT91C_BASE_PIOA, (1 << 30), PIO_PERIPH_A, PIO_DEFAULT},
56
///            {AT91C_BASE_PIOA, (1 << 31), PIO_PERIPH_A, PIO_DEFAULT},
57
///        };
58
///    \endcode
59
///    Alternatively, constants defined in the piodefs.h header file of the
60
///    board module can be used:
61
///    \code
62
///    const Pin at91board_dbgu[] = {PINS_DBGU};
63
///    const Pin at91board_usart[] = {PIN_USART0_RXD, PIN_USART0_TXD};
64
///    \endcode
65
///    It is possible to group multiple pins if they share the same
66
///    attributes, to save memory. Here is the previous DBGU example
67
///    rewritten in such a way:
68
///    \code
69
///    const Pin at91board_dbgu[] = {
70
///         {AT91C_BASE_PIOA, 0xC0000000, PIO_PERIPH_A, PIO_DEFAULT}
71
///    };
72
///    \endcode
73
/// -# For pins configured as inputs, the PIO controller must be enabled
74
///    in the PMC (*enabled by PIO_Configure at the moment*).
75
/// -# Configure a pin array by calling PIO_Configure, using
76
///    the PIO_LISTSIZE macro to calculate the array size if needed. Do not
77
///    forget to check the return value for any error.
78
/// -# Set and get the value of a pin using the PIO_Set, PIO_Clear and
79
///    PIO_Get methods.
80
//------------------------------------------------------------------------------
81
 
82
#ifndef PIO_H
83
#define PIO_H
84
 
85
//------------------------------------------------------------------------------
86
//         Headers
87
//------------------------------------------------------------------------------
88
 
89
#include <board.h>
90
 
91
//------------------------------------------------------------------------------
92
//         Definitions
93
//------------------------------------------------------------------------------
94
//------------------------------------------------------------------------------
95
/// \page "Pin types" 
96
/// This page lists the available types for a Pin instance (in its type field).
97
/// !Types
98
/// - PIO_PERIPH_A 
99
/// - PIO_PERIPH_B 
100
/// - PIO_INPUT 
101
/// - PIO_OUTPUT_0 
102
/// - PIO_OUTPUT_1 
103
 
104
/// The pin is controlled by the associated signal of peripheral A.
105
#define PIO_PERIPH_A                0
106
/// The pin is controlled by the associated signal of peripheral B.
107
#define PIO_PERIPH_B                1
108
/// The pin is an input.
109
#define PIO_INPUT                   2
110
/// The pin is an output and has a default level of 0.
111
#define PIO_OUTPUT_0                3
112
/// The pin is an output and has a default level of 1.
113
#define PIO_OUTPUT_1                4
114
//------------------------------------------------------------------------------
115
 
116
//------------------------------------------------------------------------------
117
/// \page "Pin attributes"
118
/// This page lists the valid values for the attribute field of a Pin instance.
119
/// !Attributes
120
/// - PIO_DEFAULT
121
/// - PIO_PULLUP
122
/// - PIO_DEGLITCH
123
/// - PIO_OPENDRAIN
124
 
125
/// Default pin configuration (no attribute).
126
#define PIO_DEFAULT                 (0 << 0)
127
/// The internal pin pull-up is active.
128
#define PIO_PULLUP                  (1 << 0)
129
/// The internal glitch filter is active.
130
#define PIO_DEGLITCH                (1 << 1)
131
/// The pin is open-drain.
132
#define PIO_OPENDRAIN               (1 << 2)
133
//------------------------------------------------------------------------------
134
 
135
/// Calculates the size of a Pin instances array. The array must be local (i.e.
136
/// not a pointer), otherwise the computation will not be correct.
137
#define PIO_LISTSIZE(list)    (sizeof(list) / sizeof(Pin))
138
 
139
//------------------------------------------------------------------------------
140
//         Types
141
//------------------------------------------------------------------------------
142
//------------------------------------------------------------------------------
143
/// Describes the type and attribute of one PIO pin or a group of similar pins.
144
typedef struct {
145
    /// Bitmask indicating which pin(s) to configure.
146
    unsigned int mask;
147
    /// Pointer to the PIO controller which has the pin(s).
148
    AT91S_PIO    *pio;
149
    /// Peripheral ID of the PIO controller which has the pin(s).
150
    unsigned char id;
151
    /// Pin type (see "Pin types").
152
    unsigned char type;
153
    /// Pin attribute (see "Pin attributes").
154
    unsigned char attribute;
155
} Pin;
156
//------------------------------------------------------------------------------
157
 
158
//------------------------------------------------------------------------------
159
//         Exported functions
160
//------------------------------------------------------------------------------
161
extern unsigned char PIO_Configure(const Pin *list, unsigned int size);
162
extern void PIO_Set(const Pin *pin );
163
extern void PIO_Clear(const Pin *pin);
164
extern unsigned char PIO_Get(const Pin *pin);
165
extern unsigned int PIO_GetISR(const Pin *pin);
166
extern unsigned char PIO_GetOutputDataStatus(const Pin *pin);
167
 
168
#endif //#ifndef PIO_H
169
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.