forked from wovo/hwlib
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
372 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// ========================================================================== | ||
// | ||
// blink the LED on an Arduino Due | ||
// | ||
// (c) Wouter van Ooijen (wouter@voti.nl) 2017 | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
// ========================================================================== | ||
|
||
#include "hwlib.hpp" | ||
|
||
int main( void ){ | ||
|
||
if constexpr ( hwlib::target_board == hwlib::target_boards::arduino_uno ){ | ||
|
||
DDRB |= ( 0b01 << 5 ); | ||
for(;;){ | ||
PORTB &= ~( 0b01 << 5 ); | ||
for( volatile uint32_t i = 0; i < 50'000; ++i ); | ||
PORTB |= ( 0b01 << 5 ); | ||
for( volatile uint32_t i = 0; i < 50'000; ++i ); | ||
} | ||
|
||
} else if constexpr ( hwlib::target_board == hwlib::target_boards::arduino_due ){ | ||
|
||
PIOB->PIO_OER = 0x01 << 27; | ||
for(;;){ | ||
PIOB->PIO_SODR = 0x01 << 27; | ||
for( volatile int i = 0; i < 100'000; i++ ){} | ||
IOB->PIO_CODR = 0x01 << 27; | ||
for( volatile int i = 0; i < 100'000; i++ ){} | ||
} | ||
|
||
} else { | ||
|
||
void no_blink_variation_for_this_target(); | ||
no_blink_variation_for_this_target(); | ||
|
||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#============================================================================ | ||
# | ||
# simple project makefile (just a main file) | ||
# | ||
# (c) Wouter van Ooijen (wouter@voti.nl) 2017 | ||
# | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# (See accompanying file LICENSE_1_0.txt or copy at | ||
# http://www.boost.org/LICENSE_1_0.txt) | ||
# | ||
#============================================================================ | ||
|
||
# source files in this project (main.* is automatically assumed) | ||
SOURCES := | ||
|
||
# header files in this project | ||
HEADERS := | ||
|
||
# other places to look for files for this project | ||
SEARCH := | ||
|
||
# set RELATIVE to the next higher directory | ||
# and defer to the appropriate Makefile.* there | ||
RELATIVE := .. | ||
include $(RELATIVE)/makefile.link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "hwlib.hpp" | ||
|
||
namespace target = hwlib::target; | ||
|
||
constexpr double pow( double v, int n ){ | ||
return ( n == 0 ) | ||
? 1 | ||
: v * pow( v, n - 1 ); | ||
} | ||
|
||
constexpr int fac( int n ){ | ||
return ( n == 0 ) | ||
? 1 | ||
: n * fac( n - 1 ); | ||
} | ||
|
||
constexpr double sine( double angle ){ | ||
double value = 0; | ||
for( int i = 1; i < 10; i += 2 ){ | ||
value += (( i % 4 ) == 1 ? 1 : -1 ) * pow( angle, i ) / fac( i ); | ||
} | ||
return value; | ||
} | ||
|
||
constexpr double pi = 3.14; | ||
|
||
constexpr int height = static_cast< int >( 1000 * sine( 2 * pi / 12 )); | ||
|
||
int main( void ){ | ||
|
||
// wait for the terminal emulator to start up | ||
hwlib::wait_ms( 1'000 ); | ||
|
||
hwlib::cout << "1000 * sin( 30 ) = " << height << "\n"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#============================================================================ | ||
# | ||
# simple project makefile (just a main file) | ||
# | ||
# (c) Wouter van Ooijen (wouter@voti.nl) 2017 | ||
# | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# (See accompanying file LICENSE_1_0.txt or copy at | ||
# http://www.boost.org/LICENSE_1_0.txt) | ||
# | ||
#============================================================================ | ||
|
||
# source files in this project (main.* is automatically assumed) | ||
SOURCES := | ||
|
||
# header files in this project | ||
HEADERS := | ||
|
||
# other places to look for files for this project | ||
SEARCH := | ||
|
||
# other things to build | ||
RESULTS := main.lss main.lst | ||
|
||
# set RELATIVE to the next higher directory | ||
# and defer to the appropriate Makefile.* there | ||
RELATIVE := .. | ||
include $(RELATIVE)/makefile.link |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// ========================================================================== | ||
// | ||
// File : hwlib-targets.hpp | ||
// Part of : C++ hwlib library for close-to-the-hardware OO programming | ||
// Copyright : wouter@voti.nl 2017-2019 | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
// ========================================================================== | ||
|
||
// included only via hwlib.hpp, hence no multiple-include guard is needed | ||
|
||
// this file contains Doxygen lines | ||
/// @file | ||
|
||
namespace hwlib { | ||
|
||
enum class target_boards { | ||
none, | ||
arduino_uno, | ||
arduino_due, | ||
blue_pill | ||
}; | ||
|
||
enum class target_chips { | ||
atmega328p, | ||
atsam3x8e, | ||
stm32f103c8 | ||
}; | ||
|
||
}; // namespace hwlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.