Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kroužek
safe-soldering-station
Commits
31ff4652
Commit
31ff4652
authored
Jun 10, 2016
by
Martin Vítek
Browse files
Add testing template GPIO lib, but it isn't going to be working
parent
c2ceb4b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
SW/CMakeLists.txt
View file @
31ff4652
cmake_minimum_required
(
VERSION 3.0
)
set
(
AVR_UPLOADTOOL avrdude
)
set
(
AVR_PROGRAMMER
usbasp
)
set
(
AVR_PROGRAMMER
atmelice_pdi
)
set
(
AVR_UPLOADTOOL_PORT usb
)
set
(
AVR_MCU atxmega16d4
)
set
(
AVR_H_FUSE 0xC8
)
set
(
AVR_L_FUSE 0x1F
)
#set(CMAKE_BUILD_TYPE RelWithDebInfo)
set
(
CMAKE_BUILD_TYPE Release
)
set
(
MCU_SPEED
"
147456
00UL"
)
set
(
MCU_SPEED
"
20000
00UL"
)
set
(
WITH_MCU OFF
)
set
(
WITH_MCU OFF CACHE BOOL
"Add the mCU type to the target file name."
FORCE
)
...
...
@@ -35,6 +35,7 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wl,--gc-sections -Wl,--relax -Os -mrela
set
(
SOURCE_FILES
main.cpp
gpio.h
)
add_avr_executable
(
safe-soldering-station
${
SOURCE_FILES
}
)
SW/gpio.h
0 → 100644
View file @
31ff4652
#pragma once
#include
<avr/io.h>
#include
<stdint.h>
/*
* If this will produce lot of instructions, it's possible to pass address of first port register - PORTA
* and registers are next 23 addresses in memory
*/
enum
modes
{
INVERTED
,
TOTEM_POLE
,
BUS_KEEPER
,
TOTEM_PULL_UP
,
TOTEM_PULL_DOWN
,
WIRED_OR
,
WIRED_AND
,
WIRED_OR_PULL_DOWN
,
WIRED_AND_PULL_UP
};
enum
dirs
{
INPUT
,
OUTPUT
};
template
<
PORT_struct
*
port
,
uint8_t
pin_bm
>
class
gpio
{
public:
gpio
(
bool
mode
=
TOTEM_POLE
,
bool
dir
=
OUTPUT
,
bool
inv
=
false
)
{
port
->
DIRSET
=
pin_bm
;
port
->
OUTCLR
=
pin_bm
;
//port->PIN1CTRL
}
gpio
()
{
}
void
on
()
{
port
->
OUTSET
=
pin_bm
;
}
void
off
()
{
port
->
OUTCLR
=
pin_bm
;
}
void
toggle
()
{
port
->
OUTTGL
=
pin_bm
;
}
};
/*
template <PORT_t *port, uint8_t pin_mask>
void on()
{
port->OUTSET = pin_mask;
};
*/
\ No newline at end of file
SW/main.cpp
View file @
31ff4652
#include
<avr/io.h>
#include
<util/delay.h>
#include
"gpio.h"
int
main
()
{
PORTD
.
DIRSET
=
(
1
<<
PIN0_bm
);
gpio
<
PORTD
,
PIN0_bm
>
led
();
//gpio<&PORTD, PIN1_bm> lcd();
//on<&PORTD, PIN0_bm>();
for
(;;)
{
PORTD
.
OUTSET
=
(
1
<<
PIN0_bm
);
//led.toggle(
);
_delay_ms
(
250
);
PORTD
.
OUTCLR
=
(
1
<<
PIN0_bm
);
//led.toggle(
);
_delay_ms
(
250
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment