Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wovo committed Jan 18, 2021
1 parent 637f046 commit 02a0db6
Show file tree
Hide file tree
Showing 7 changed files with 803 additions and 3 deletions.
2 changes: 0 additions & 2 deletions library/hwlib-all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,4 @@
#include HWLIB_INCLUDE( peripherals/hwlib-matrix-keypad.hpp )
#include HWLIB_INCLUDE( peripherals/hwlib-servo-background.hpp )

#include HWLIB_INCLUDE( shields/hwlib-arduino-multifunction-shield.hpp )

#endif // HWLIB_ALL_H
1 change: 1 addition & 0 deletions library/hwlib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@
#include HWLIB_INCLUDE( targets/hwlib-none.hpp )
#endif

#include HWLIB_INCLUDE( shields/hwlib-arduino-multifunction-shield.hpp )

#endif // HWLIB_ALL_H
65 changes: 64 additions & 1 deletion library/shields/hwlib-arduino-multifunction-shield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,70 @@
// this file contains Doxygen lines
/// @file

#ifdef HWLIB_TARGET_arduino_uno

namespace hwlib {

class multifunction_shield {

target::pin_out led_1_inv, led_2_inv, led_3_inv, led_4_inv;
target::pin_in switch_1_inv, switch_2_inv, switch_3_inv;
target::pin_out beeper_inv;

public:

hwlib::pin_invert_from_out_t led_1, led_2, led_3, led_4;
hwlib::port_out_from_pins_t leds;

hwlib::pin_invert_from_in_t switch_1, switch_2, switch_3;
hwlib::port_in_from_pins_t switches;

hwlib::pin_invert_from_out_t beeper;

multifunction_shield():
led_1_inv( target::pins::d13 ),
led_2_inv( target::pins::d12 ),
led_3_inv( target::pins::d11 ),
led_4_inv( target::pins::d10 ),

switch_1_inv( target::pins::a1 ),
switch_2_inv( target::pins::a2 ),
switch_3_inv( target::pins::a3 ),

beeper_inv( target::pins::d3 ),

led_1( led_1_inv ),
led_2( led_2_inv ),
led_3( led_3_inv ),
led_4( led_4_inv ),
leds( led_1, led_2, led_3, led_4 ),

switch_1( switch_1_inv ),
switch_2( switch_2_inv ),
switch_3( switch_3_inv ),
switches( switch_1, switch_2, switch_3 ),

beeper( beeper_inv )
{
led_1.write( 0 ); led_1.flush();
led_2.write( 0 ); led_2.flush();
led_3.write( 0 ); led_3.flush();
led_4.write( 0 ); led_4.flush();

beeper.write( 0 ); beeper.flush();

}

// missing:
// 7-segment displays - needs library support
// potentiometer A/D input
// LM35
// DS1820
// IR receiver
// APC220

}; // class multifunction_shield

}; // namespace hwlib

}; // namespace hwlib
#endif
121 changes: 121 additions & 0 deletions library/targets/hwlib-micro-bit.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// ==========================================================================
//
// File : hwlib-longan-nano.hpp
// Part of : C++ hwlib library for close-to-the-hardware OO programming
// Copyright : [email protected] 2021
//
// 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)
//
// ==========================================================================


#ifndef HWLIB_LONGAN_NANO_H
#define HWLIB_LONGAN_NANO_H

#include HWLIB_INCLUDE(../hwlib-all.hpp)

namespace gd32vf103xx {

/// GPIO pin names
enum class pins {
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,
b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15,
c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15,
led,
/// \cond INTERNAL
SIZE_THIS_IS_NOT_A_PIN
/// \endcond
};

/// \cond INTERNAL
struct pin_info_type {
uint8_t port;
uint8_t pin;
};

const HWLIB_WEAK pin_info_type &pin_info(pins name) {

static const pin_info_type pin_info_array[(int) pins::SIZE_THIS_IS_NOT_A_PIN] = {
{ 0, 0 }, // a0
{ 0, 1 }, // a1
{ 0, 2 }, // a2
{ 0, 3 }, // a3
{ 0, 4 }, // a4
{ 0, 5 }, // a5
{ 0, 6 }, // a6
{ 0, 7 }, // a7

{ 0, 8 }, // a8
{ 0, 9 }, // a9
{ 0, 10 }, // a10
{ 0, 11 }, // a11
{ 0, 12 }, // a12
{ 0, 13 }, // a13
{ 0, 14 }, // a14
{ 0, 15 }, // a15

{ 1, 0 }, // b0
{ 1, 1 }, // b1
{ 1, 2 }, // b2
{ 1, 3 }, // b3
{ 1, 4 }, // b4
{ 1, 5 }, // b5
{ 1, 6 }, // b6
{ 1, 7 }, // b7

{ 1, 8 }, // b8
{ 1, 9 }, // b9
{ 1, 10 }, // b10
{ 1, 11 }, // b11
{ 1, 12 }, // b12
{ 1, 13 }, // b13
{ 1, 14 }, // b14
{ 1, 15 }, // b15

{ 2, 0 }, // c0
{ 2, 1 }, // c1
{ 2, 2 }, // c2
{ 2, 3 }, // c3
{ 2, 4 }, // c4
{ 2, 5 }, // c5
{ 2, 6 }, // c6
{ 2, 7 }, // c7

{ 2, 8 }, // c8
{ 2, 9 }, // c9
{ 2, 10 }, // c10
{ 2, 11 }, // c11
{ 2, 12 }, // c12
{ 2, 13 }, // c13
{ 2, 14 }, // c14
{ 2, 15 }, // c15

};

uint_fast8_t n = static_cast< uint_fast8_t>( name );
if (n >= static_cast< uint_fast8_t>( pins::SIZE_THIS_IS_NOT_A_PIN )) {
HWLIB_PANIC_WITH_LOCATION;
}
return pin_info_array[ n ];

}

/// \endcond

}; // end namespace gd32vf103xx

