]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - psdk_cust/pdk_k2g_1_0_1_0_eng/packages/ti/platform_org/evmk2g/platform_lib/src/evmc66x_dcan.c
Remove SPI LLD build artifacts
[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_0_eng / packages / ti / platform_org / evmk2g / platform_lib / src / evmc66x_dcan.c
1 /*
2  * Copyright (c) 2015, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
34 /**
35  *
36  *  \file  evmc66x_dcan.c
37  *
38  *  \brief This file contains C66x DCAN specific functions.
39  *
40  ******************************************************************************/
42 #include "platform_internal.h"
44 #if (PLATFORM_DCAN_IN)
46 /**
47  * \brief This function initializes DCAN module.
48  *
49  * This function should be called before using any other DCAN functions
50  *
51  */
52 void dcanInit(void)
53 {
54         int32_t ret;
56         /* Configure DCAN0 Tx as GPIO pin */
57         ret = pinMuxSetMode(PIN_NUM_127, PADCONFIG_MUX_MODE_QUATERNARY);
58         if(ret)
59         {
60                 IFPRINT(platform_write("ERROR:In configuring the %d pin\n",
61                                        PIN_NUM_127));
62         }
64     /* Configure DCAN0 Rx as DCAN pin */
65         ret = pinMuxSetMode(PIN_NUM_128, PADCONFIG_MUX_MODE_PRIMARY);
66         if(ret)
67         {
68                 IFPRINT(platform_write("ERROR:In configuring the %d pin\n",
69                                        PIN_NUM_128));
70         }
72     /* Configure DCAN1 Tx as GPIO pin */
73         ret = pinMuxSetMode(PIN_NUM_137, PADCONFIG_MUX_MODE_QUATERNARY);
74         if(ret)
75         {
76         IFPRINT(platform_write("ERROR:In configuring the %d pin\n",
77                                PIN_NUM_137));
78         }
80     /* Configure DCAN1 Rx as DCAN pin */
81         ret = pinMuxSetMode(PIN_NUM_138, PADCONFIG_MUX_MODE_SECONDARY);
82         if(ret)
83         {
84         IFPRINT(platform_write("ERROR:In configuring the %d pin\n",
85                                 PIN_NUM_138));
86         }
88         /* Set the direction for Tx pins */
89         ret = gpioSetDirection(GPIO_PORT_1, GPIO_PIN_56, GPIO_OUT);
90         if(ret)
91         {
92         IFPRINT(platform_write("Failed to set the direction of %d pin\n",
93                                GPIO_PIN_56));
94         }
96         ret = gpioSetDirection(GPIO_PORT_1, GPIO_PIN_66, GPIO_OUT);
97         if(ret)
98         {
99         IFPRINT(platform_write("Failed to set the direction of %d pin\n",
100                                GPIO_PIN_66));
101     }
103 #if 0
104     /* Set the direction for Rx pins */
105         ret = gpioSetDirection(GPIO_PORT_1, GPIO_PIN_57, GPIO_IN);
106         if(ret)
107         {
108                 IFPRINT(platform_write("Failed to set the direction of %d pin\n",
109                                                            GPIO_PIN_57));
110         }
112         ret = gpioSetDirection(GPIO_PORT_1, GPIO_PIN_67, GPIO_IN);
113         if(ret)
114         {
115         IFPRINT(platform_write("Failed to set the direction of %d pin\n",
116                                GPIO_PIN_67));
117         }
118 #endif
121 /**
122  *
123  * \brief  This Function toggle the pins between low and high
124  * \n      states with some delay
125  *
126  * \param  timeDelay  [IN]   Time delay between high and low states in usec
127  *
128  * \return
129  * \n      GPIO_RET_OK          - Requested operation is successful
130  * \n      INVALID_GPIO_PORT    - Invalid GPIO port number
131  * \n      INVALID_GPIO_NUMBER  - Invalid GPIO pin number
132  *
133  */
134 int16_t dcanTogglePins(uint32_t timeDealy)
136         uint16_t ret;
138     /* Set the pins to high */
139         ret = gpioSetOutput(GPIO_PORT_1, GPIO_PIN_56);
140     if(ret)
141     {
142         IFPRINT(platform_write("Error in setting the output of %d pin\n",
143                                GPIO_PIN_56));
144         goto err;
145     }
147 #if 0
148     ret = gpioSetOutput(GPIO_PORT_1, GPIO_PIN_57);
149     if(ret)
150     {
151         IFPRINT(platform_write("Error in setting the output of %d pin\n",
152                                GPIO_PIN_57));
153         goto err;
154     }
155 #endif
157     ret = gpioSetOutput(GPIO_PORT_1, GPIO_PIN_66);
158     if(ret)
159     {
160         IFPRINT(platform_write("Error in setting the output of %d pin\n",
161                                GPIO_PIN_66));
162         goto err;
163     }
165 #if 0
166     ret = gpioSetOutput(GPIO_PORT_1, GPIO_PIN_67);
167     if(ret)
168     {
169         IFPRINT(platform_write("Error in setting the output of %d pin\n",
170                                GPIO_PIN_67));
171         goto err;
172     }
173 #endif
175     platform_delay(timeDealy);
177     /* set the pins to low */
178     ret = gpioClearOutput( GPIO_PORT_1, GPIO_PIN_56);
179     if(ret)
180     {
182         IFPRINT(platform_write("Error in clearing the output of %d pin\n",
183                                GPIO_PIN_56));
184         goto err;
185     }
187 #if 0
188     ret = gpioClearOutput( GPIO_PORT_1, GPIO_PIN_57);
189     if(ret)
190     {
191         IFPRINT(platform_write("Error in clearing the output of %d pin\n",
192                                GPIO_PIN_57));
193         goto err;
194     }
195 #endif
197     ret = gpioClearOutput( GPIO_PORT_1, GPIO_PIN_66);
198     if(ret)
199     {
200         IFPRINT(platform_write("Error in clearing the output of %d pin\n",
201                                GPIO_PIN_66));
202         goto err;
203     }
205 #if 0
206     ret = gpioClearOutput( GPIO_PORT_1, GPIO_PIN_67);
207     if(ret)
208     {
209         IFPRINT(platform_write("Error in clearing the output of %d pin\n",
210                                GPIO_PIN_67));
211         goto err;
212     }
213 #endif
215     platform_delay(timeDealy);
217 err : return (int16_t)ret;
221 #endif /* #if (PLATFORM_DCAN_IN) */
223 /* Nothing past this point */