This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
forked from wovo/hwlib
-
Notifications
You must be signed in to change notification settings - Fork 0
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
30 changed files
with
294 additions
and
105 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
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
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 }; | ||
} |
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 @@ | ||
// ========================================================================== | ||
// | ||
// 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]] |
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 @@ | ||
// ========================================================================== | ||
// | ||
// 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.
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,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]] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
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.