1 /********************************************************************
2 * Copyright (C) 2012-2013 Texas Instruments Incorporated.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33 /** @file dfe_flOpen.c
34 *
35 * @path $(CSLPATH)\src\ip\dfe
36 *
37 * @brief File for functional layer of CSL API dfeFl_Open()
38 *
39 *
40 */
42 #include <ti/drv/dfe/dfe_fl.h>
44 /** ============================================================================
45 * @n@b dfeFl_Open
46 *
47 * @b Description
48 * @n The API would open the Dfe module. It returns a valid handle
49 * which is used for subsequent Dfe APIs.
50 *
51 * @b Arguments
52 * @verbatim
53 pDfeObj Pointer to the Dfe object
54 dfeNum Dfe Instance number
55 pDfeParam Pointer to the parameter
56 status Pointer for the returning status
57 @endverbatim
58 *
59 * <b> Return Value </b>
60 * @li Valid DfeFl_Handle if oper properly
61 * @li NULL if any error
62 *
63 * <b> Pre Condition </b>
64 * @n None
65 *
66 * <b> Post Condition </b>
67 * @n 1. Dfe object structure is populated
68 * @n 2. The status is returned in the status variable. If status
69 * returned is
70 * @li DFE_FL_SOK Valid Dfe handle is returned
71 * @li DFE_FL_INVPARAMS The open command fails
72 *
73 * @b Reads
74 * @n None
75 *
76 * @b Writes
77 * @n None
78 *
79 * @b Example
80 * @verbatim
82 DfeFl_Context dfeCtx;
83 DfeFl_Param dfeParam;
84 DfeFl_Obj objDfe;
85 DfeFl_InstNum dfeInstNum;
86 DfeFl_Handle hDfe;
87 DfeFl_Status status = DFE_FL_SOK;
89 // open DFE
90 dfeFl_Init(&dfeCtx);
91 dfeParam.flags = 0;
92 dfeInstNum = CSL_DFE;
93 hDfe = dfeFl_Open(&objDfe, dfeInstNum, &dfeParam, &status);
95 @endverbatim
96 * ===========================================================================
97 */
98 DfeFl_Handle dfeFl_Open (
99 DfeFl_Obj *pDfeObj,
100 DfeFl_InstNum dfeNum,
101 DfeFl_Param *pDfeParam,
102 uint32_t dfeBaseAddr,
103 DfeFl_Status *status
104 )
105 {
106 // check parameter
107 if (status == NULL)
108 return NULL;
110 if(pDfeObj == NULL || dfeNum != 0)
111 {
112 *status = DFE_FL_INVPARAMS;
113 return NULL;
114 }
116 pDfeObj->regs = (DfeFl_RegsOvly)dfeBaseAddr;
117 pDfeObj->dfeNum = dfeNum;
118 return (DfeFl_Handle)pDfeObj;
119 }