-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathudma.c
84 lines (70 loc) · 2.1 KB
/
udma.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* udma.c
*
* Created on: Nov 16, 2016
* Author: clausr
*/
#include "udma.h"
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_types.h"
#include "inc/hw_udma.h"
#include "driverlib/interrupt.h"
#include "driverlib/udma.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
static uint32_t g_udma_ui32Status = 0, g_udma_ui32uDMAErrCount = 0;
//*****************************************************************************
//
// The simple interrupt handler for uDMA errors. This interrupt will occur if
// the uDMA encounters a bus error while trying to perform a transfer. This
// handler just increments a counter if an error occurs.
//
//*****************************************************************************
void
uDMAErrorHandler(void) {
//
// Check for uDMA error bit
//
g_udma_ui32Status = MAP_uDMAErrorStatusGet();
//
// If there is a uDMA error, then clear the error and increment
// the error counter.
//
if(g_udma_ui32Status) {
MAP_uDMAErrorStatusClear();
g_udma_ui32uDMAErrCount++;
}
}
//*****************************************************************************
//
// The simple interrupt handler for uDMA errors. This interrupt will occur if
// the uDMA encounters a bus error while trying to perform a transfer. This
// handler just increments a counter if an error occurs.
//
//*****************************************************************************
inline uint32_t uDMAGetLastError() {
return g_udma_ui32Status;
}
inline uint32_t uDMAGetErrorCount() {
return g_udma_ui32uDMAErrCount;
}
void
uDMAInit(void) {
//
// Power up the uDMA
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
while (!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_UDMA));
//
// Enable the uDMA controller.
//
MAP_uDMAEnable();
//
// Point at the control table to use for channel control structures.
//
MAP_uDMAControlBaseSet(ui8DMAChannelControlStructure);
uDMAIntRegister(INT_UDMAERR, uDMAErrorHandler);
}