FreeCalypso > hg > tcs211-l1-reconst
comparison chipsetsw/drivers/drv_app/spi/spi_env.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /****************************************************************************/ | |
2 /* */ | |
3 /* File Name: spi_env.c */ | |
4 /* */ | |
5 /* Purpose: This file contains definitions for RV manager related */ | |
6 /* functions used to get info, start and stop the SPI SWE. */ | |
7 /* */ | |
8 /* Version 0.1 */ | |
9 /* */ | |
10 /* Date Modification */ | |
11 /* ------------------------------------ */ | |
12 /* 20/08/2000 Create */ | |
13 /* */ | |
14 /* Author David Lamy-Charrier (dlamy@tif.ti.com) */ | |
15 /* */ | |
16 /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved*/ | |
17 /****************************************************************************/ | |
18 | |
19 #include "spi/spi_env.h" | |
20 #include "rv/general.h" | |
21 #include "rvm/rvm_gen.h" | |
22 #include "rvm/rvm_priorities.h" | |
23 #include "rvm/rvm_use_id_list.h" | |
24 #include <string.h> | |
25 | |
26 //extern T_RV_RET spi_core(void); | |
27 #include "spi/spi_task.h" | |
28 | |
29 | |
30 /* global pointer to the error function */ | |
31 static T_RVM_RETURN (*spi_error_ft)(T_RVM_NAME swe_name, T_RVM_RETURN error_cause, | |
32 T_RVM_ERROR_TYPE error_type,T_RVM_STRING error_msg); | |
33 | |
34 /* Global variables */ | |
35 T_SPI_GBL_INFO *SPI_GBL_INFO_PTR = NULL; | |
36 | |
37 | |
38 | |
39 /****************************************************************************** | |
40 * Function : spi_get_info | |
41 * | |
42 * Description : This function is called by the RV manager to learn | |
43 * spi requirements in terms of memory, SWEs... | |
44 * | |
45 * Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to fill | |
46 * containing infos related to the SPI SWE. | |
47 * | |
48 * Return : T_RVM_RETURN | |
49 * | |
50 * History : 0.1 (20-August-2000) | |
51 * | |
52 * | |
53 ******************************************************************************/ | |
54 T_RVM_RETURN spi_get_info(T_RVM_INFO_SWE * infoSWE) | |
55 { | |
56 | |
57 /* SWE info */ | |
58 | |
59 infoSWE->swe_type = RVM_SWE_TYPE_4; | |
60 infoSWE->type_info.type4.swe_use_id = SPI_USE_ID; | |
61 memcpy( infoSWE->type_info.type4.swe_name, "SPI", sizeof("SPI") ); | |
62 | |
63 infoSWE->type_info.type4.stack_size = SPI_STACK_SIZE; | |
64 infoSWE->type_info.type4.priority = RVM_SPI_TASK_PRIORITY; | |
65 | |
66 | |
67 /* memory bank info */ | |
68 infoSWE->type_info.type4.nb_mem_bank = 1; | |
69 | |
70 memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "SPI_PRIM", 9); | |
71 infoSWE->type_info.type4.mem_bank[0].initial_params.size = SPI_MB_PRIM_SIZE; | |
72 infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = SPI_MB_PRIM_WATERMARK; | |
73 | |
74 | |
75 /* linked SWE info */ | |
76 infoSWE->type_info.type4.nb_linked_swe = 0; | |
77 | |
78 | |
79 /* generic functions */ | |
80 infoSWE->type_info.type4.set_info = spi_set_info; | |
81 infoSWE->type_info.type4.init = spi_init; | |
82 infoSWE->type_info.type4.core = spi_core; | |
83 infoSWE->type_info.type4.stop = spi_stop; | |
84 infoSWE->type_info.type4.kill = spi_kill; | |
85 | |
86 /* Set the return path */ | |
87 infoSWE->type_info.type4.return_path.callback_func = NULL; | |
88 infoSWE->type_info.type4.return_path.addr_id = 0; | |
89 | |
90 return RV_OK; | |
91 } | |
92 | |
93 | |
94 /****************************************************************************** | |
95 * Function : spi_set_info | |
96 * | |
97 * Description : This function is called by the RV manager to inform | |
98 * the spi SWE about task_id, mb_id and error function. | |
99 * | |
100 * Parameters : - T_RVM_TASK_ID taskId: task_id. | |
101 * - T_RV_RETURN ReturnPath[], array of return path for linked SWE | |
102 * - T_RVF_MB_ID mbId[]: array of memory bank ids. | |
103 * - callback function to call in case of unrecoverable error. | |
104 * | |
105 * Return : T_RVM_RETURN | |
106 * | |
107 * History : 0.1 (20-August-2000) | |
108 * | |
109 * | |
110 ******************************************************************************/ | |
111 T_RVM_RETURN spi_set_info( T_RVF_ADDR_ID addr_id, | |
112 T_RV_RETURN ReturnPath[], | |
113 T_RVF_MB_ID mbId[], | |
114 T_RVM_RETURN (*callBackFct)(T_RVM_NAME SWEntName, | |
115 T_RVM_RETURN errorCause, | |
116 T_RVM_ERROR_TYPE errorType, | |
117 T_RVM_STRING errorMsg)) | |
118 { | |
119 T_RVF_MB_STATUS mb_status; | |
120 UINT16 i; | |
121 | |
122 rvf_send_trace("SPI : spi_set_info: try to init GLOBAL INFO SPI structure ... ",62, | |
123 NULL_PARAM, | |
124 RV_TRACE_LEVEL_DEBUG_LOW, | |
125 SPI_USE_ID); | |
126 | |
127 mb_status = rvf_get_buf(mbId[0],sizeof(T_SPI_GBL_INFO),(void **) &SPI_GBL_INFO_PTR); | |
128 | |
129 if (mb_status == RVF_RED) | |
130 { | |
131 rvf_send_trace("SPI : spi_set_info: Not enough memory to initiate GLOBAL INFO SPI structure ... ",80, | |
132 NULL_PARAM, | |
133 RV_TRACE_LEVEL_ERROR, | |
134 SPI_USE_ID); | |
135 | |
136 return (RVM_MEMORY_ERR); | |
137 } | |
138 | |
139 | |
140 /* store the pointer to the error function */ | |
141 spi_error_ft = callBackFct ; | |
142 | |
143 SPI_GBL_INFO_PTR->prim_id = mbId[0]; | |
144 | |
145 /* Store the addr id */ | |
146 SPI_GBL_INFO_PTR->addr_id = addr_id; | |
147 | |
148 for(i=0;i<MADC_NUMBER_OF_MEAS;i++) | |
149 { | |
150 SPI_GBL_INFO_PTR->adc_result[i] = 0; | |
151 } | |
152 | |
153 SPI_GBL_INFO_PTR->is_gsm_on = FALSE; | |
154 | |
155 SPI_GBL_INFO_PTR->SpiTaskReady = FALSE; | |
156 | |
157 /* spi task_id and spi mb_id could be retrieved later | |
158 using rvf_get_taskid and rvf_get_mb_id functions */ | |
159 | |
160 return RV_OK; | |
161 } | |
162 | |
163 | |
164 /****************************************************************************** | |
165 * Function : spi_init | |
166 * | |
167 * Description : This function is called by the RV manager to initialize the | |
168 * spi SWE before creating the task and calling spi_start. | |
169 * | |
170 * Parameters : None | |
171 * | |
172 * Return : T_RVM_RETURN | |
173 * | |
174 * History : 0.1 (20-August-2000) | |
175 * | |
176 * | |
177 ******************************************************************************/ | |
178 T_RVM_RETURN spi_init(void) | |
179 { | |
180 | |
181 return RV_OK; | |
182 } | |
183 | |
184 | |
185 | |
186 /****************************************************************************** | |
187 * Function : spi_stop | |
188 * | |
189 * Description : This function is called by the RV manager to stop the spi SWE. | |
190 * | |
191 * Parameters : None | |
192 * | |
193 * Return : T_RVM_RETURN | |
194 * | |
195 * History : 0.1 (20-August-2000) | |
196 * | |
197 * | |
198 ******************************************************************************/ | |
199 T_RVM_RETURN spi_stop(void) | |
200 { | |
201 /* other SWEs have not been killed yet, spi can send messages to other SWEs */ | |
202 | |
203 return RV_OK; | |
204 } | |
205 | |
206 | |
207 /****************************************************************************** | |
208 * Function : spi_kill | |
209 * | |
210 * Description : This function is called by the RV manager to kill the spi | |
211 * SWE, after the spi_stop function has been called. | |
212 * | |
213 * Parameters : None | |
214 * | |
215 * Return : T_RVM_RETURN | |
216 * | |
217 * History : 0.1 (20-August-2000) | |
218 * | |
219 * | |
220 ******************************************************************************/ | |
221 T_RVM_RETURN spi_kill (void) | |
222 { | |
223 /* free all memory buffer previously allocated */ | |
224 return RV_OK; | |
225 } | |
226 | |
227 | |
228 |