Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
604e38a5
Commit
604e38a5
authored
7 years ago
by
bbartels
Browse files
Options
Downloads
Patches
Plain Diff
wip: fix more issues in hw_impl_zybo_uart.c
parent
2cffb0a4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/xsdk_workspace/real_quad/src/hw_impl_zybo_uart.c
+24
-13
24 additions, 13 deletions
quad/xsdk_workspace/real_quad/src/hw_impl_zybo_uart.c
with
24 additions
and
13 deletions
quad/xsdk_workspace/real_quad/src/hw_impl_zybo_uart.c
+
24
−
13
View file @
604e38a5
...
...
@@ -8,22 +8,28 @@ void uart_interrupt_handler(XUartPs *InstancePtr);
int
SetupInterruptSystem
(
XUartPs
*
UartInstancePtr
,
u16
UartIntrId
,
Xil_ExceptionHandler
handler
);
void
uart_interrupt_handler
(
XUartPs
*
InstancePtr
);
// Queue has to be global to be accessible to ISR
static
struct
Queue
queue
;
static
volatile
unsigned
char
buff
[
MAX_UART_BUFFER_SIZE
]
;
static
XScuGic
xscugic
;
struct
UARTState
{
struct
Queue
*
queue
;
XUartPs
*
inst
;
}
;
int
zybo_uart_reset
(
struct
UARTDriver
*
self
)
{
// Instantiate the Driver state
if
(
self
->
state
==
NULL
)
{
self
->
state
=
malloc
(
sizeof
(
XUartPs
));
if
(
self
->
state
==
NULL
)
{
return
-
1
;
}
queue_init
(
&
queue
,
buff
,
MAX_UART_BUFFER_SIZE
);
self
->
state
=
malloc
(
sizeof
(
struct
UARTState
));
if
(
self
->
state
==
NULL
)
return
-
1
;
self
->
state
->
inst
=
malloc
(
sizeof
(
XUartPs
));
if
(
self
->
state
->
inst
==
NULL
)
return
-
1
;
// We are cheating. We put the Queue on the callback field,
// because that was the only way we could get the Queue
// into this interupt handler. And the callback field was a void
// pointer so we can do whatever we want with it...
self
->
state
->
inst
->
CallBackRef
=
queue_malloc
(
MAX_UART_BUFFER_SIZE
);
if
(
self
->
state
->
inst
->
CallBackRef
==
NULL
)
return
-
1
;
}
XUartPs
*
inst
=
self
->
state
;
;
XUartPs
*
inst
=
self
->
state
->
inst
;
// Configure XUartPs instance
XUartPs_Config
*
config
=
XUartPs_LookupConfig
(
XPAR_PS7_UART_0_DEVICE_ID
);
...
...
@@ -75,7 +81,9 @@ int zybo_uart_write(struct UARTDriver *self, unsigned char c) {\
}
int
zybo_uart_read
(
struct
UARTDriver
*
self
,
unsigned
char
*
c
)
{
if
(
queue_remove
(
&
queue
,
c
))
return
-
1
;
// We put the queue on the void pointer callback reference
struct
Queue
*
queue
=
InstancePtr
->
CallBackRef
;
if
(
queue_remove
(
queue
,
c
))
return
-
1
;
else
return
0
;
}
...
...
@@ -191,6 +199,9 @@ int XUartPs_SetBaudRate_ours(XUartPs *InstancePtr, u32 BaudRate)
void
uart_interrupt_handler
(
XUartPs
*
InstancePtr
)
{
u32
IsrStatus
;
// We put the queue on the void pointer callback reference
struct
Queue
*
queue
=
InstancePtr
->
CallBackRef
;
/*
* Read the interrupt ID register to determine which
* interrupt is active
...
...
@@ -211,7 +222,7 @@ void uart_interrupt_handler(XUartPs *InstancePtr) {
while
(
0
==
(
CsrRegister
&
XUARTPS_SR_RXEMPTY
))
{
u8
byte
=
XUartPs_ReadReg
(
InstancePtr
->
Config
.
BaseAddress
,
XUARTPS_FIFO_OFFSET
);
queue_add
(
&
queue
,
byte
);
queue_add
(
queue
,
byte
);
CsrRegister
=
XUartPs_ReadReg
(
InstancePtr
->
Config
.
BaseAddress
,
XUARTPS_SR_OFFSET
);
}
...
...
@@ -241,7 +252,7 @@ void uart_interrupt_handler(XUartPs *InstancePtr) {
int
SetupInterruptSystem
(
XUartPs
*
UartInstancePtr
,
u16
UartIntrId
,
Xil_ExceptionHandler
handler
)
{
int
Status
;
XScuGic
xscugic
;
XScuGic_Config
*
IntcConfig
;
/* Config for interrupt controller */
/* Initialize the interrupt controller driver */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment