add physical interrupt handler, handle physical layer interrupt and 5ms interrupt independently.

This commit is contained in:
Gatsby Van
2023-12-24 13:04:46 +08:00
parent 2a20921193
commit eba0147d2f
+42 -33
View File
@@ -69,6 +69,7 @@ MPC_CONFIG mpcConfig = {
static bool mpcStatusUpAssert = false; static bool mpcStatusUpAssert = false;
/************************** Function Prototypes ******************************/ /************************** Function Prototypes ******************************/
int SetupInterruptSystem(XScuGic* instPtr, uint32_t devId); int SetupInterruptSystem(XScuGic* instPtr, uint32_t devId);
void PhysicalIntr_Handler(void *callBackRef);
void PeriodicPull_Handler(void *callBackRef); void PeriodicPull_Handler(void *callBackRef);
#ifdef _MPC_CTRL #ifdef _MPC_CTRL
void MPC_IntrHandler(void* CallBackRef); void MPC_IntrHandler(void* CallBackRef);
@@ -134,29 +135,41 @@ int SetupInterruptSystem(XScuGic* instPtr, uint32_t devId){
* rising edge 0x03. * rising edge 0x03.
*/ */
// Initialize physical layer interrupt.
XScuGic_SetPriorityTriggerType(instPtr, PHY_INTR_ID, 0x00, 0x03);
// Connect the interrupt service routine isr1 to the interrupt controller
Status = XScuGic_Connect(instPtr, PHY_INTR_ID,
(Xil_ExceptionHandler) PhysicalIntr_Handler, (void *) phyInstPtr);
if (Status != SUCCESS) {
return Status;
}
// Initialize physical layer interrupt. // Initialize physical layer interrupt.
XScuGic_SetPriorityTriggerType(instPtr, PERIODIC_5MS_INTR_ID, 0x00, 0x03); XScuGic_SetPriorityTriggerType(instPtr, PERIODIC_5MS_INTR_ID, 0x00, 0x03);
// Connect the interrupt service routine isr1 to the interrupt controller // Connect the interrupt service routine isr1 to the interrupt controller
Status = XScuGic_Connect(instPtr, PERIODIC_5MS_INTR_ID, Status = XScuGic_Connect(instPtr, PERIODIC_5MS_INTR_ID,
(Xil_ExceptionHandler) PeriodicPull_Handler, (void *) instPtr); (Xil_ExceptionHandler) PeriodicPull_Handler, (void *) linkInstPtr);
if (Status != SUCCESS) { if (Status != SUCCESS) {
return Status; return Status;
} }
XScuGic_Enable(instPtr, PERIODIC_5MS_INTR_ID);
#ifdef _MPC_CTRL #ifdef _MPC_CTRL
// Initialize MPC interrupt. // Initialize MPC interrupt.
XScuGic_SetPriorityTriggerType(instPtr, MPC_RX_DONE_INTR_ID, 0x00, 0x03); XScuGic_SetPriorityTriggerType(instPtr, MPC_RX_DONE_INTR_ID, 0x00, 0x03);
// Connect the interrupt service routine isr1 to the interrupt controller // Connect the interrupt service routine isr1 to the interrupt controller
Status = XScuGic_Connect(instPtr, MPC_RX_DONE_INTR_ID, Status = XScuGic_Connect(instPtr, MPC_RX_DONE_INTR_ID,
(Xil_ExceptionHandler) MPC_IntrHandler, (void *) instPtr); (Xil_ExceptionHandler) MPC_IntrHandler, (void *) mpcInstPtr);
if (Status != XST_SUCCESS) { if (Status != XST_SUCCESS) {
return Status; return Status;
} }
XScuGic_Enable(instPtr, MPC_RX_DONE_INTR_ID); XScuGic_Enable(instPtr, MPC_RX_DONE_INTR_ID);
#endif #endif
XScuGic_Enable(instPtr, PHY_INTR_ID);
XScuGic_Enable(instPtr, PERIODIC_5MS_INTR_ID);
/* Initialize the exception table and register the interrupt controller /* Initialize the exception table and register the interrupt controller
* handler with the exception table * handler with the exception table
*/ */
@@ -185,7 +198,7 @@ void MPC_PCIESentStart(){
/** /**
* @brief Handler of mater pc contrl interrupt. * @brief Handler of mater pc contrl interrupt.
* *
* @param CallBackRef A pointer to corresponding frame UART instance. * @param CallBackRef A pointer to corresponding mpcInstPtr instance.
* *
* @return None. * @return None.
* *
@@ -195,22 +208,21 @@ void MPC_IntrHandler(void* CallBackRef) {
} }
#endif #endif
/****************************************************************************/ /*****************************************************************************/
/** /**
* This function is a interrupt service routine for IRQ_F2P[1:1], IRQ_F2P[1:1] * @brief Handler of physical layer interrupt.
* tells CPU that the data in OCM is ready!
* *
* @param callBackRef is the SCUGIC instance pointer. * @param CallBackRef A pointer to corresponding physical layer instance.
* *
* @return None. * @return None.
* *
* @note None. ******************************************************************************/
* void PhysicalIntr_Handler(void *callBackRef) {
*****************************************************************************/
void PeriodicPull_Handler(void *callBackRef) {
int32_t Status;
Phy_UpdateState(phyInstPtr);
uint32_t GpioConfig = XGpio_DiscreteRead(&configGpio, 2); uint32_t GpioConfig = XGpio_DiscreteRead(&configGpio, 2);
if(L2_isDataAvail(linkInstPtr) == true ){
GpioConfig^=0x00000001;
}
Phy_UpdateState(phyInstPtr);
if(phyInstPtr->TOR.curr == PHY_TOR_TX){ if(phyInstPtr->TOR.curr == PHY_TOR_TX){
switch(phyInstPtr->frameType.curr){ switch(phyInstPtr->frameType.curr){
case L1_1M2BPS_5MS_FRAME: case L1_1M2BPS_5MS_FRAME:
@@ -271,6 +283,20 @@ void PeriodicPull_Handler(void *callBackRef) {
break; break;
} }
} }
XGpio_DiscreteWrite(&configGpio, 2, GpioConfig);
}
/****************************************************************************/
/**
* Handler of periodic 5ms interrupt
*
* @param callBackRef is the linklayer instance pointer.
*
* @return None.
*
*****************************************************************************/
void PeriodicPull_Handler(void *callBackRef) {
int32_t Status;
Status = Linklayer_Proc(linkInstPtr); Status = Linklayer_Proc(linkInstPtr);
if(Status != SUCCESS){ if(Status != SUCCESS){
@@ -278,10 +304,6 @@ void PeriodicPull_Handler(void *callBackRef) {
_nop_(); _nop_();
} }
if(L2_isDataAvail(linkInstPtr) == true ){
GpioConfig^=0x00000001;
}
if (linkInstPtr->slotNum.next % DATA_STORE_INTERVAL == 1) { if (linkInstPtr->slotNum.next % DATA_STORE_INTERVAL == 1) {
mpcStatusUpAssert = true; mpcStatusUpAssert = true;
mpcRecord->frame1Cnt = mpcRecord->frame1Recv - mpcRecord->frame1CntLast; mpcRecord->frame1Cnt = mpcRecord->frame1Recv - mpcRecord->frame1CntLast;
@@ -303,11 +325,6 @@ void PeriodicPull_Handler(void *callBackRef) {
mpcRecord->frame7CntLast = mpcRecord->frame7Recv; mpcRecord->frame7CntLast = mpcRecord->frame7Recv;
mpcRecord->frame8CntLast = mpcRecord->frame8Recv; mpcRecord->frame8CntLast = mpcRecord->frame8Recv;
} }
// TODO: Dijian frequency pattern TX_RX State.
GpioConfig ^= 0x80000000;
GpioConfig = (phyInstPtr->TOR.next == PHY_TOR_TX) ? GpioConfig|0x40000000 : GpioConfig&0xBFFFFFFF;
XGpio_DiscreteWrite(&configGpio, 2, GpioConfig);
} // PhyIntr_Handler } // PhyIntr_Handler
/*****************************************************************************/ /*****************************************************************************/
@@ -392,18 +409,10 @@ int main(void) {
return Status; return Status;
} }
Status = Phy_SetMode(phyInstPtr, PHY_MODE_SCHEDULE);
if (Status == SUCCESS) {
DBG_PRINT("Physical Mode %u Setup SUCCESS! \n", PHY_MODE_LISTEN);
}
else {
DBG_PRINT("Physical Mode %u Setup FAILED! \n", PHY_MODE_LISTEN);
return Status;
}
DBG_PRINT("Starting Physical Layer..."); DBG_PRINT("Starting Physical Layer...");
Phy_Start(phyInstPtr); Phy_Start(phyInstPtr);
// FIXME: only for debug, linklayer should be start by MPC
Linklayer_Start(linkInstPtr); Linklayer_Start(linkInstPtr);
while(true) { while(true) {