diff --git a/examples/README.md b/examples/README.md index 6dc2b7e0e8..e48d953228 100644 --- a/examples/README.md +++ b/examples/README.md @@ -94,7 +94,7 @@ make gdb ## Interesting Examples -We have a lot of examples, 190 to be +We have a lot of examples, 191 to be exact, but here are some of our favorite examples for our supported development boards: diff --git a/examples/stm32f103c8t6_blue_pill/tlc594x/main.cpp b/examples/stm32f103c8t6_blue_pill/tlc594x/main.cpp new file mode 100644 index 0000000000..26d48896d1 --- /dev/null +++ b/examples/stm32f103c8t6_blue_pill/tlc594x/main.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019, Linas Nikiperavicius + * + * This file is part of the modm project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +// ---------------------------------------------------------------------------- + +#include +#include + +using namespace Board; + +/* + * Turns on each TLC594* output in ascending order. + * Each output is active for 500 milliseconds. + */ + +#define CHANNELS 24 + +modm::TLC594X< CHANNELS, SpiMaster1, GpioA4, GpioA3 > tlc594x; + +int +main() +{ + Board::initialize(); + + SpiMaster1::connect< GpioA5::Sck, GpioA7::Mosi > (); + SpiMaster1::initialize< Board::SystemClock, 1125_kBd>(); + + tlc594x.initialize(0, -1, true, false, true); + + while (true) + { + for (uint16_t i = 0; i < CHANNELS; ++i) + { + tlc594x.setAllChannels(0x000); + tlc594x.setChannel(i, 0xfff); + RF_CALL_BLOCKING(tlc594x.writeChannels()); + + modm::delayMilliseconds(500); + } + } + + return 0; +} diff --git a/examples/stm32f103c8t6_blue_pill/tlc594x/openocd.cfg b/examples/stm32f103c8t6_blue_pill/tlc594x/openocd.cfg new file mode 100644 index 0000000000..b157e7e432 --- /dev/null +++ b/examples/stm32f103c8t6_blue_pill/tlc594x/openocd.cfg @@ -0,0 +1,2 @@ +# Replace this with your custom programmer +source [find interface/stlink-v2.cfg] diff --git a/examples/stm32f103c8t6_blue_pill/tlc594x/project.xml b/examples/stm32f103c8t6_blue_pill/tlc594x/project.xml new file mode 100644 index 0000000000..d1a02bef7a --- /dev/null +++ b/examples/stm32f103c8t6_blue_pill/tlc594x/project.xml @@ -0,0 +1,12 @@ + + modm:blue-pill + + + + + + modm:platform:spi:1 + modm:driver:tlc594x + modm:build:scons + +