Skip to content
Snippets Groups Projects
Commit 0fb5286f authored by dawehr's avatar dawehr
Browse files

wip: new uart now passes the uart hw test

parent 7005bd84
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@ struct ZyboI2CState {
struct ZyboUARTState {
struct Queue *queue;
XUartPs *inst;
XScuGic xscugic;
int devId;
};
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment