Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
duck
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
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
jp7g21
duck
Commits
c27b5a21
Commit
c27b5a21
authored
3 years ago
by
Xoaquin Castrelo
Browse files
Options
Downloads
Patches
Plain Diff
Added support for UART.
parent
3ed5a13e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
emb/uart.cpp
+36
-0
36 additions, 0 deletions
emb/uart.cpp
emb/uart.hpp
+9
-0
9 additions, 0 deletions
emb/uart.hpp
with
45 additions
and
0 deletions
emb/uart.cpp
0 → 100644
+
36
−
0
View file @
c27b5a21
#include
"uart.hpp"
#include
"servos.hpp"
#include
"command.h"
#include
<avr/io.h>
#include
<avr/interrupt.h>
void
initUart
()
{
cli
();
UCSR0A
=
(
1
<<
U2X0
);
// double transmission speed
UCSR0B
=
(
1
<<
RXCIE0
)
// enable RX complete interrupt
|
(
1
<<
UDRIE0
)
// enable data register empty interrupt
|
(
1
<<
RXEN0
)
// enable receiver
|
(
1
<<
TXEN0
);
// enable transmitter
UCSR0C
=
(
0
<<
UMSEL01
)
|
(
0
<<
UMSEL00
)
// asynchronous USART
|
(
0
<<
UPM01
)
|
(
0
<<
UPM00
)
// no parity bit
|
(
0
<<
USBS0
)
// 1 stop bit
|
(
1
<<
UCSZ01
)
|
(
1
<<
UCSZ00
);
// 8 data bits
UBRR0
=
16
;
// 115.2k baud rate
sei
();
}
ISR
(
USART_RX_vect
)
{
uart_add_ch
(
UDR0
);
}
ISR
(
USART_UDRE_vect
)
{
// nothing to do right now
}
This diff is collapsed.
Click to expand it.
emb/uart.hpp
0 → 100644
+
9
−
0
View file @
c27b5a21
#ifndef UART_H
#define UART_H
/**
* Initialises the UART logic.
*/
void
initUart
();
#endif
/* UART_H */
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