AVR32 MDMA driver module.
Definition in file mdma.c.
#include <avr32/io.h>
#include "compiler.h"
#include "mdma.h"
Go to the source code of this file.
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. |
int mdma_channels_is_enable | ( | volatile avr32_mdma_t * | mdma, | |
U32 | channels | |||
) |
Check if a DMA Transfer for a Channel is enable.
mdma | Pointer to the MDMA instance to access. | |
channels | MDMA Channel to check |
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.
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.
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.
mdma | Pointer to the MDMA instance to access. |
>=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.
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.
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.
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.
mdma | Pointer to the MDMA instance to access. | |
channels | MDMA Channel To configure |
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 }