FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/spi/spi_process.c @ 260:34b7059b9337
drv_app/spi/*: code readability fixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 14 May 2021 02:13:47 +0000 |
parents | 365833d1d186 |
children |
comparison
equal
deleted
inserted
replaced
259:365833d1d186 | 260:34b7059b9337 |
---|---|
1 /*****************************************************************************/ | 1 /*****************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* Name spi_process.c */ | 3 /* Name spi_process.c */ |
4 /* */ | 4 /* */ |
5 /* Function this file contains the spi_process function, used to */ | 5 /* Function this file contains the spi_process function, used to */ |
6 /* handle messages received in the SPI mailbox, and 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. */ | 7 /* access the ABB. It is called by the spi task core. */ |
8 /* */ | 8 /* */ |
9 /* Version 0.1 */ | 9 /* Version 0.1 */ |
10 /* */ | 10 /* */ |
11 /* Date Modification */ | 11 /* Date Modification */ |
22 #include "rvm/rvm_use_id_list.h" | 22 #include "rvm/rvm_use_id_list.h" |
23 #include "spi/spi_process.h" | 23 #include "spi/spi_process.h" |
24 #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE | 24 #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE |
25 | 25 |
26 | 26 |
27 | |
28 //#ifndef _WINDOWS | |
29 //#include "iq.h" | |
30 //#endif | |
31 | |
32 /******************************************************************************* | 27 /******************************************************************************* |
33 ** Function spi_process | 28 ** Function spi_process |
34 ** | 29 ** |
35 *******************************************************************************/ | 30 *******************************************************************************/ |
36 UINT8 spi_process(T_RV_HDR * msg_ptr) | 31 UINT8 spi_process(T_RV_HDR * msg_ptr) |
37 { | 32 { |
38 UINT16 data ; | 33 UINT16 data ; |
39 // static UINT8 int_nb = 0; | |
40 | 34 |
41 if(msg_ptr != NULL) | 35 if(msg_ptr != NULL) |
42 { | 36 { |
43 switch (msg_ptr->msg_id) | 37 switch (msg_ptr->msg_id) |
44 { | 38 { |
45 case ABB_EXT_IRQ_EVT: | 39 case ABB_EXT_IRQ_EVT: |
46 { | 40 { |
47 /* Call to the low-level driver function : interrupt status register reading */ | 41 /* Call to the low-level driver function : interrupt status register reading */ |
48 data = ABB_Read_Register_on_page(PAGE0, ITSTATREG); | 42 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 | 43 |
72 /* Callback function */ | 44 /* Callback function */ |
73 if(msg_ptr->callback_func != NULL) | 45 if(msg_ptr->callback_func != NULL) |
74 { | 46 { |
75 msg_ptr->callback_func(&data); | 47 msg_ptr->callback_func(&data); |
76 } | 48 } |
77 //#endif | |
78 | 49 |
79 rvf_free_buf ((void *) msg_ptr); | 50 rvf_free_buf ((void *) msg_ptr); |
80 | 51 |
81 break; | 52 break; |
82 } | 53 } |
83 | 54 |
84 case SPI_ABB_READ_EVT: | 55 case SPI_ABB_READ_EVT: |
85 { | 56 { |
86 rvf_send_trace("SPI_task: SPI_READ_ABB_EVT received", 35, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | 57 rvf_send_trace("SPI_task: SPI_READ_ABB_EVT received", 35, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); |
87 | 58 |
88 /* Call to the low-level driver function */ | 59 /* 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); | 60 data = ABB_Read_Register_on_page(((T_SPI_READ *)msg_ptr)->page, ((T_SPI_READ *)msg_ptr)->address); |
90 | 61 |
95 } | 66 } |
96 | 67 |
97 rvf_free_buf ((void *) msg_ptr); | 68 rvf_free_buf ((void *) msg_ptr); |
98 | 69 |
99 return 0; | 70 return 0; |
100 } | 71 } |
101 | 72 |
102 case SPI_ABB_WRITE_EVT: | 73 case SPI_ABB_WRITE_EVT: |
103 { | 74 { |
104 rvf_send_trace("SPI_task: SPI_WRITE_ABB_EVT received", 36, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | 75 rvf_send_trace("SPI_task: SPI_WRITE_ABB_EVT received", 36, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); |
105 | 76 |
106 /* Call to the low-level driver function */ | 77 /* 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); | 78 ABB_Write_Register_on_page(((T_SPI_WRITE *)msg_ptr)->page, ((T_SPI_WRITE *)msg_ptr)->address, ((T_SPI_WRITE *)msg_ptr)->data); |
108 | 79 |
109 rvf_free_buf ((void *) msg_ptr); | 80 rvf_free_buf ((void *) msg_ptr); |
110 | 81 |
111 return 0; | 82 return 0; |
112 } | 83 } |
113 | 84 |
114 case SPI_ABB_CONF_ADC_EVT: | 85 case SPI_ABB_CONF_ADC_EVT: |
115 { | 86 { |
116 rvf_send_trace("SPI_task: SPI_ABB_CONF_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | 87 rvf_send_trace("SPI_task: SPI_ABB_CONF_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); |
117 | 88 |
118 /* Call to the low-level driver function */ | 89 /* 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); | 90 ABB_Conf_ADC(((T_SPI_ABB_CONF_ADC *)msg_ptr)->channels, ((T_SPI_ABB_CONF_ADC *)msg_ptr)->itval); |
120 | 91 |
121 rvf_free_buf ((void *) msg_ptr); | 92 rvf_free_buf ((void *) msg_ptr); |
122 | 93 |
123 return 0; | 94 return 0; |
124 } | 95 } |
125 | 96 |
126 case SPI_ABB_READ_ADC_EVT: | 97 case SPI_ABB_READ_ADC_EVT: |
127 { | 98 { |
128 rvf_send_trace("SPI_task: SPI_ABB_READ_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | 99 rvf_send_trace("SPI_task: SPI_ABB_READ_ADC_EVT received", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); |
129 | 100 |
130 /* Call to the low-level driver function */ | 101 /* Call to the low-level driver function */ |
131 ABB_Read_ADC(((T_SPI_ABB_READ_ADC *)msg_ptr)->Buff); | 102 ABB_Read_ADC(((T_SPI_ABB_READ_ADC *)msg_ptr)->Buff); |
132 | 103 |
137 } | 108 } |
138 | 109 |
139 rvf_free_buf ((void *) msg_ptr); | 110 rvf_free_buf ((void *) msg_ptr); |
140 | 111 |
141 return 0; | 112 return 0; |
142 } | 113 } |
143 | 114 |
144 default: | 115 default: |
145 { | 116 { |
146 /* Unknown message has been received */ | 117 /* Unknown message has been received */ |
147 #ifdef RVM_PWR_SWE | 118 #ifdef RVM_PWR_SWE |
148 rvf_send_trace("SPI_task : Received an unknown or a PWR message",47, NULL_PARAM , | 119 rvf_send_trace("SPI_task : Received an unknown or a PWR message",47, NULL_PARAM , |
149 RV_TRACE_LEVEL_DEBUG_HIGH, SPI_USE_ID); | 120 RV_TRACE_LEVEL_DEBUG_HIGH, SPI_USE_ID); |
150 #else | 121 #else |
153 | 124 |
154 rvf_free_buf ((void *) msg_ptr); | 125 rvf_free_buf ((void *) msg_ptr); |
155 #endif | 126 #endif |
156 | 127 |
157 return 1; | 128 return 1; |
158 } | 129 } |
159 } // end of switch | 130 } // end of switch |
160 } // end of if (msg_ptr != NULL) | 131 } // end of if (msg_ptr != NULL) |
161 return 0; | 132 return 0; |
162 } | 133 } |
163 | |
164 |