20 struct process * dma_callback[4];
24 dma_init(
void) __banked
28 for(tmp_ptr = 0; tmp_ptr < 4; tmp_ptr++) {
29 dma_callback[tmp_ptr] = 0;
31 tmp_ptr = (uint16_t) &(dma_conf[0]);
33 DMA1CFGH = tmp_ptr >> 8;
85 dma_config2(uint8_t channel,
void *src,
dma_inc_t src_inc,
void *dst,
dma_inc_t dst_inc,
87 struct process * proc) __banked
90 if((!channel) || (channel > 4)) {
94 DMAIRQ &= ~(1 << channel);
98 dma_conf[channel].
src_h = ((uint16_t) src) >> 8;
99 dma_conf[channel].
src_l = ((uint16_t) src);
100 dma_conf[channel].
dst_h = ((uint16_t) dst) >> 8;
101 dma_conf[channel].
dst_l = ((uint16_t) dst);
102 dma_conf[channel].
len_h = vlen_mode + (length >> 8);
103 dma_conf[channel].
len_l = length;
104 dma_conf[channel].
t_mode = ((word_mode&0x1)<<7) | (t_mode << 5) | trigger;
105 dma_conf[channel].
addr_mode = (src_inc << 6) + (dst_inc << 4) + 2;
112 dma_callback[channel] = proc;
114 return (xDMAHandle)channel + 1;
126 dma_arm(xDMAHandle channel) __banked
128 uint8_t ch_id = ((uint8_t)channel);
129 if(!ch_id || (ch_id > 4)) {
132 DMAARM |= (1 << ch_id);
145 dma_abort(xDMAHandle channel) __banked
147 uint8_t ch_id = ((uint8_t) channel);
148 if(!ch_id || (ch_id > 4)) {
151 DMAARM = 0x80 + (1 << ch_id);
164 dma_trigger(xDMAHandle channel) __banked
166 uint8_t ch_id = ((uint8_t) channel);
167 if(!ch_id || (ch_id > 4)) {
170 DMAREQ |= (1 << ch_id);
183 dma_state(xDMAHandle channel) __banked
185 uint8_t ch_id = ((uint8_t)channel);
186 if(!ch_id || (ch_id > 4)) {
189 if((DMAIRQ &(1 << ch_id)) == 0) {
196 dma_config_print(xDMAHandle channel) __banked
198 uint8_t ch_id = channel - 1;
204 printf(
"DMA channel %d @ %x %x ", ch_id, (uint16_t) &(dma_conf[ch_id]) >> 8, (uint16_t) &(dma_conf[ch_id]) & 0xFF);
207 uint8_t *ptr = (uint8_t *)&(dma_conf[ch_id]);
208 for(i = 0; i< 8; i++) {
210 printf(
":%02x", *ptr++);