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

Subversion Repositories openrisc

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

Go to most recent revision | 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
/// Set of functions and definition for using a SSC
35
/// peripheral.
36
///
37
/// !Usage
38
///
39
/// -# Configure the SSC to operate at a specific frequency by calling
40
///    SSC_Configure(). This function enables the peripheral clock of the SSC,
41
///    but not its PIOs.
42
/// -# Configure the transmitter and/or the receiver using the
43
///    SSC_ConfigureTransmitter() and SSC_ConfigureEmitter() functions.
44
/// -# Enable the PIOs or the transmitter and/or the received using
45
///    CHIP_EnableSSCTransmitter() and CHIP_EnableSSCReceiver().
46
/// -# Enable the transmitter and/or the receiver using SSC_EnableTransmitter()
47
///    and SSC_EnableReceiver()
48
/// -# Send data through the transmitter using SSC_Write() and SSC_WriteBuffer()
49
/// -# Receive data from the receiver using SSC_Read() and SSC_ReadBuffer()
50
/// -# Disable the transmitter and/or the receiver using SSC_DisableTransmitter()
51
///    and SSC_DisableReceiver()
52
//------------------------------------------------------------------------------
53
 
54
#ifndef SSC_H
55
#define SSC_H
56
 
57
//------------------------------------------------------------------------------
58
//         Headers
59
//------------------------------------------------------------------------------
60
 
61
#include <board.h>
62
 
63
//------------------------------------------------------------------------------
64
//         Definitions
65
//------------------------------------------------------------------------------
66
 
67
//------------------------------------------------------------------------------
68
/// \page "SSC configuration macros"
69
/// This page lists several macros which are used when configuring a SSC
70
/// peripheral.
71
/// 
72
/// !Macros
73
/// - SSC_STTDLY
74
/// - SSC_PERIOD
75
/// - SSC_DATLEN
76
/// - SSC_DATNB
77
/// - SSC_FSLEN
78
 
79
/// Calculates the value of the STTDLY field given the number of clock cycles
80
/// before the first bit of a new frame is transmitted.
81
#define SSC_STTDLY(bits)        (bits << 16)
82
 
83
/// Calculates the value of the PERIOD field of the Transmit Clock Mode Register
84
/// of an SSC interface, given the desired clock divider.
85
#define SSC_PERIOD(divider)     (((divider / 2) - 1) << 24)
86
 
87
/// Calculates the value of the DATLEN field of the Transmit Frame Mode Register
88
/// of an SSC interface, given the number of bits in one sample.
89
#define SSC_DATLEN(bits)        (bits - 1)
90
 
91
/// Calculates the value of the DATNB field of the Transmit Frame Mode Register
92
/// of an SSC interface, given the number of samples in one frame.
93
#define SSC_DATNB(samples)      ((samples -1) << 8)
94
 
95
/// Calculates the value of the FSLEN field of the Transmit Frame Mode Register
96
/// of an SSC interface, given the number of transmit clock periods that the 
97
/// frame sync signal should take.
98
#define SSC_FSLEN(periods)      ((periods - 1) << 16)
99
//------------------------------------------------------------------------------
100
 
101
//------------------------------------------------------------------------------
102
//         Exported functions
103
//------------------------------------------------------------------------------
104
extern void SSC_Configure(AT91S_SSC *ssc,
105
                                 unsigned int id,
106
                                 unsigned int bitRate,
107
                                 unsigned int masterClock);
108
extern void SSC_ConfigureTransmitter(AT91S_SSC *ssc,
109
                                            unsigned int tcmr,
110
                                            unsigned int tfmr);
111
extern void SSC_ConfigureReceiver(AT91S_SSC *ssc,
112
                                         unsigned int rcmr,
113
                                         unsigned int rfmr);
114
 
115
extern void SSC_EnableTransmitter(AT91S_SSC *ssc);
116
extern void SSC_DisableTransmitter(AT91S_SSC *ssc);
117
extern void SSC_EnableReceiver(AT91S_SSC *ssc);
118
extern void SSC_DisableReceiver(AT91S_SSC *ssc);
119
 
120
extern void SSC_EnableInterrupts(AT91S_SSC *ssc, unsigned int sources);
121
extern void SSC_DisableInterrupts(AT91S_SSC *ssc, unsigned int sources);
122
 
123
extern void SSC_Write(AT91S_SSC *ssc, unsigned int frame);
124
extern unsigned char SSC_WriteBuffer(AT91S_SSC *ssc,
125
                                            void *buffer,
126
                                            unsigned int length);
127
extern unsigned int SSC_Read(AT91S_SSC *ssc);
128
extern unsigned char SSC_ReadBuffer(AT91S_SSC *ssc,
129
                                           void *buffer,
130
                                           unsigned int length);
131
 
132
#endif //#ifndef SSC_H
133
 

powered by: WebSVN 2.1.0

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