#include HWLIB_INCLUDE( hwlib-gd32vf103xx.hpp )

namespace gd32vf103c8 = ::gd32vf103xx;

namespace hwlib {

namespace target = ::gd32vf103c8;
const auto target_chip = target_chips::gd32vf103c8;
const auto target_board = target_boards::longan_nano;

};

#endif // #ifdef HWLIB_LONGAN_NANO_H
120 changes: 120 additions & 0 deletions library/targets/hwlib-nrf52833.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// ==========================================================================
//
// File : hwlib-gd32v103c8.hpp
// Part of : C++ hwlib library for close-to-the-hardware OO programming
// Copyright : [email protected] 2021
//
// 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)
//
// ==========================================================================


#ifndef HWLIB_GD32VF103C8_H
#define HWLIB_GD32VF103C8_H

#include HWLIB_INCLUDE(../hwlib-all.hpp)

namespace gd32vf103xx {

/// GPIO pin names
enum class pins {
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,
b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15,
c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15,
led,
/// \cond INTERNAL
SIZE_THIS_IS_NOT_A_PIN
/// \endcond
};

/// \cond INTERNAL
struct pin_info_type {
uint8_t port;
uint8_t pin;
};

const HWLIB_WEAK pin_info_type &pin_info(pins name) {

static const pin_info_type pin_info_array[(int) pins::SIZE_THIS_IS_NOT_A_PIN] = {
{ 0, 0 }, // a0
{ 0, 1 }, // a1
{ 0, 2 }, // a2
{ 0, 3 }, // a3
{ 0, 4 }, // a4
{ 0, 5 }, // a5
{ 0, 6 }, // a6
{ 0, 7 }, // a7

{ 0, 8 }, // a8
{ 0, 9 }, // a9
{ 0, 10 }, // a10
{ 0, 11 }, // a11
{ 0, 12 }, // a12
{ 0, 13 }, // a13
{ 0, 14 }, // a14
{ 0, 15 }, // a15

{ 1, 0 }, // b0
{ 1, 1 }, // b1
{ 1, 2 }, // b2
{ 1, 3 }, // b3
{ 1, 4 }, // b4
{ 1, 5 }, // b5
{ 1, 6 }, // b6
{ 1, 7 }, // b7

{ 1, 8 }, // b8
{ 1, 9 }, // b9
{ 1, 10 }, // b10
{ 1, 11 }, // b11
{ 1, 12 }, // b12
{ 1, 13 }, // b13
{ 1, 14 }, // b14
{ 1, 15 }, // b15

{ 2, 0 }, // c0
{ 2, 1 }, // c1
{ 2, 2 }, // c2
{ 2, 3 }, // c3
{ 2, 4 }, // c4
{ 2, 5 }, // c5
{ 2, 6 }, // c6
{ 2, 7 }, // c7

{ 2, 8 }, // c8
{ 2, 9 }, // c9
{ 2, 10 }, // c10
{ 2, 11 }, // c11
{ 2, 12 }, // c12
{ 2, 13 }, // c13
{ 2, 14 }, // c14
{ 2, 15 }, // c15

};

uint_fast8_t n = static_cast< uint_fast8_t>( name );
if (n >= static_cast< uint_fast8_t>( pins::SIZE_THIS_IS_NOT_A_PIN )) {
HWLIB_PANIC_WITH_LOCATION;
}
return pin_info_array[ n ];

}

/// \endcond

}; // end namespace gd32vf103xx

#include HWLIB_INCLUDE( hwlib-gd32vf103xx.hpp )

namespace gd32vf103c8 = ::gd32vf103xx;

namespace hwlib {

namespace target = ::gd32vf103c8;
const auto target_chip = target_chips::gd32vf103c8;

};

#endif // #ifdef HWLIB_GD32VF103C8_H
Loading

0 comments on commit 02a0db6

Please sign in to comment.