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 Transfer 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 Transfer 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 Transfer 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 Transfer 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 Transfer for a Channel.
void mdma_start_descriptor_xfert (volatile avr32_mdma_t *mdma, U32 channels, U8 arbitration)
 Start a Descriptor DMA Transfer for a Channel.
void mdma_start_single_xfert (volatile avr32_mdma_t *mdma, U32 channels, U8 arbitration)
 Start a Single DMA Transfer for a Channel.
int mdma_stop_channels (volatile avr32_mdma_t *mdma, U32 channels)
 Stop a DMA Transfer 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 Transfer 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 127 of file mdma.c.

References MDMA_FAILURE, and MDMA_SUCCESS.

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

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 57 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().

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

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

Init a Descriptor Mode Transfer 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 98 of file mdma.c.

Referenced by main().

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

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 52 of file mdma.c.

00053 {
00054   return mdma->imr;
00055 }

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 Transfer 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 87 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.

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

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

Start a Descriptor DMA Transfer 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 110 of file mdma.c.

References MDMA_DESCRIPTOR_MODE.

Referenced by main().

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

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

Start a Single DMA Transfer 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 104 of file mdma.c.

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

int mdma_stop_channels ( volatile avr32_mdma_t *  mdma,
U32  channels 
)

Stop a DMA Transfer 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 116 of file mdma.c.

References MDMA_DEFAULT_TIMEOUT, MDMA_FAILURE, and MDMA_SUCCESS.

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


Generated on Fri Feb 19 02:25:24 2010 for AVR32 - MDMA Driver by  doxygen 1.5.5