diff --git a/quad/xsdk_workspace/real_quad/src/hw_impl_zybo.h b/quad/xsdk_workspace/real_quad/src/hw_impl_zybo.h index f47c34b058ff274b624c2283efaedfb6876d5740..8f439cdf1872f1da5bcd0638d76a152f58c27f8f 100644 --- a/quad/xsdk_workspace/real_quad/src/hw_impl_zybo.h +++ b/quad/xsdk_workspace/real_quad/src/hw_impl_zybo.h @@ -34,6 +34,7 @@ struct ZyboI2CState { struct ZyboUARTState { struct Queue *queue; XUartPs *inst; + XScuGic xscugic; int devId; }; diff --git a/quad/xsdk_workspace/real_quad/src/hw_impl_zybo_uart.c b/quad/xsdk_workspace/real_quad/src/hw_impl_zybo_uart.c index 807da706237c5e92d4a936ee66de3fb82eea7fa0..fcb5dc7f165762d0ede4da93f9a16b8e6b6df631 100644 --- a/quad/xsdk_workspace/real_quad/src/hw_impl_zybo_uart.c +++ b/quad/xsdk_workspace/real_quad/src/hw_impl_zybo_uart.c @@ -4,7 +4,7 @@ int XUartPs_SetBaudRate_ours(XUartPs *InstancePtr, u32 BaudRate); -int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_ExceptionHandler handler, struct ZyboUARTState *state); +int SetupInterruptSystem(struct ZyboUARTState *state, u16 UartIntrId, Xil_ExceptionHandler handler); void uart_interrupt_handler(struct ZyboUARTState *state); int zybo_uart_reset(struct UARTDriver *self) { @@ -32,7 +32,7 @@ int zybo_uart_reset(struct UARTDriver *self) { *uart_ctrl_reg |= 0x00000003; // clear TX & RX // Setup Interrupts - if (SetupInterruptSystem(inst, XPAR_PS7_UART_0_INTR, (Xil_ExceptionHandler) uart_interrupt_handler, state) != XST_SUCCESS) { + if (SetupInterruptSystem(state, XPAR_PS7_UART_0_INTR, (Xil_ExceptionHandler) uart_interrupt_handler) != XST_SUCCESS) { return -1; } @@ -234,10 +234,9 @@ void uart_interrupt_handler(struct ZyboUARTState *state) { * @note None. * ****************************************************************************/ -int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_ExceptionHandler handler, struct ZyboUARTState *state) +int SetupInterruptSystem(struct ZyboUARTState *state, u16 UartIntrId, Xil_ExceptionHandler handler) { int Status; - XScuGic xscugic; XScuGic_Config *IntcConfig; /* Config for interrupt controller */ /* Initialize the interrupt controller driver */ @@ -246,7 +245,7 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception return XST_FAILURE; } - Status = XScuGic_CfgInitialize(&xscugic, IntcConfig, + Status = XScuGic_CfgInitialize(&state->xscugic, IntcConfig, IntcConfig->CpuBaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; @@ -258,14 +257,14 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception */ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler) XScuGic_InterruptHandler, - &xscugic); + &state->xscugic); /* * Connect a device driver handler that will be called when an * interrupt for the device occurs, the device driver handler * performs the specific interrupt processing for the device */ - Status = XScuGic_Connect(&xscugic, UartIntrId, + Status = XScuGic_Connect(&state->xscugic, UartIntrId, handler, (void *) state); if (Status != XST_SUCCESS) { @@ -273,7 +272,7 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception } /* Enable the interrupt for the device */ - XScuGic_Enable(&xscugic, UartIntrId); + XScuGic_Enable(&state->xscugic, UartIntrId); /* Enable interrupts */ Xil_ExceptionEnable();