source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/wifiHD/src/SOFTWARE_FRAMEWORK/DRIVERS/PDCA/pdca.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 8.5 KB
Line 
1/* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
2
3/*This file is prepared for Doxygen automatic documentation generation.*/
4/*! \file *********************************************************************
5 *
6 * \brief PDCA driver for AVR32 UC3.
7 *
8 * This file defines a useful set of functions for the PDCA interface on AVR32
9 * devices.
10 *
11 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
12 * - Supported devices:  All AVR32 devices with a PDCA module.
13 * - AppNote:
14 *
15 * \author               Atmel Corporation: http://www.atmel.com \n
16 *                       Support and FAQ: http://support.atmel.no/
17 *
18 ******************************************************************************/
19
20/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions are met:
24 *
25 * 1. Redistributions of source code must retain the above copyright notice, this
26 * list of conditions and the following disclaimer.
27 *
28 * 2. Redistributions in binary form must reproduce the above copyright notice,
29 * this list of conditions and the following disclaimer in the documentation
30 * and/or other materials provided with the distribution.
31 *
32 * 3. The name of Atmel may not be used to endorse or promote products derived
33 * from this software without specific prior written permission.
34 *
35 * 4. This software may only be redistributed and used in connection with an Atmel
36 * AVR product.
37 *
38 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
39 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
40 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
41 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
42 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
48 *
49 */
50
51#ifndef _PDCA_H_
52#define _PDCA_H_
53
54#include <avr32/io.h>
55
56
57//! Size of PDCA transfer: byte.
58#define PDCA_TRANSFER_SIZE_BYTE               AVR32_PDCA_BYTE
59
60//! Size of PDCA transfer: half-word.
61#define PDCA_TRANSFER_SIZE_HALF_WORD          AVR32_PDCA_HALF_WORD
62
63//! Size of PDCA transfer: word.
64#define PDCA_TRANSFER_SIZE_WORD               AVR32_PDCA_WORD
65
66/*! \name PDCA Driver Status Codes
67 */
68//! @{
69#define PDCA_SUCCESS 0
70#define PDCA_INVALID_ARGUMENT -1
71//! @}
72
73/*! \name PDCA Transfer Status Codes
74 */
75//! @{
76#define PDCA_TRANSFER_ERROR                   AVR32_PDCA_TERR_MASK
77#define PDCA_TRANSFER_COMPLETE                AVR32_PDCA_TRC_MASK
78#define PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO  AVR32_PDCA_RCZ_MASK
79//! @}
80
81
82//! PDCA channel options.
83typedef struct
84{
85  //! Memory address.
86  volatile  void         *addr          ;
87  //! Transfer counter.
88            unsigned int  size          ;
89  //! Next memory address.
90  volatile  void         *r_addr        ;
91  //! Next transfer counter.
92            unsigned int  r_size        ;
93  //! Select peripheral ID.
94            unsigned int  pid           ;
95  //! Select the size of the transfer (byte, half-word or word).
96            unsigned int  transfer_size ;
97#if (defined AVR32_PDCA_120_H_INCLUDED ) || (defined AVR32_PDCA_121_H_INCLUDED ) || (defined AVR32_PDCA_122_H_INCLUDED )
98// Note: the options in this preprocessor section are only available from the PDCA IP version 1.2.0 on.
99  //! Enable (\c 1) or disable (\c 0) the transfer upon event trigger.
100            unsigned char etrig         ;
101#endif // #ifdef AVR32_PDCA_120_H_INCLUDED
102} pdca_channel_options_t;
103
104
105/*! \brief Get PDCA channel handler
106 *
107 * \param pdca_ch_number  PDCA channel
108 *
109 * \return channel handled or PDCA_INVALID_ARGUMENT
110 */
111extern volatile avr32_pdca_channel_t *pdca_get_handler(unsigned int pdca_ch_number);
112
113/*! \brief Set the channel configuration
114 *
115 * \param pdca_ch_number PDCA channel
116 * \param opt channel option
117 */
118extern int pdca_init_channel(unsigned int pdca_ch_number, const pdca_channel_options_t *opt);
119
120/*! \brief Get the PDCA channel transfer enable status
121 *
122 * \param pdca_ch_number PDCA channel
123 *
124 * \return \c 1 if channel transfer is enabled, else \c 0
125 */
126extern unsigned int pdca_get_channel_status(unsigned int pdca_ch_number);
127
128/*! \brief Disable the PDCA for the given channel
129 *
130 * \param pdca_ch_number PDCA channel
131 */
132extern void pdca_disable(unsigned int pdca_ch_number);
133
134/*! \brief Enable the PDCA for the given channel
135 *
136 * \param pdca_ch_number PDCA channel
137 */
138extern void pdca_enable(unsigned int pdca_ch_number);
139
140/*! \brief Get PDCA channel load size (or remaining size if transfer started)
141 *
142 * \param pdca_ch_number PDCA channel
143 *
144 * \return size           current size to transfer
145 */
146extern unsigned int pdca_get_load_size(unsigned int pdca_ch_number);
147
148/*! \brief Set PDCA channel load values
149 *
150 * \param pdca_ch_number PDCA channel
151 * \param addr           address where data to load are stored
152 * \param size           size of the data block to load
153 */
154extern void pdca_load_channel(unsigned int pdca_ch_number, volatile void *addr, unsigned int size);
155
156/*! \brief Get PDCA channel reload size
157 *
158 * \param pdca_ch_number PDCA channel
159 *
160 * \return size           current reload size
161 */
162extern unsigned int pdca_get_reload_size(unsigned int pdca_ch_number);
163
164/*! \brief Set PDCA channel reload values
165 *
166 * \param pdca_ch_number PDCA channel
167 * \param addr           address where data to load are stored
168 * \param size           size of the data block to load
169 */
170extern void pdca_reload_channel(unsigned int pdca_ch_number, volatile void *addr, unsigned int size);
171
172/*! \brief Set the peripheral function to use with the PDCA channel
173 *
174 * \param pdca_ch_number PDCA channel
175 * \param pid the peripheral ID
176 */
177extern void pdca_set_peripheral_select(unsigned int pdca_ch_number, unsigned int pid);
178
179/*! \brief Set the size of the transfer
180 *
181 * \param pdca_ch_number PDCA channel
182 * \param transfer_size size of the transfer (byte, half-word or word)
183 */
184extern void pdca_set_transfer_size(unsigned int pdca_ch_number, unsigned int transfer_size);
185
186#if (defined AVR32_PDCA_120_H_INCLUDED ) || (defined AVR32_PDCA_121_H_INCLUDED ) || (defined AVR32_PDCA_122_H_INCLUDED )
187// Note: the functions in this preprocessor section are only available from the PDCA IP version 1.2.0 on.
188
189/*! \brief Disable the event-triggered transfer feature
190 *
191 * \param pdca_ch_number PDCA channel
192 */
193extern void pdca_disable_event_trigger(unsigned int pdca_ch_number);
194
195/*! \brief Enable the event-triggered transfer feature
196 *
197 * \param pdca_ch_number PDCA channel
198 */
199extern void pdca_enable_event_trigger(unsigned int pdca_ch_number);
200
201#endif // #ifdef AVR32_PDCA_120_H_INCLUDED
202
203/*! \brief Disable PDCA transfer error interrupt
204 *
205 * \param pdca_ch_number PDCA channel
206 */
207extern void pdca_disable_interrupt_transfer_error(unsigned int pdca_ch_number);
208
209/*! \brief Enable PDCA transfer error interrupt
210 *
211 * \param pdca_ch_number PDCA channel
212 */
213extern void pdca_enable_interrupt_transfer_error(unsigned int pdca_ch_number);
214
215/*! \brief Disable PDCA transfer interrupt when completed (ie TCR and TCRR are both zero)
216 *
217 * \param pdca_ch_number PDCA channel
218 */
219extern void pdca_disable_interrupt_transfer_complete(unsigned int pdca_ch_number);
220
221/*! \brief Enable PDCA transfer interrupt when completed (ie TCR and TCRR are both zero)
222 *
223 * \param pdca_ch_number PDCA channel
224 */
225extern void pdca_enable_interrupt_transfer_complete(unsigned int pdca_ch_number);
226
227/*! \brief Disable PDCA transfer interrupt when TCRR reaches zero
228 *
229 * \param pdca_ch_number PDCA channel
230 */
231extern void pdca_disable_interrupt_reload_counter_zero(unsigned int pdca_ch_number);
232
233/*! \brief Enable PDCA transfer interrupt when TCRR reaches zero
234 *
235 * \param pdca_ch_number PDCA channel
236 */
237extern void pdca_enable_interrupt_reload_counter_zero(unsigned int pdca_ch_number);
238
239/*! \brief Get PDCA channel transfer status
240 *
241 * \param pdca_ch_number PDCA channel
242 *
243 * \return PDCA transfer status with the following bit-masks:\n
244 *           - \c PDCA_TRANSFER_ERROR;\n
245 *           - \c PDCA_TRANSFER_COMPLETE;\n
246 *           - \c PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO.
247 */
248extern unsigned long pdca_get_transfer_status(unsigned int pdca_ch_number);
249
250
251#endif  // _PDCA_H_
Note: See TracBrowser for help on using the repository browser.