comparison bsp/abb+spi/abb_core_inth.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /******************************************************************************/
2 /* TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION */
3 /* */
4 /* Property of Texas Instruments -- For Unrestricted Internal Use Only */
5 /* Unauthorized reproduction and/or distribution is strictly prohibited. This*/
6 /* product is protected under copyright law and trade secret law as an*/
7 /* unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All*/
8 /* rights reserved. */
9 /* */
10 /* */
11 /* Filename : abb_core_inth.c */
12 /* */
13 /* Description : Functions to manage the ABB device interrupt. */
14 /* The Serial Port Interface is used to connect the TI */
15 /* Analog BaseBand (ABB). */
16 /* It is assumed that the ABB is connected as the SPI */
17 /* device 0, and ABB interrupt is mapped as external IT. */
18 /* */
19 /* Author : Pascal PUEL */
20 /* */
21 /* Version number : 1.2 */
22 /* */
23 /* Date and time : 07/02/03 */
24 /* */
25 /* Previous delta : Creation */
26 /* */
27 /******************************************************************************/
28 /* */
29 /* 17/12/03 */
30 /* The original abb_inth.c has been splitted between the actual abb_inth.c */
31 /* located in drv_apps directory and abb_inth_core.c located in drv_core */
32 /* directory. */
33 /* */
34 /******************************************************************************/
35
36 #include "../../include/config.h"
37 #include "../../include/sys_types.h"
38 #include "../../riviera/rv/general.h"
39 #include "../../nucleus/nucleus.h" // for NUCLEUS functions and types
40
41 #include "../../L1/include/l1_confg.h"
42 #include "../../L1/include/l1_macro.h"
43
44 #include <string.h>
45 #include "abb_core_inth.h"
46
47 #if (OP_L1_STANDALONE == 0)
48 #include "../../riviera/rv/rv_defined_swe.h" // for RVM_PWR_SWE
49 #endif
50
51 #if (OP_L1_STANDALONE == 1)
52 #include "../../L1/include/l1_types.h"
53 #endif
54
55 #include "../iq.h"
56
57 #include "../../gpf/inc/cust_os.h"
58 #include "../../L1/include/l1_signa.h"
59 #include "abb.h"
60
61 #if(OP_L1_STANDALONE == 0)
62 #include "../../riviera/rvm/rvm_use_id_list.h" // for SPI_USE_ID
63 #include "spi_env.h"
64 #include "spi_process.h" // for ABB_EXT_IRQ_EVT
65 #if 0 // FreeCalypso
66 #include "power/power.h"
67 #endif
68 #endif /* (OP_L1_STANDALONE == 0) */
69
70
71
72 // Size of the HISR stack associated to the ABB interrupt
73 #define ABB_HISR_STACK_SIZE (512)
74
75 static NU_HISR ABB_Hisr;
76 static char ABB_HisrStack[ABB_HISR_STACK_SIZE];
77
78
79
80 /*-----------------------------------------------------------------------*/
81 /* Create_ABB_HISR() */
82 /* */
83 /* This function is called from Layer1 during initialization process */
84 /* to create the HISR associated to the ABB External Interrupt. */
85 /* */
86 /*-----------------------------------------------------------------------*/
87 void Create_ABB_HISR(void)
88 {
89 // Fill the entire stack with the pattern 0xFE
90 memset (ABB_HisrStack, 0xFE, sizeof(ABB_HisrStack));
91
92 // Create the HISR which is called when an ABB interrupt is received.
93 NU_Create_HISR(&ABB_Hisr, "EXT_HISR", EXT_HisrEntry, 2, ABB_HisrStack, sizeof(ABB_HisrStack)); // lowest prty
94 }
95
96
97
98
99 /*-----------------------------------------------------------------------*/
100 /* Activate_ABB_HISR() */
101 /* */
102 /* This function is called from the interrupt handler to activate */
103 /* the HISR associated to the ABB External Interrupt. */
104 /* */
105 /*-----------------------------------------------------------------------*/
106 SYS_BOOL Activate_ABB_HISR(void)
107 {
108 if(NU_SUCCESS != NU_Activate_HISR(&ABB_Hisr))
109 {
110 return 1;
111 }
112 return 0;
113 }
114
115
116
117 /*-----------------------------------------------------------------------*/
118 /* EXT_HisrEntry() */
119 /* */
120 /* This function is called when an ABB interrupt (external interrupt) */
121 /* is received. */
122 /* In a "L1_STANDALONE" environment, this IT is related to ADC. */
123 /* In a complete system, this IT can have several causes. In that case, */
124 /* it sends a message to the SPI task, to handle the IT in calling a */
125 /* callback function. */
126 /* */
127 /*-----------------------------------------------------------------------*/
128 void EXT_HisrEntry(void)
129 {
130 #if (OP_L1_STANDALONE == 1)
131 // New code in order to test the ADC with the L1 standalone
132 UWORD16 data ;
133 xSignalHeaderRec *adc_msg;
134
135 // Call to the low-level driver function to read the interrupt status register.
136 data = ABB_Read_Register_on_page(PAGE1, ITSTATREG);
137
138 if(data & ADCEND_IT_STS) // end of ADC
139 {
140 adc_msg = os_alloc_sig(sizeof(T_CST_ADC_RESULT));
141 if(adc_msg != NU_NULL)
142 {
143 adc_msg->SignalCode = CST_ADC_RESULT;
144 ABB_Read_ADC(&((T_CST_ADC_RESULT *)(adc_msg->SigP))->adc_result[0]);
145 os_send_sig(adc_msg, RRM1_QUEUE);
146 }
147 }
148
149 #if (CHIPSET == 12)
150 // Unmask ABB ext interrupt
151 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT);
152 #else
153 // Unmask external (ABB) interrupt
154 IQ_Unmask(IQ_EXT);
155 #endif
156 #endif
157
158 #if (OP_L1_STANDALONE == 0)
159 T_RV_HDR *msgPtr;
160
161 if(SPI_GBL_INFO_PTR != NULL)
162 {
163 if(SPI_GBL_INFO_PTR->SpiTaskReady != FALSE)
164 {
165 if(rvf_get_buf (SPI_GBL_INFO_PTR->prim_id, sizeof (T_RV_HDR),(void **) &msgPtr) == RVF_RED)
166 {
167 rvf_send_trace ("SPI ERROR: ABB IQ External not possible. Reason: Not enough memory",
168 66,
169 NULL_PARAM,
170 RV_TRACE_LEVEL_ERROR,
171 SPI_USE_ID);
172
173 /* Unmask External interrupt */
174 #if (CHIPSET == 12)
175 // Unmask ABB ext interrupt
176 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT);
177 #else
178 // Unmask external (ABB) interrupt
179 IQ_Unmask(IQ_EXT);
180 #endif
181 }
182 else // enough memory => normal processing : a message is sent to the SPI task.
183 {
184 msgPtr->msg_id = ABB_EXT_IRQ_EVT;
185 msgPtr->dest_addr_id = SPI_GBL_INFO_PTR->addr_id;
186 msgPtr->callback_func = (CALLBACK_FUNC) spi_abb_read_int_reg_callback;
187
188 rvf_send_msg (SPI_GBL_INFO_PTR->addr_id, msgPtr);
189 }
190 }
191 else // SpiTaskReady is false
192 {
193 rvf_send_trace("ABB IQ External not possible. Reason: SPI Task not ready",56, NULL_PARAM,
194 RV_TRACE_LEVEL_ERROR, SPI_USE_ID);
195
196 /* Unmask External interrupt */
197 #if (CHIPSET == 12)
198 // Unmask ABB ext interrupt
199 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT);
200 #else
201 // Unmask external (ABB) interrupt
202 IQ_Unmask(IQ_EXT);
203 #endif
204 }
205 }
206 else // SPI_GBL_INFO_PTR = NULL
207 {
208 rvf_send_trace("ABB IQ External ERROR. Reason: SPI task not started",51, NULL_PARAM,
209 RV_TRACE_LEVEL_ERROR, SPI_USE_ID);
210
211 /* Unmask External interrupt */
212 #if (CHIPSET == 12)
213 // Unmask ABB ext interrupt
214 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT);
215 #else
216 // Unmask external (ABB) interrupt
217 IQ_Unmask(IQ_EXT);
218 #endif
219 }
220 #endif
221 }