Skip to content

Commit

Permalink
[examples] Add TLC594x Blue Pill example
Browse files Browse the repository at this point in the history
  • Loading branch information
linasdev committed Jul 15, 2019
1 parent 98ffb3a commit b570d07
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ make gdb

## Interesting Examples

We have a lot of examples, <!--examplecount-->190<!--/examplecount--> to be
We have a lot of examples, <!--examplecount-->191<!--/examplecount--> to be
exact, but here are some of our favorite examples for our supported development
boards:

Expand Down
49 changes: 49 additions & 0 deletions examples/stm32f103c8t6_blue_pill/tlc594x/main.cpp
Original file line number Diff line number Diff line change
@@ -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 <modm/board.hpp>
#include <modm/driver/pwm/tlc594x.hpp>

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;
}
2 changes: 2 additions & 0 deletions examples/stm32f103c8t6_blue_pill/tlc594x/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Replace this with your custom programmer
source [find interface/stlink-v2.cfg]
12 changes: 12 additions & 0 deletions examples/stm32f103c8t6_blue_pill/tlc594x/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<library>
<extends>modm:blue-pill</extends>
<options>
<option name="modm:build:build.path">../../../build/stm32f103c8t6_blue_pill/tlc594x</option>
<option name="modm:build:openocd.cfg">openocd.cfg</option>
</options>
<modules>
<module>modm:platform:spi:1</module>
<module>modm:driver:tlc594x</module>
<module>modm:build:scons</module>
</modules>
</library>

0 comments on commit b570d07

Please sign in to comment.