FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/spi/spi_task.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_task.c */ | 3 /* Name spi_task.c */ |
4 /* */ | 4 /* */ |
5 /* Function this file contains the main SPI function: spi_core. */ | 5 /* Function this file contains the main SPI function: spi_core. */ |
6 /* It contains the body of the SPI task. */ | 6 /* It contains the body of the SPI task. */ |
7 /* It will initialize the SPI and then wait for messages */ | 7 /* It will initialize the SPI and then wait for messages */ |
8 /* or functions calls. */ | 8 /* or functions calls. */ |
9 /* */ | 9 /* */ |
10 /* Version 0.1 */ | 10 /* Version 0.1 */ |
11 /* Author Candice Bazanegue */ | 11 /* Author Candice Bazanegue */ |
12 /* */ | 12 /* */ |
13 /* Date Modification */ | 13 /* Date Modification */ |
14 /* ------------------------------------ */ | 14 /* ------------------------------------ */ |
15 /* 20/08/2000 Create */ | 15 /* 20/08/2000 Create */ |
16 /* 01/09/2003 Modfication */ | 16 /* 01/09/2003 Modfication */ |
17 /* Author Pascal Puel */ | 17 /* Author Pascal Puel */ |
18 /* */ | 18 /* */ |
19 /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */ | 19 /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */ |
20 /*****************************************************************************/ | 20 /*****************************************************************************/ |
21 | 21 |
22 #ifndef _WINDOWS | 22 #ifndef _WINDOWS |
23 #include "chipset.cfg" | 23 #include "chipset.cfg" |
41 #include "pwr/pwr_process.h" | 41 #include "pwr/pwr_process.h" |
42 #include "pwr/pwr_env.h" | 42 #include "pwr/pwr_env.h" |
43 #endif | 43 #endif |
44 | 44 |
45 | 45 |
46 | |
47 /******************************************************************************* | 46 /******************************************************************************* |
48 ** Function spi_core | 47 ** Function spi_core |
49 ** | 48 ** |
50 ** Description Core of the spi task, which initiliazes the spi SWE and | 49 ** Description Core of the spi task, which initiliazes the spi SWE and |
51 ** waits for messages. | 50 ** waits for messages. |
52 ** | 51 ** |
53 *******************************************************************************/ | 52 *******************************************************************************/ |
54 T_RV_RET spi_core(void) | 53 T_RV_RET spi_core(void) |
55 { | 54 { |
56 BOOLEAN error_occured = FALSE; | 55 BOOLEAN error_occured = FALSE; |
57 T_RV_HDR * msg_ptr; | 56 T_RV_HDR * msg_ptr; |
58 | 57 |
59 rvf_send_trace("SPI_task: Initialization", 24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); | 58 rvf_send_trace("SPI_task: Initialization", 24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID); |
60 SPI_GBL_INFO_PTR->SpiTaskReady = TRUE; | 59 SPI_GBL_INFO_PTR->SpiTaskReady = TRUE; |
61 | 60 |
62 #ifndef _WINDOWS | 61 #ifndef _WINDOWS |
63 /* Unmask External Interrupt once the SPI task is started */ | 62 /* Unmask External Interrupt once the SPI task is started */ |
64 #if (CHIPSET == 12) | 63 #if (CHIPSET == 12) |
66 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT); | 65 F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT); |
67 #else | 66 #else |
68 // Unmask external (ABB) interrupt | 67 // Unmask external (ABB) interrupt |
69 IQ_Unmask(IQ_EXT); | 68 IQ_Unmask(IQ_EXT); |
70 #endif | 69 #endif |
71 // Get the switch on cause from ABB. | 70 // Get the switch on cause from ABB. |
72 Set_Switch_ON_Cause(); | 71 Set_Switch_ON_Cause(); |
73 #endif | 72 #endif |
74 | 73 |
75 /* loop to process messages */ | 74 /* loop to process messages */ |
76 while (error_occured == FALSE) | 75 while (error_occured == FALSE) |
76 { | |
77 /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */ | |
78 UINT16 received_event = rvf_wait (0xffff, 0); | |
79 | |
80 /* If an event related to mailbox 0 is received, then */ | |
81 if (received_event & RVF_TASK_MBOX_0_EVT_MASK) | |
77 { | 82 { |
78 /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */ | 83 /* Read the message in the driver mailbox and delegate action..*/ |
79 UINT16 received_event = rvf_wait (0xffff, 0); | 84 msg_ptr = (T_RV_HDR *) rvf_read_mbox(SPI_MAILBOX); |
80 | |
81 /* If an event related to mailbox 0 is received, then */ | |
82 if (received_event & RVF_TASK_MBOX_0_EVT_MASK) | |
83 { | |
84 /* Read the message in the driver mailbox and delegate action..*/ | |
85 msg_ptr = (T_RV_HDR *) rvf_read_mbox(SPI_MAILBOX); | |
86 | 85 |
87 #ifdef RVM_PWR_SWE | 86 #ifdef RVM_PWR_SWE |
88 if(spi_process(msg_ptr)) | 87 if(spi_process(msg_ptr)) |
89 { | 88 { |
90 pwr_process(msg_ptr); | 89 pwr_process(msg_ptr); |
91 } | 90 } |
92 #else | 91 #else |
93 spi_process(msg_ptr); | 92 spi_process(msg_ptr); |
94 #endif | 93 #endif |
95 } | 94 } |
96 | 95 |
97 #ifdef RVM_PWR_SWE | 96 #ifdef RVM_PWR_SWE |
98 /* Timers */ | 97 /* Timers */ |
99 if (received_event & SPI_TIMER0_WAIT_EVENT) | 98 if (received_event & SPI_TIMER0_WAIT_EVENT) |
100 { | 99 { |
101 pwr_bat_test_timer_process(); | 100 pwr_bat_test_timer_process(); |
102 } | 101 } |
103 | 102 |
104 if (received_event & SPI_TIMER1_WAIT_EVENT) | 103 if (received_event & SPI_TIMER1_WAIT_EVENT) |
105 /* timer used to detect the end of the CI charge */ | 104 /* timer used to detect the end of the CI charge */ |
106 { | 105 { |
107 pwr_CI_charge_timer_process(); | 106 pwr_CI_charge_timer_process(); |
108 } | 107 } |
109 | 108 |
110 if (received_event & SPI_TIMER2_WAIT_EVENT) | 109 if (received_event & SPI_TIMER2_WAIT_EVENT) |
111 /* timer used to detect the end of the CV charge */ | 110 /* timer used to detect the end of the CV charge */ |
112 { | 111 { |
113 pwr_CV_charge_timer_process(); | 112 pwr_CV_charge_timer_process(); |
114 } | 113 } |
115 | 114 |
116 if (received_event & SPI_TIMER3_WAIT_EVENT) | 115 if (received_event & SPI_TIMER3_WAIT_EVENT) |
117 /* timer used to check the battery discharge level */ | 116 /* timer used to check the battery discharge level */ |
118 { | 117 { |
119 pwr_discharge_timer_process(); | 118 pwr_discharge_timer_process(); |
120 } | 119 } |
121 #endif | 120 #endif |
122 } // end of while | 121 } // end of while |
123 return RV_OK; | 122 return RV_OK; |
124 } | 123 } |
125 | 124 |
126 | 125 |
127 | |
128 /********************************************************************************** | 126 /********************************************************************************** |
129 * Function : spi_adc_on | 127 * Function : spi_adc_on |
130 * | 128 * |
131 * Description : Put the variable is_adc_on of the T_SPI_GBL_INFO structure to TRUE. | 129 * Description : Put the variable is_adc_on of the T_SPI_GBL_INFO structure to TRUE. |
132 * This variable is used for the battery management. | 130 * This variable is used for the battery management. |
133 * This function is called by the CST entity. | 131 * This function is called by the CST entity. |
134 * | 132 * |
135 * Parameters : None | 133 * Parameters : None |
136 * | 134 * |
137 * Return : None | 135 * Return : None |