Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multipass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
derf
multipass
Commits
ef3ef992
Commit
ef3ef992
authored
7 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
arduino-nano: Add GPIO input/output/read/write support
parent
771b62b0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/arduino-nano/driver/gpio.h
+85
-0
85 additions, 0 deletions
include/arduino-nano/driver/gpio.h
src/arch/arduino-nano/Makefile.inc
+1
-0
1 addition, 0 deletions
src/arch/arduino-nano/Makefile.inc
with
86 additions
and
0 deletions
include/arduino-nano/driver/gpio.h
+
85
−
0
View file @
ef3ef992
#ifndef GPIO_H
#define GPIO_H
#include
<avr/io.h>
class
GPIO
{
private:
GPIO
(
const
GPIO
&
copy
);
public:
GPIO
()
{}
enum
Pin
:
unsigned
char
{
pb0
=
8
,
pb1
=
9
,
pb2
=
10
,
pb3
=
11
,
pb4
=
12
,
pb5
=
13
,
pb6
=
14
,
pb7
=
15
,
pc0
=
16
,
pc1
=
17
,
pc2
=
18
,
pc3
=
19
,
pc4
=
20
,
pc5
=
21
,
pc6
=
22
,
pd0
=
24
,
pd1
=
25
,
pd2
=
26
,
pd3
=
27
,
pd4
=
28
,
pd5
=
29
,
pd6
=
30
,
pd7
=
31
};
void
setup
();
void
led_on
(
unsigned
char
id
);
void
led_off
(
unsigned
char
id
);
void
led_toggle
(
unsigned
char
id
);
inline
void
input
(
unsigned
char
const
pin
)
{
if
(
pin
<
8
)
{
}
else
if
(
pin
<
16
)
{
DDRB
&=
~
_BV
(
pin
-
8
);
}
else
if
(
pin
<
24
)
{
DDRC
&=
~
_BV
(
pin
-
16
);
}
else
if
(
pin
<
32
)
{
DDRD
&=
~
_BV
(
pin
-
24
);
}
}
inline
void
output
(
unsigned
char
const
pin
)
{
if
(
pin
<
8
)
{
}
else
if
(
pin
<
16
)
{
DDRB
|=
_BV
(
pin
-
8
);
}
else
if
(
pin
<
24
)
{
DDRC
|=
_BV
(
pin
-
16
);
}
else
if
(
pin
<
32
)
{
DDRD
|=
_BV
(
pin
-
24
);
}
}
inline
unsigned
char
read
(
unsigned
char
const
pin
)
{
if
(
pin
<
8
)
{
}
if
(
pin
<
16
)
{
return
(
PINB
&
_BV
(
pin
-
8
));
}
if
(
pin
<
24
)
{
return
(
PINC
&
_BV
(
pin
-
16
));
}
if
(
pin
<
32
)
{
return
(
PIND
&
_BV
(
pin
-
24
));
}
return
0
;
}
inline
void
write
(
unsigned
char
const
pin
,
unsigned
char
value
)
{
if
(
pin
<
8
)
{
}
else
if
(
pin
<
16
)
{
if
(
value
)
{
PORTB
|=
_BV
(
pin
-
8
);
}
else
{
PORTB
&=
~
_BV
(
pin
-
8
);
}
}
else
if
(
pin
<
24
)
{
if
(
value
)
{
PORTB
|=
_BV
(
pin
-
16
);
}
else
{
PORTB
&=
~
_BV
(
pin
-
16
);
}
}
else
if
(
pin
<
32
)
{
if
(
value
)
{
PORTB
|=
_BV
(
pin
-
24
);
}
else
{
PORTB
&=
~
_BV
(
pin
-
24
);
}
}
}
};
extern
GPIO
gpio
;
...
...
This diff is collapsed.
Click to expand it.
src/arch/arduino-nano/Makefile.inc
+
1
−
0
View file @
ef3ef992
...
...
@@ -26,6 +26,7 @@ OBJECTS = ${TARGETS:.cc=.o}
build/system.elf
:
${OBJECTS}
${
CXX
}
${
COMMON_FLAGS
}
${
CXXFLAGS
}
-Wl
,--gc-sections
-o
$@
${
OBJECTS
}
avr-size
--format
=
avr
--mcu
=
${
MCU
}
$@
build/system.hex
:
build/system.elf
${
OBJCOPY
}
-O
ihex
${
@:.hex
=
.elf
}
$@
...
...
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