mdma.h File Reference


Detailed Description

MDMA driver for AVR32 UC3.

AVR32 MDMA driver module.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file mdma.h.

#include <avr32/io.h>
#include "compiler.h"

Go to the source code of this file.

Data Structures

struct  mdma_descriptor_t
 MDMA Descriptor Structure Definition. More...
struct  mdma_interrupt_t
 MDMA interrupts. More...
struct  mdma_opt_t
 MDMA Option Settings. More...

Defines

#define MDMA_DEFAULT_TIMEOUT   10000
 Default time-out value (number of attempts).
#define MDMA_INVALID_ARGUMENT   (-1)
 MDMA driver functions return value in case of invalid argument(s).
MDMA Burst Transfert Size
#define MDMA_16_BEAT_BURST   (3)
#define MDMA_4_BEAT_BURST   (1)
#define MDMA_8_BEAT_BURST   (2)
#define MDMA_SINGLE_TRANSFER_BURST   (0)
MDMA Channel Mode
#define MDMA_DESCRIPTOR_MODE   (1)
#define MDMA_SINGLE_TRANSFERT_MODE   (0)
Return Values
#define MDMA_FAILURE   -1
 Failure because of some unspecified reason.
#define MDMA_SUCCESS   0
 Successful completion.
MDMA Arbitration Mode
#define MDMA_FIXED_PRIORITY_MODE   (0)
#define MDMA_ROUND_ROBIN_MODE   (1)
MDMA Transfert Size
#define MDMA_TRANSFERT_SIZE_BYTE   (0)
#define MDMA_TRANSFERT_SIZE_HLFW   (1)
#define MDMA_TRANSFERT_SIZE_WORD   (2)

Functions

int mdma_channels_is_enable (volatile avr32_mdma_t *mdma, U32 channels)
 Check if a DMA Transfert for a Channel is enable.
void mdma_configure_interrupts (volatile avr32_mdma_t *mdma, const mdma_interrupt_t *bitfield)
 Enables various MDMA interrupts.
void mdma_descriptor_mode_xfert_init (volatile avr32_mdma_t *mdma, U32 channel, U32 *start_adress)
 Init a Descriptor Mode Transfert for a Channel.
unsigned long mdma_get_interrupt_settings (volatile avr32_mdma_t *mdma)
 MDMA interrupt settings.
void mdma_single_mode_xfert_init (volatile avr32_mdma_t *mdma, U32 channel, const mdma_opt_t *opt, U32 *src, U32 *dest)
 Init a Single Mode Transfert for a Channel.
void mdma_start_descriptor_xfert (volatile avr32_mdma_t *mdma, U32 channels, U8 arbitration)
 Start a Descriptor DMA Transfert for a Channel.
void mdma_start_single_xfert (volatile avr32_mdma_t *mdma, U32 channels, U8 arbitration)
 Start a Single DMA Transfert for a Channel.
int mdma_stop_channels (volatile avr32_mdma_t *mdma, U32 channels)
 Stop a DMA Transfert for a Channel.


Define Documentation

#define MDMA_16_BEAT_BURST   (3)

Definition at line 96 of file mdma.h.

#define MDMA_4_BEAT_BURST   (1)

Definition at line 94 of file mdma.h.

#define MDMA_8_BEAT_BURST   (2)

Definition at line 95 of file mdma.h.

#define MDMA_DEFAULT_TIMEOUT   10000

Default time-out value (number of attempts).

Definition at line 65 of file mdma.h.

Referenced by mdma_stop_channels().

#define MDMA_DESCRIPTOR_MODE   (1)

Definition at line 80 of file mdma.h.

Referenced by mdma_start_descriptor_xfert().

#define MDMA_FAILURE   -1

Failure because of some unspecified reason.

Definition at line 61 of file mdma.h.

Referenced by mdma_channels_is_enable(), and mdma_stop_channels().

#define MDMA_FIXED_PRIORITY_MODE   (0)

Definition at line 86 of file mdma.h.

Referenced by main().

#define MDMA_INVALID_ARGUMENT   (-1)

MDMA driver functions return value in case of invalid argument(s).

Definition at line 55 of file mdma.h.

#define MDMA_ROUND_ROBIN_MODE   (1)

Definition at line 87 of file mdma.h.

#define MDMA_SINGLE_TRANSFER_BURST   (0)

Definition at line 93 of file mdma.h.

#define MDMA_SINGLE_TRANSFERT_MODE   (0)

