comparison gsm-fw/bsp/abb+spi/spi_process.c @ 148:63750f70796d

gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 16 Nov 2013 19:03:37 +0000
parents
children e48ea5875df7
comparison
equal deleted inserted replaced
147:4ac657b95f52 148:63750f70796d
1 /*****************************************************************************/
2 /* */
3 /* Name spi_process.c */
4 /* */
5 /* Function this file contains the spi_process function, used to */
6 /* handle messages received in the SPI mailbox, and used to */
7 /* access the ABB. It is called by the spi task core. */
8 /* */
9 /* Version 0.1 */
10 /* */
11 /* Date Modification */
12 /* ------------------------------------ */
13 /* 20/08/2000 Create */
14 /* */
15 /* Author */
16 /* */
17 /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */
18 /*****************************************************************************/
19
20 #include "rvf/rvf_api.h"
21 #include "spi/spi_api.h"
22 #include "rvm/rvm_use_id_list.h"
23 #include "spi/spi_process.h"
24 #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE
25
26
27
28 //#ifndef _WINDOWS
29 //#include "iq.h"
30 //#endif
31
32 /*******************************************************************************
33 ** Function spi_process
34 **
35 *******************************************************************************/
36 UINT8 spi_process(T_RV_HDR * msg_ptr)
37 {
38 UINT16 data ;
39 // static UINT8 int_nb = 0;
40
41 if(msg_ptr != NULL)
42 {
43 switch (msg_ptr->msg_id)
44 {
45 case ABB_EXT_IRQ_EVT:
46 {
47 /* Call to the low-level driver function : interrupt status register reading */
48 data = ABB_Read_Register_on_page(PAGE0, ITSTATREG);
49
50 //#ifndef _WINDOWS
51 // SW workaround to avoid an ABB interrupt occuring to early after the application start.
52 // The first ABB interrupt is skipped.
53
54 // if((int_nb == 0) && (data == ADCEND_IT_STS))
55 // {
56 // int_nb++;
57
58 /* Unmask keypad interrupt */
59 // IQ_Unmask(IQ_EXT);
60 // }
61 // else
62 // {
63
64 /* Callback function */
65 // if(msg_ptr->callback_func != NULL)
66 // {
67 // msg_ptr->callback_func(&data);
68 // }
69 // }
70 //#else
71
72 /* Callback function */
73 if(msg_ptr->callback_func != NULL)
74 {
75 msg_ptr->callback_func(&data);
76 }
77 //#endif
78
79 rvf_free_buf ((void *) msg_ptr);
80
81 break;
82 }
83
84 case SPI_ABB_READ_EVT:
85 {
86 rvf_send_trace("SPI_task: SPI_READ_ABB_EVT received", 35, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
87
88 /* Call to the low-level driver function */
89 data = ABB_Read_Register_on_page(((T_SPI_READ *)msg_ptr)->page, ((T_SPI_READ *)msg_ptr)->address);
90
91 /* Callback function */
92 if(((T_SPI_READ *)msg_ptr)->os_hdr.callback_func != NULL)
93 {
94 ((T_SPI_READ *)msg_ptr)->os_hdr.callback_func(&data);
95 }
96
97 rvf_free_buf ((void *) msg_ptr);
98
99 return 0;
100 }
101
102 case SPI_ABB_WRITE_EVT:
103 {
104 rvf_send_trace("SPI_task: SPI_WRITE_ABB_EVT received", 36, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
105
106 /* Call to the low-level driver function */
107 ABB_Write_Register_on_page(((T_SPI_WRITE *)msg_ptr)->page, ((T_SPI_WRITE *)msg_ptr)->address, ((T_SPI_WRITE *)msg_ptr)->data);
108
109 rvf_free_buf ((void *) msg_ptr);
110
111 return 0;
112 }
113
114 case SPI_ABB_CONF_ADC_EVT:
115 {
116 rvf_send_trace("SPI_task: SPI_ABB_CONF_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
117
118 /* Call to the low-level driver function */
119 ABB_Conf_ADC(((T_SPI_ABB_CONF_ADC *)msg_ptr)->channels, ((T_SPI_ABB_CONF_ADC *)msg_ptr)->itval);
120
121 rvf_free_buf ((void *) msg_ptr);
122
123 return 0;
124 }
125
126 case SPI_ABB_READ_ADC_EVT:
127 {
128 rvf_send_trace("SPI_task: SPI_ABB_READ_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
129
130 /* Call to the low-level driver function */
131 ABB_Read_ADC(((T_SPI_ABB_READ_ADC *)msg_ptr)->Buff);
132
133 /* Callback function */
134 if(((T_SPI_ABB_READ_ADC *)msg_ptr)->callback_func != NULL)
135 {
136 ((T_SPI_ABB_READ_ADC *)msg_ptr)->callback_func();
137 }
138
139 rvf_free_buf ((void *) msg_ptr);
140
141 return 0;
142 }
143
144 default:
145 {
146 /* Unknown message has been received */
147 #ifdef RVM_PWR_SWE
148 rvf_send_trace("SPI_task : Received an unknown or a PWR message",47, NULL_PARAM ,
149 RV_TRACE_LEVEL_DEBUG_HIGH, SPI_USE_ID);
150 #else
151 rvf_send_trace("SPI_task : Received an unknown message",38, NULL_PARAM ,
152 RV_TRACE_LEVEL_DEBUG_HIGH, SPI_USE_ID);
153
154 rvf_free_buf ((void *) msg_ptr);
155 #endif
156
157 return 1;
158 }
159 } // end of switch
160 } // end of if (msg_ptr != NULL)
161 return 0;
162 }
163
164