Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
main_core.c
Go to the documentation of this file.
1
17/*disclaimer*/
18
19// Section: Included Files
20
21#include <stddef.h>
22#include "../main_core_types.h"
23#include "../main_core_interface.h"
24#include "../main_core.h"
25
26// Section: File specific functions
27
28
29
30// Section: Driver Interface
31
34 .Deinitialize = &MAIN_CORE_Deinitialize,
35 .InterruptRequestGenerate = &MAIN_CORE_InterruptRequestGenerate,
36 .IsInterruptRequestAcknowledged = &MAIN_CORE_IsInterruptRequestAcknowledged,
37 .InterruptRequestComplete = &MAIN_CORE_InterruptRequestComplete,
38 .IsInterruptRequested = &MAIN_CORE_IsInterruptRequested,
39 .InterruptRequestAcknowledge = &MAIN_CORE_InterruptRequestAcknowledge,
40 .InterruptRequestAcknowledgeComplete= &MAIN_CORE_InterruptRequestAcknowledgeComplete,
41 .SystemStatusGet = &MAIN_CORE_SystemStatusGet,
42 .FIFORead = &MAIN_CORE_FIFORead,
43 .FIFOWrite = &MAIN_CORE_FIFOWrite,
44 .FIFOReadIsFull = &MAIN_CORE_FIFOReadIsFull,
45 .FIFOReadIsEmpty = &MAIN_CORE_FIFOReadIsEmpty,
46 .FIFOWriteIsFull = &MAIN_CORE_FIFOWriteIsFull,
47 .FIFOWriteIsEmpty = &MAIN_CORE_FIFOWriteIsEmpty,
48 .ProtocolRead = &MAIN_CORE_ProtocolRead,
49 .ProtocolWrite = &MAIN_CORE_ProtocolWrite,
50 .ProtocolIsFull = &MAIN_CORE_ProtocolIsFull,
51 .ProtocolIsEmpty = &MAIN_CORE_ProtocolIsEmpty,
52 .ProtocolCallbackRegister = NULL,
53 .ReadFIFODataReadyCallbackRegister = NULL,
54 .WriteFIFOEmptyCallbackRegister = NULL,
55 .FIFOOverFLowUnderFlowCallbackRegister = NULL,
56 .MainInitiatedCallbackRegister = NULL,
57 .MainBreakCallbackRegister = NULL,
58 .MainResetCallbackRegister = NULL,
59};
60
61// Section: MAIN_CORE Module APIs
62
64{
65 //MRSTIE disabled; MTSIACK disabled; STMIRQ disabled; RFITSEL Trigger data valid interrupt when 1st FIFO entry is written by Slave;
66 SI1CON = 0x0U;
67
68
69}
70
72{
73 SI1CON = 0x0U;
74
75
76}
77
79{
80 SI1CONbits.STMIRQ = 1U;
81}
82
84{
85 return(SI1STATbits.STMIACK);
86
87}
88
90{
91 SI1CONbits.STMIRQ = 0U;
92}
93
95{
96 return(SI1STATbits.MTSIRQ);
97}
99{
100 SI1CONbits.MTSIACK = 1U;
101}
102
104{
105 SI1CONbits.MTSIACK = 0U;
106}
107
109{
111
112 if(SI1STATbits.MSTRST)
113 {
115 }
116 else
117 {
118 switch(SI1STATbits.MSTPWR)
119 {
121 break;
122 case 1: systemStatus = MAIN_CORE_SYSTEM_STATUS_IDLE_MODE;
123 break;
124 case 2: systemStatus = MAIN_CORE_SYSTEM_STATUS_SLEEP_MODE;
125 break;
126 default:systemStatus = MAIN_CORE_SYSTEM_STATUS_RUNNING_STATE;
127 break;
128 }
129 }
130 return systemStatus;
131}
132
133uint16_t MAIN_CORE_FIFORead(uint16_t *pData, uint16_t wordCount)
134{
135 uint16_t readCountStatus = 0U;
136
137 while(wordCount)
138 {
140 {
141 *pData++ = SRMWFDATA;
142 wordCount--;
143 readCountStatus++;
144 }
145 else
146 {
147 break;
148 }
149 }
150 return readCountStatus;
151}
152
153uint16_t MAIN_CORE_FIFOWrite(uint16_t *pData, uint16_t wordCount)
154{
155 uint16_t writeCountStatus = 0U;
156
157 while(wordCount)
158 {
160 {
161 SWMRFDATA = *pData++;
162 wordCount--;
163 writeCountStatus++;
164 }
165 else
166 {
167 break;
168 }
169 }
170 return writeCountStatus;
171}
172
173bool MAIN_CORE_ProtocolWrite(enum MAIN_CORE_PROTOCOLS protocolName, uint16_t *pData)
174{
175 bool status = false;
176 switch(protocolName)
177 {
178 default:
179 break;
180 }
181 return status;
182}
183
184bool MAIN_CORE_ProtocolRead(enum MAIN_CORE_PROTOCOLS protocolName, uint16_t *pData)
185{
186 bool status = false;
187 switch(protocolName)
188 {
189 case MSI1_ProtocolA:
191 {
192 pData[0] = SI1MBX0D;
193 pData[1] = SI1MBX1D;
194 pData[2] = SI1MBX2D;
195 pData[3] = SI1MBX3D;
196 pData[4] = SI1MBX4D;
197
198 status = true;
199 }
200 else
201 {
202 status = false;
203 }
204 break;
205 case MSI1_ProtocolB:
207 {
208 pData[0] = SI1MBX5D;
209 pData[1] = SI1MBX6D;
210 pData[2] = SI1MBX7D;
211 pData[3] = SI1MBX8D;
212 pData[4] = SI1MBX9D;
213 pData[5] = SI1MBX10D;
214 pData[6] = SI1MBX11D;
215 pData[7] = SI1MBX12D;
216 pData[8] = SI1MBX13D;
217 pData[9] = SI1MBX14D;
218
219 status = true;
220 }
221 else
222 {
223 status = false;
224 }
225 break;
226 default:
227 break;
228 }
229 return status;
230}
231
232
233
234
235
236
237
238
239
240
@ MSI1_ProtocolA
@ MSI1_ProtocolB
This is the generated driver header file for the MAIN_CORE driver.
This is the generated driver types header file for the MAIN_CORE driver.
@ MAIN_CORE_SYSTEM_STATUS_IN_RESET_STATE
@ MAIN_CORE_SYSTEM_STATUS_SLEEP_MODE
@ MAIN_CORE_SYSTEM_STATUS_IDLE_MODE
@ MAIN_CORE_SYSTEM_STATUS_NOT_IN_LOW_POWER_MODE
@ MAIN_CORE_SYSTEM_STATUS_RUNNING_STATE
size_t status
Definition uart1.c:99
MAIN_CORE_SYSTEM_STATUS
Defines the status enumeration for main_core.
static bool MAIN_CORE_FIFOReadIsEmpty(void)
This inline function checks whether the status of Read FIFO is Empty. Returns true if last read by Ma...
Definition main_core.h:275
static bool MAIN_CORE_FIFOWriteIsFull(void)
This inline function checks whether the status of Write FIFO is Full. Returns true if last write by M...
Definition main_core.h:288
uint16_t MAIN_CORE_FIFORead(uint16_t *pData, uint16_t wordCount)
This routine reads FIFO data sent from the Main Core.
Definition main_core.c:133
bool MAIN_CORE_IsInterruptRequestAcknowledged(void)
This routine returns the status of interrupt request acknowledge from the MAIN_CORE.
Definition main_core.c:83
uint16_t MAIN_CORE_FIFOWrite(uint16_t *pData, uint16_t wordCount)
This routine transfers FIFO data to Main Core.
Definition main_core.c:153
bool MAIN_CORE_IsInterruptRequested(void)
This routine returns the status of interrupt request from the MAIN_CORE.
Definition main_core.c:94
bool MAIN_CORE_ProtocolWrite(enum MAIN_CORE_PROTOCOLS protocolName, uint16_t *pData)
This routine writes data to mailbox.
Definition main_core.c:173
bool MAIN_CORE_ProtocolRead(enum MAIN_CORE_PROTOCOLS protocolName, uint16_t *pData)
This routine reads data from mailbox.
Definition main_core.c:184
enum MAIN_CORE_SYSTEM_STATUS MAIN_CORE_SystemStatusGet(void)
This routine returns Main system status.
Definition main_core.c:108
void MAIN_CORE_Initialize(void)
This routine initializes the MSI driver. This routine must be called before any other MSI routine is ...
Definition main_core.c:63
void MAIN_CORE_InterruptRequestAcknowledgeComplete(void)
This routine clears acknowledge for interrupt received from Main MSI.
Definition main_core.c:103
static bool MAIN_CORE_ProtocolIsFull(enum MAIN_CORE_PROTOCOLS protocolName)
This inline function checks whether mailbox is full. Returns true if New data are ready to read....
Definition main_core.h:335
void MAIN_CORE_InterruptRequestComplete(void)
This routine clears interrupt to MAIN_CORE.
Definition main_core.c:89
MAIN_CORE_PROTOCOLS
Defines the list of Protocols configured for MAIN_CORE_driver.
void MAIN_CORE_Deinitialize(void)
Deinitializes MAIN_CORE to POR values.
Definition main_core.c:71
static bool MAIN_CORE_FIFOWriteIsEmpty(void)
This inline function checks whether the status of Write FIFO is Empty. Returns true if last write by ...
Definition main_core.h:301
static bool MAIN_CORE_ProtocolIsEmpty(enum MAIN_CORE_PROTOCOLS protocolName)
This inline function checks whether mailbox is empty. Returns true if Protocol is empty indicating ma...
Definition main_core.h:362
void MAIN_CORE_InterruptRequestAcknowledge(void)
This routine acknowledges interrupt received from Main MSI.
Definition main_core.c:98
static bool MAIN_CORE_FIFOReadIsFull(void)
This inline function checks whether the status of Read FIFO is full. last write by Secondary core to ...
Definition main_core.h:262
void MAIN_CORE_InterruptRequestGenerate(void)
This routine generates interrupt to MAIN_CORE.
Definition main_core.c:78
const struct MAIN_CORE_INTERFACE MSIInterface
Structure object of type SEC_CORE_INTERFACE with the custom name given by the user in the Melody Driv...
Definition main_core.c:32
Structure containing the function pointers of MAIN_CORE driver.
void(* Initialize)(void)
Pointer to MAIN_CORE_Initialize.