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

Commit

Permalink
doxygen cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wovo committed Feb 8, 2017
1 parent debfa90 commit d14ff5f
Show file tree
Hide file tree
Showing 30 changed files with 294 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ EXCLUDE_SYMBOLS = _*
# that contain example code fragments that are included (see the \include
# command).

EXAMPLE_PATH = ..
EXAMPLE_PATH = .

# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ MSG += Make one of the project source files your current editor file.
error:
$(error $(MSG) )

REMOVE := ../bmptk/tools/bmptk-rm
BMPTK := ../bmptk

REMOVE := $(BMPTK)/tools/bmptk-rm

build:
Doxygen
Expand Down
10 changes: 10 additions & 0 deletions demos/arduino-due/blink/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// ==========================================================================
//
// blink the LED on an Arduino Due
//
// This file is in the public domain.
//
// =========================================================================

//! [[Doxygen blink example]]
#include "hwlib.hpp"

int main( void ){
Expand All @@ -7,3 +16,4 @@ int main( void ){
auto led = hwlib::target::pin_out( 1, 27 );
hwlib::blink( led );
}
//! [[Doxygen blink example]]
37 changes: 37 additions & 0 deletions demos/arduino-due/panic/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ==========================================================================
//
// print hello, prefixed with a sequence number
//
// show how an application can define its own panic function
//
// ==========================================================================

//! [[Doxygen panic example]]
#include "hwlib.hpp"

void HWLIB_NORETURN hwlib::panic( const char * file, int line ){

// wait for the console connection to be ready
hwlib::wait_ms( 1000 );

// tell what happend and where
// (don't forget to flush)
hwlib::cout
<< "\n"
<< "*** PANIC (unrecoverable error) *** \n"
<< "detected in file '" << file << "'\n"
<< "at line " << line << "\n"
<< hwlib::flush;

// don't return
for(;;);
}
//! [[Doxygen panic example]]

int main( void ){
// kill the watchdog
WDT->WDT_MR = WDT_MR_WDDIS;

// there is no port 99, so this will cause a panic
hwlib::target::pin_out pin { 99, 0 };
}
25 changes: 25 additions & 0 deletions demos/db103/hc595/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ==========================================================================
//
// kitt on 8 LEDs on a HC595 connected to a DB103 board
//
// This file is in the public domain.
//
// ==========================================================================

//! [[Doxygen hc595 example]]
#include "hwlib.hpp"

int main( void ){

auto sclk = hwlib::target::pin_out{ 1, 2 };
auto mosi = hwlib::target::pin_out{ 1, 0 };
auto cs = hwlib::target::pin_out{ 1, 1 };

auto spi_bus = hwlib::spi_bus_bit_banged_sclk_mosi_miso{
sclk, mosi, hwlib::pin_in_dummy };

auto chip = hwlib::hc595{ spi_bus, cs };

hwlib::kitt( chip, 50 );
}
//! [[Doxygen hc595 example]]
25 changes: 25 additions & 0 deletions demos/db103/pcf8574a/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ==========================================================================
//
// kitt on 8 LEDs on PCF8574A connected to a DB013 board
//
// This file is in the public domain.
//
// ==========================================================================

//! [[Doxygen pcf8574a example]]
#include "hwlib.hpp"

int main( void ){

auto scl = hwlib::target::pin_oc{ 0, 4 };
auto sda = hwlib::target::pin_oc{ 0, 5 };

auto i2c_bus = hwlib::i2c_bus_bit_banged_scl_sda{ scl,sda };

auto chip = hwlib::pcf8574a{ i2c_bus, 0 };

auto leds = hwlib::port_oc_invert( chip );

hwlib::kitt( leds, 50 );
}
//! [[Doxygen pcf8574a example]]
File renamed without changes.
30 changes: 30 additions & 0 deletions demos/db103/pcf8591-adc/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ==========================================================================
//
// kitt on 8 LEDs on PCF8574A connected to a DB103
//
// This file is in the public domain.
//
// ==========================================================================

//! [[Doxygen pcf8591-adc example]]
#include "hwlib.hpp"

int main( void ){

auto scl = hwlib::target::pin_oc{ 0, 4 };
auto sda = hwlib::target::pin_oc{ 0, 5 };

auto i2c_bus = hwlib::i2c_bus_bit_banged_scl_sda{ scl,sda };

auto chip = hwlib::pcf8591{ i2c_bus, 0 };

for(;;){
hwlib::cout
<< "adc0: " << hwlib::setw( 4 ) << chip.adc0.get() << " "
<< "adc1: " << hwlib::setw( 4 ) << chip.adc1.get() << " "
<< "adc2: " << hwlib::setw( 4 ) << chip.adc2.get() << " "
<< "adc3: " << hwlib::setw( 4 ) << chip.adc3.get() << "\n";
hwlib::wait_ms( 250 );
}
}
//! [[Doxygen pcf8591-adc example]]
Binary file added images/oled.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions include/hwlib-due.hpp → include/hwlib-arduino-due.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ enum class ad_pins {
/// \endcond
};

/// definition of an A/D input
struct ad_pin_info_type {

/// the channel number
uint8_t channel;
};

Expand Down Expand Up @@ -646,6 +649,7 @@ class pin_adc : public hwlib::adc {
}
};

