1 /*
2 * bios6_edma3_rm_sample.h
3 *
4 * Header file for the Demo application for the EDMA3 Resource Manager.
5 *
6 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
7 *
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the
19 * distribution.
20 *
21 * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
39 #ifndef BIOS6_EDMA3_RM_SAMPLE_H_
40 #define BIOS6_EDMA3_RM_SAMPLE_H_
42 #include <ti/sysbios/knl/Semaphore.h>
44 #include <ti/sdo/edma3/rm/edma3_rm.h>
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 /* To enable debug traces in the EDMA3 sample app */
51 /* Nowhere this macro is used, undefined to remove Misra C warning */
53 /* #define EDMA3_DEBUG_PRINT */
55 #ifdef EDMA3_DEBUG_PRINT
56 #include <stdio.h>
57 #define EDMA3_DEBUG_PRINTF printf
58 #endif /* EDMA3_DEBUG_PRINT */
60 /**
61 * Cache line size on the underlying SoC. It needs to be modified
62 * for different cache line sizes, if the Cache is Enabled.
63 */
64 #define EDMA3_CACHE_LINE_SIZE_IN_BYTES (128u)
66 /* Error returned in case of buffers are not aligned on the cache boundary */
67 #define EDMA3_NON_ALIGNED_BUFFERS_ERROR (-1)
69 /* Error returned in case of data mismatch */
70 #define EDMA3_DATA_MISMATCH_ERROR (-2)
72 /**
73 * \brief EDMA3 Initialization
74 *
75 * This function initializes the EDMA3 Resource Manager for the given EDMA3 controller
76 * and opens a EDMA3 RM instance. It internally calls EDMA3_RM_create() and
77 * EDMA3_RM_open(), in that order.
78 *
79 * It also registers interrupt handlers for various EDMA3 interrupts like
80 * transfer completion or error interrupts.
81 *
82 * \param edma3Id [IN] EDMA3 Controller Instance Id (Hardware
83 * instance id, starting from 0)
84 * \param errorCode [IN/OUT] Error code while opening RM instance
85 * \return EDMA3_RM_Handle: If successfully opened, the API will return the
86 * associated RM's instance handle.
87 */
88 EDMA3_RM_Handle edma3init (uint32_t edma3Id, EDMA3_RM_Result *errorCode);
90 /**
91 * \brief EDMA3 De-initialization
92 *
93 * This function de-initializes the EDMA3 RM for the given EDMA3 controller
94 * and closes the previously opened EDMA3 RM instance. It internally calls
95 * EDMA3_RM_close and EDMA3_RM_delete(), in that order.
96 *
97 * It also un-registers the previously registered interrupt handlers for various
98 * EDMA3 interrupts.
99 *
100 * \param edma3Id [IN] EDMA3 Controller Instance Id (Hardware
101 * instance id, starting from 0)
102 * \param hEdma [IN] EDMA3 RM handle, returned while using
103 * edma3init().
104 * \return EDMA3_RM_SOK if success, else error code
105 */
106 EDMA3_RM_Result edma3deinit (uint32_t edma3Id, EDMA3_RM_Handle hEdma);
108 /**
109 * Counting Semaphore related functions (OS dependent) should be
110 * called/implemented by the application. A handle to the semaphore
111 * is required while opening the driver/resource manager instance.
112 */
114 /**
115 * \brief EDMA3 OS Semaphore Create
116 *
117 * This function creates a counting semaphore with specified
118 * attributes and initial value. It should be used to create a semaphore
119 * with initial value as '1'. The semaphore is then passed by the user
120 * to the EDMA3 RM for proper sharing of resources.
121 * \param initVal [IN] is initial value for semaphore
122 * \param attrs [IN] is the semaphore attributes ex: Fifo type
123 * \param hSem [OUT] is location to recieve the handle to just created
124 * semaphore
125 * \return EDMA3_RM_SOK if succesful, else a suitable error code.
126 */
127 EDMA3_RM_Result edma3OsSemCreate(int32_t initVal,
128 const Semaphore_Params *semParams,
129 EDMA3_OS_Sem_Handle *hSem);
131 /**
132 * \brief EDMA3 OS Semaphore Delete
133 *
134 * This function deletes or removes the specified semaphore
135 * from the system. Associated dynamically allocated memory
136 * if any is also freed up.
137 * \warning OsSEM services run in client context and not in a thread
138 * of their own. If there exist threads pended on a semaphore
139 * that is being deleted, results are undefined.
140 * \param hSem [IN] handle to the semaphore to be deleted
141 * \return EDMA3_RM_SOK if succesful else a suitable error code
142 */
143 EDMA3_RM_Result edma3OsSemDelete(EDMA3_OS_Sem_Handle hSem);
145 #ifdef __cplusplus
146 }
147 #endif /* extern "C" */
149 #endif