Skip to content
Snippets Groups Projects
Commit 4a6012f7 authored by dawehr's avatar dawehr
Browse files

wip: new uart now passes the uart hw test

parent 8fb3e349
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,7 @@ struct ZyboI2CState { ...@@ -34,6 +34,7 @@ struct ZyboI2CState {
struct ZyboUARTState { struct ZyboUARTState {
struct Queue *queue; struct Queue *queue;
XUartPs *inst; XUartPs *inst;
XScuGic xscugic;
int devId; int devId;
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int XUartPs_SetBaudRate_ours(XUartPs *InstancePtr, u32 BaudRate); 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); void uart_interrupt_handler(struct ZyboUARTState *state);
int zybo_uart_reset(struct UARTDriver *self) { int zybo_uart_reset(struct UARTDriver *self) {
...@@ -32,7 +32,7 @@ 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 *uart_ctrl_reg |= 0x00000003; // clear TX & RX
// Setup Interrupts // 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; return -1;
} }
...@@ -234,10 +234,9 @@ void uart_interrupt_handler(struct ZyboUARTState *state) { ...@@ -234,10 +234,9 @@ void uart_interrupt_handler(struct ZyboUARTState *state) {
* @note None. * @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; int Status;
XScuGic xscugic;
XScuGic_Config *IntcConfig; /* Config for interrupt controller */ XScuGic_Config *IntcConfig; /* Config for interrupt controller */
/* Initialize the interrupt controller driver */ /* Initialize the interrupt controller driver */
...@@ -246,7 +245,7 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception ...@@ -246,7 +245,7 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception
return XST_FAILURE; return XST_FAILURE;
} }
Status = XScuGic_CfgInitialize(&xscugic, IntcConfig, Status = XScuGic_CfgInitialize(&state->xscugic, IntcConfig,
IntcConfig->CpuBaseAddress); IntcConfig->CpuBaseAddress);
if (Status != XST_SUCCESS) { if (Status != XST_SUCCESS) {
return XST_FAILURE; return XST_FAILURE;
...@@ -258,14 +257,14 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception ...@@ -258,14 +257,14 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception
*/ */
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler) XScuGic_InterruptHandler, (Xil_ExceptionHandler) XScuGic_InterruptHandler,
&xscugic); &state->xscugic);
/* /*
* Connect a device driver handler that will be called when an * Connect a device driver handler that will be called when an
* interrupt for the device occurs, the device driver handler * interrupt for the device occurs, the device driver handler
* performs the specific interrupt processing for the device * performs the specific interrupt processing for the device
*/ */
Status = XScuGic_Connect(&xscugic, UartIntrId, Status = XScuGic_Connect(&state->xscugic, UartIntrId,
handler, handler,
(void *) state); (void *) state);
if (Status != XST_SUCCESS) { if (Status != XST_SUCCESS) {
...@@ -273,7 +272,7 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception ...@@ -273,7 +272,7 @@ int SetupInterruptSystem(XUartPs *UartInstancePtr, u16 UartIntrId, Xil_Exception
} }
/* Enable the interrupt for the device */ /* Enable the interrupt for the device */
XScuGic_Enable(&xscugic, UartIntrId); XScuGic_Enable(&state->xscugic, UartIntrId);
/* Enable interrupts */ /* Enable interrupts */
Xil_ExceptionEnable(); 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