/// returns the time since the3 first call
uint32_t HWLIB_WEAK now_us(){
static bool init_done = false;
if( ! init_done ){
Expand Down
29 changes: 23 additions & 6 deletions include/hwlib-uno.hpp → include/hwlib-arduino-uno.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ class pin_in : public hwlib::pin_in {
}
{}

bool get() override {
bool get(
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
return ( port & mask ) != 0;
}
};
Expand Down Expand Up @@ -247,7 +249,10 @@ class pin_out : public hwlib::pin_out {
}
{}

void set( bool v ) override {
void set(
bool v,
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
if( v ){
port |= mask;
} else {
Expand Down Expand Up @@ -301,15 +306,20 @@ class pin_in_out : public hwlib::pin_in_out {
port_direction( port_number ) &= ~ mask;
}

bool get() override {
bool get(
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
return ( port & mask ) != 0;
}

virtual void direction_set_output() override {
port_direction( port_number ) |= mask;
}

void set( bool v ) override {
void set(
bool v,
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
if( v ){
port |= mask;
} else {
Expand Down Expand Up @@ -355,11 +365,16 @@ class pin_oc : public hwlib::pin_oc {
}
{}

bool get() override {
bool get(
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
return ( port & mask ) != 0;
}

void set( bool v ) override {
void set(
bool v,
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
if( v ){
port_direction( port_number ) &= ~ mask;
} else {
Expand All @@ -370,6 +385,7 @@ class pin_oc : public hwlib::pin_oc {

};

/*
// should be part of due, anders for Uno!
class shield_lcd_mcufriend {
private:
Expand Down Expand Up @@ -398,6 +414,7 @@ class shield_lcd_mcufriend {
lcd{ rst, cs, rs, wr, rd, data }
{}
};
*/

}; // namespace due

Expand Down
67 changes: 42 additions & 25 deletions include/hwlib-db103.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ class pin_in : public hwlib::pin_in {
*gpioreg( port, 0x8000 ) &= ~ mask;
}

bool get() override {
bool get(
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
return *gpioreg( port, 0x3FFC ) & mask;
}
};
Expand All @@ -183,7 +185,10 @@ class pin_out : public hwlib::pin_out {
*gpioreg( port, 0x8000 ) |= mask ;
}

void set( bool v ) override {
void set(
bool v,
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
*gpioreg( port, 0x04 << pin ) = v ? -1 : 0;
}
};
Expand Down Expand Up @@ -214,15 +219,20 @@ class pin_in_out : public hwlib::pin_in_out {
*gpioreg( port, 0x8000 ) &= ~ mask;
}

bool get() override {
bool get(
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
return *gpioreg( port, 0x3FFC ) & mask;
}

virtual void direction_set_output() override {
*gpioreg( port, 0x8000 ) |= mask ;
}

void set( bool v ) override {
void set(
bool v,
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
*gpioreg( port, 0x04 << pin ) = v ? -1 : 0;
}
};
Expand All @@ -248,11 +258,16 @@ class pin_oc : public hwlib::pin_oc {
*gpioreg( port, 0x8000 ) &= ~ mask;
}

bool get() override {
bool get(
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
return *gpioreg( port, 0x3FFC ) & mask;
}

void set( bool v ) override {
void set(
bool v,
hwlib::buffering buf = hwlib::buffering::unbuffered
) override {
if( v ){

// make the pin an input
Expand All @@ -269,33 +284,35 @@ class pin_oc : public hwlib::pin_oc {
}
};

class pin_adc : public hwlib::adc {
private:
uint32_t channel;
/// adc implementation for an LPC1114
class pin_adc : public hwlib::adc {
private:
uint32_t channel;

public:
public:

pin_adc( uint32_t port, uint32_t pin )
: adc{ 10 }, channel{ configure_as_adc( port, pin ) }
{}
/// create an A/D pin from its port and pin numbers
pin_adc( uint32_t port, uint32_t pin )
: adc{ 10 }, channel{ configure_as_adc( port, pin ) }
{}

adc_value_type get() override {
adc_value_type get() override {

// configure the A/D for the pin
LPC_ADC->CR = ( 0x01 << channel ) | ( 12 << 8 );
// configure the A/D for the pin
LPC_ADC->CR = ( 0x01 << channel ) | ( 12 << 8 );

// start the conversion
LPC_ADC->CR |= ( 0x01 << 24 );
// start the conversion
LPC_ADC->CR |= ( 0x01 << 24 );

// wait for the conversion to complete
while( ( LPC_ADC->GDR & ( 1 << 31 )) == 0 );
// wait for the conversion to complete
while( ( LPC_ADC->GDR & ( 1 << 31 )) == 0 );

hwlib::wait_ms( 10 );
hwlib::wait_ms( 10 );

// return the A/D result
return 3 | (( LPC_ADC->GDR >> 6 ) & 0x3FF);
}
};
// return the A/D result
return 3 | (( LPC_ADC->GDR >> 6 ) & 0x3FF);
}
};


}; // namespace db103
Expand Down
2 changes: 1 addition & 1 deletion include/hwlib-defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
/// The TRACE macro can be used like hwlib::cout to print to,
/// but what is printed will be prefixed with a newfile
/// and the HWLIB_HERE string.
#define HWLIB_TRACE ( ::hwlib::cout << "\n" << HWLIB_HERE )
#define HWLIB_TRACE ( ::hwlib::cout << "\n" << HWLIB_HERE << hwlib::flush )

/// panic-with-location macro
//
Expand Down
Loading

0 comments on commit d14ff5f

Please sign in to comment.