Definition at line 79 of file mdma.h.

Referenced by mdma_single_mode_xfert_init().

#define MDMA_SUCCESS   0

Successful completion.

Definition at line 60 of file mdma.h.

Referenced by mdma_channels_is_enable(), and mdma_stop_channels().

#define MDMA_TRANSFERT_SIZE_BYTE   (0)

Definition at line 71 of file mdma.h.

#define MDMA_TRANSFERT_SIZE_HLFW   (1)

Definition at line 72 of file mdma.h.

#define MDMA_TRANSFERT_SIZE_WORD   (2)

Definition at line 73 of file mdma.h.


Function Documentation

int mdma_channels_is_enable ( volatile avr32_mdma_t *  mdma,
U32  channels 
)

Check if a DMA Transfert for a Channel is enable.

Parameters:
mdma Pointer to the MDMA instance to access.
channels MDMA Channel to check
Return values:
MDMA_SUCCESS if channel is enable.
MDMA_FAILURE if channel is disable.

Definition at line 128 of file mdma.c.

References MDMA_FAILURE, and MDMA_SUCCESS.

00129 {
00130   if(mdma->cr&((1<<channels)<<(AVR32_MDMA_CR_CH0EN_OFFSET)))
00131       return MDMA_SUCCESS;
00132   else
00133     return MDMA_FAILURE;
00134 }

void mdma_configure_interrupts ( volatile avr32_mdma_t *  mdma,
const mdma_interrupt_t bitfield 
)

Enables various MDMA interrupts.

Parameters:
mdma Pointer to the MDMA instance to access.
bitfield The interrupt enable configuration.

Definition at line 58 of file mdma.c.

References mdma_interrupt_t::berr0, mdma_interrupt_t::berr1, mdma_interrupt_t::berr2, mdma_interrupt_t::berr3, mdma_interrupt_t::ch0c, mdma_interrupt_t::ch1c, mdma_interrupt_t::ch2c, and mdma_interrupt_t::ch3c.

Referenced by main().

00059 {
00060   Bool global_interrupt_enabled = Is_global_interrupt_enabled();
00061 
00062   // Enable the appropriate interrupts.
00063   mdma->ier            = bitfield->ch0c << AVR32_MDMA_IER_CH0C_OFFSET |
00064                          bitfield->ch1c << AVR32_MDMA_IER_CH1C_OFFSET |
00065                          bitfield->ch2c << AVR32_MDMA_IER_CH2C_OFFSET |
00066                          bitfield->ch3c << AVR32_MDMA_IER_CH3C_OFFSET |
00067                          bitfield->berr0 << AVR32_MDMA_IER_BERR0_OFFSET |
00068                          bitfield->berr1 << AVR32_MDMA_IER_BERR1_OFFSET |
00069                          bitfield->berr2 << AVR32_MDMA_IER_BERR2_OFFSET |
00070                          bitfield->berr3 << AVR32_MDMA_IER_BERR3_OFFSET ;
00071 
00072 
00073   // Disable the appropriate interrupts.
00074   if (global_interrupt_enabled) Disable_global_interrupt();
00075   mdma->idr            = (~bitfield->ch0c & 1)  << AVR32_MDMA_IDR_CH0C_OFFSET |
00076                          (~bitfield->ch1c & 1)  << AVR32_MDMA_IDR_CH1C_OFFSET |
00077                          (~bitfield->ch2c & 1)  << AVR32_MDMA_IDR_CH2C_OFFSET |
00078                          (~bitfield->ch3c & 1)  << AVR32_MDMA_IDR_CH3C_OFFSET |
00079                          (~bitfield->berr0 & 1) << AVR32_MDMA_IDR_BERR0_OFFSET |
00080                          (~bitfield->berr1 & 1) << AVR32_MDMA_IDR_BERR1_OFFSET |
00081                          (~bitfield->berr2 & 1) << AVR32_MDMA_IDR_BERR2_OFFSET |
00082                          (~bitfield->berr3 & 1) << AVR32_MDMA_IDR_BERR3_OFFSET ;
00083 
00084   if (global_interrupt_enabled) Enable_global_interrupt();
00085 
00086 }

void mdma_descriptor_mode_xfert_init ( volatile avr32_mdma_t *  mdma,
U32  channel,
U32 *  start_adress 
)

Init a Descriptor Mode Transfert for a Channel.

Parameters:
mdma Pointer to the MDMA instance to access.
channel MDMA Channel To configure
start_adress Start adress of the buffer

