OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_AT91SAM3U256_IAR/] [AT91Lib/] [peripherals/] [adc/] [adc.h] - Blame information for rev 580

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 580 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
/// \unit
32
///
33
/// !Purpose
34
///
35
/// Interface for configuration the Analog-to-Digital Converter (ADC) peripheral.
36
///
37
/// !Usage
38
///
39
/// -# Configurate the pins for ADC
40
/// -# Initialize the ADC with ADC_Initialize().
41
/// -# Select the active channel using ADC_EnableChannel()
42
/// -# Start the conversion with ADC_StartConversion()
43
//  -# Wait the end of the conversion by polling status with ADC_GetStatus()
44
//  -# Finally, get the converted data using ADC_GetConvertedData()
45
///
46
//------------------------------------------------------------------------------
47
#ifndef ADC_H
48
#define ADC_H
49
 
50
//------------------------------------------------------------------------------
51
//         Headers
52
//------------------------------------------------------------------------------
53
#include <utility/assert.h>
54
 
55
//------------------------------------------------------------------------------
56
//         Definitions
57
//------------------------------------------------------------------------------
58
#define ADC_CHANNEL_0 0
59
#define ADC_CHANNEL_1 1
60
#define ADC_CHANNEL_2 2
61
#define ADC_CHANNEL_3 3
62
#define ADC_CHANNEL_4 4
63
#define ADC_CHANNEL_5 5
64
#define ADC_CHANNEL_6 6
65
#define ADC_CHANNEL_7 7
66
 
67
//------------------------------------------------------------------------------
68
//         Macros function of register access
69
//------------------------------------------------------------------------------
70
#define ADC_CfgModeReg(pAdc, mode)  { \
71
            ASSERT(((mode)&0xF00000C0)== 0, "ADC Bad configuration ADC MR");\
72
            (pAdc)->ADC_MR = (mode);\
73
        }
74
 
75
#define ADC_GetModeReg(pAdc)                ((pAdc)->ADC_MR)
76
 
77
#define ADC_StartConversion(pAdc)           ((pAdc)->ADC_CR = AT91C_ADC_START)
78
 
79
#define ADC_SoftReset(pAdc)                 ((pAdc)->ADC_CR = AT91C_ADC_SWRST)
80
 
81
#define ADC_EnableChannel(pAdc, channel)    {\
82
            ASSERT(channel < 8, "ADC Channel not exist");\
83
            (pAdc)->ADC_CHER = (1 << (channel));\
84
        }
85
 
86
#define ADC_DisableChannel (pAdc, channel)  {\
87
            ASSERT((channel) < 8, "ADC Channel not exist");\
88
            (pAdc)->ADC_CHDR = (1 << (channel));\
89
        }
90
 
91
 
92
#define ADC_EnableIt(pAdc, mode)            {\
93
            ASSERT(((mode)&0xFFF00000)== 0, "ADC bad interrupt IER");\
94
            (pAdc)->ADC_IER = (mode);\
95
        }
96
 
97
#define ADC_DisableIt(pAdc, mode)           {\
98
            ASSERT(((mode)&0xFFF00000)== 0, "ADC bad interrupt IDR");\
99
            (pAdc)->ADC_IDR = (mode);\
100
        }
101
 
102
#define ADC_EnableDataReadyIt(pAdc)         ((pAdc)->ADC_IER = AT91C_ADC_DRDY)
103
 
104
#define ADC_GetStatus(pAdc)                 ((pAdc)->ADC_SR)
105
 
106
#define ADC_GetChannelStatus(pAdc)          ((pAdc)->ADC_CHSR)
107
 
108
#define ADC_GetInterruptMaskStatus(pAdc)    ((pAdc)->ADC_IMR)
109
 
110
#define ADC_GetLastConvertedData(pAdc)      ((pAdc)->ADC_LCDR)
111
 
112
 
113
//------------------------------------------------------------------------------
114
//         Exported functions
115
//------------------------------------------------------------------------------
116
extern void ADC_Initialize (AT91S_ADC *pAdc,
117
                     unsigned char idAdc,
118
                     unsigned char trgEn,
119
                     unsigned char trgSel,
120
                     unsigned char sleepMode,
121
                     unsigned char resolution,
122
                     unsigned int mckClock,
123
                     unsigned int adcClock,
124
                     unsigned int startupTime,
125
                     unsigned int sampleAndHoldTime);
126
//extern void ADC_CfgModeReg(AT91S_ADC *pAdc, unsigned int mode);
127
//extern unsigned int ADC_GetModeReg(AT91S_ADC *pAdc);
128
//extern void ADC_EnableChannel(AT91S_ADC *pAdc, unsigned int channel);
129
//extern void ADC_DisableChannel (AT91S_ADC *pAdc, unsigned int channel);
130
//extern unsigned int ADC_GetChannelStatus(AT91S_ADC *pAdc);
131
//extern void ADC_StartConversion(AT91S_ADC *pAdc);
132
//extern void ADC_SoftReset(AT91S_ADC *pAdc);
133
//extern unsigned int ADC_GetLastConvertedData(AT91S_ADC *pAdc);
134
extern unsigned int ADC_GetConvertedData(AT91S_ADC *pAdc, unsigned int channel);
135
//extern void ADC_EnableIt(AT91S_ADC *pAdc, unsigned int flag);
136
//extern void ADC_EnableDataReadyIt(AT91S_ADC *pAdc);
137
//extern void ADC_DisableIt(AT91S_ADC *pAdc, unsigned int flag);
138
//extern unsigned int ADC_GetStatus(AT91S_ADC *pAdc);
139
//extern unsigned int ADC_GetInterruptMaskStatus(AT91S_ADC *pAdc);
140
extern unsigned int ADC_IsInterruptMasked(AT91S_ADC *pAdc, unsigned int flag);
141
extern unsigned int ADC_IsStatusSet(AT91S_ADC *pAdc, unsigned int flag);
142
extern unsigned char ADC_IsChannelInterruptStatusSet(unsigned int adc_sr,
143
                                              unsigned int channel);
144
 
145
#endif //#ifndef ADC_H

powered by: WebSVN 2.1.0

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