Definition at line 99 of file mdma.c.

Referenced by main().

00100 {
00101   mdma->descriptor_channel[channel].dsa   = (U32)start_adress;
00102   mdma->channel[channel].cdar             = (U32)start_adress;
00103 }

unsigned long mdma_get_interrupt_settings ( volatile avr32_mdma_t *  mdma  ) 

MDMA interrupt settings.

Parameters:
mdma Pointer to the MDMA instance to access.
Return values:
>=0 The interrupt enable configuration organized according to mdma_interrupt_t.
Interrupt Settings.

Definition at line 53 of file mdma.c.

00054 {
00055   return mdma->imr;
00056 }

void mdma_single_mode_xfert_init ( volatile avr32_mdma_t *  mdma,
U32  channel,
const mdma_opt_t opt,
U32 *  src,
U32 *  dest 
)

Init a Single Mode Transfert for a Channel.

Parameters:
mdma Pointer to the MDMA instance to access.
channel MDMA Channel To configure
opt Pointer to the MDMA option.
src Pointer to the source buffer.
dest Pointer to the destination buffer.

Definition at line 88 of file mdma.c.

References mdma_opt_t::burst_size, mdma_opt_t::count, MDMA_SINGLE_TRANSFERT_MODE, mdma_opt_t::size, and mdma_opt_t::tc_ienable.

00089 {
00090   mdma->channel[channel].ccr    = opt->count        << AVR32_MDMA_CCR0_TCNT_OFFSET  |
00091                                   opt->size         << AVR32_MDMA_CCR0_SIZE_OFFSET  |
00092                                   opt->burst_size   << AVR32_MDMA_CCR0_BURST_OFFSET |
00093                                   opt->tc_ienable   << AVR32_MDMA_CCR0_TCIE_OFFSET ;
00094   mdma->channel[channel].rar    = (U32)src ;
00095   mdma->channel[channel].war    = (U32)dest;
00096   mdma->cr                      = (MDMA_SINGLE_TRANSFERT_MODE)<< (channel) << (AVR32_MDMA_CR_CH0M_OFFSET) ;
00097 }

void mdma_start_descriptor_xfert ( volatile avr32_mdma_t *  mdma,
U32  channels,
U8  arbitration 
)

Start a Descriptor DMA Transfert for a Channel.

Parameters:
mdma Pointer to the MDMA instance to access.
channels MDMA Channel To configure
arbitration Pointer to the MDMA option.

Definition at line 111 of file mdma.c.

References MDMA_DESCRIPTOR_MODE.

Referenced by main().

00112 {
00113   mdma->CR.arb = arbitration;
00114   mdma->cr    |= ((1<<channels)<<AVR32_MDMA_CR_CH0EN_OFFSET)|(((MDMA_DESCRIPTOR_MODE)<<channels)<<AVR32_MDMA_CR_CH0M_OFFSET);
00115 }

void mdma_start_single_xfert ( volatile avr32_mdma_t *  mdma,
U32  channels,
U8  arbitration 
)

Start a Single DMA Transfert for a Channel.

Parameters:
mdma Pointer to the MDMA instance to access.
channels MDMA Channel To configure
arbitration Pointer to the MDMA option.

Definition at line 105 of file mdma.c.

00106 {
00107   mdma->CR.arb = arbitration;
00108   mdma->cr     = (1<<channels)<< (AVR32_MDMA_CR_CH0EN_OFFSET);
00109 }

int mdma_stop_channels ( volatile avr32_mdma_t *  mdma,
U32  channels 
)

Stop a DMA Transfert for a Channel.

Parameters:
mdma Pointer to the MDMA instance to access.
channels MDMA Channel To configure
Return values:
MDMA_FAILURE Timeout has expired/ MDMA_SUCCESS success.

Definition at line 117 of file mdma.c.

References MDMA_DEFAULT_TIMEOUT, MDMA_FAILURE, and MDMA_SUCCESS.

00118 {  
00119   int timeout = MDMA_DEFAULT_TIMEOUT;
00120 
00121   while (mdma->cr & (1<<channels)<< (AVR32_MDMA_CR_CH0DIS_OFFSET) )
00122   {
00123     if (!timeout--) return MDMA_FAILURE;
00124   } 
00125   return MDMA_SUCCESS; 
00126 }


Generated on Thu Dec 17 19:58:45 2009 for AVR32 - MDMA Driver by  doxygen 1.5.5