Skip to content

Commit

Permalink
[example] Add IS31FL3733 driver on STM32G071
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Aug 14, 2020
1 parent 471605b commit 9b6aeee
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
62 changes: 62 additions & 0 deletions examples/nucleo_g071rb/matrix/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2019, Niklas Hauser
*
* 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/processing.hpp>
#include <modm/driver/display/is31fl3733.hpp>

using namespace Board;

using PinReset = GpioC8;
using PinSda = GpioA11;
using PinScl = GpioA12;

using I2cInstance = BitBangI2cMaster<PinScl, PinSda>;
static modm::Is31fl3733<I2cInstance> driver(modm::is31fl3733::addr());

// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
LedD13::setOutput(modm::Gpio::Low);

MODM_LOG_ERROR << "error" << modm::endl;

// Reset the I2C interface of the chip
PinReset::setOutput(modm::Gpio::High);
modm::delay(20ms);
PinReset::setOutput(modm::Gpio::Low);

I2cInstance::initialize<SystemClock, 400_kHz>();
I2cInstance::connect<PinScl::BitBang, PinSda::BitBang>();

RF_CALL_BLOCKING(driver.reset());
RF_CALL_BLOCKING(driver.clearSoftwareShutdown());
RF_CALL_BLOCKING(driver.setGlobalCurrent(1));

driver.enableAll();
RF_CALL_BLOCKING(driver.writeOnOff());

uint8_t pwm{0};
while (true)
{
for (uint8_t y=0, pi=pwm; y<16; y++) {
for (uint8_t x=0; x<12; x++) {
driver.setPwm(x, y, pi++);
}
}
RF_CALL_BLOCKING(driver.writePwm());
modm::delay(10ms);
pwm++;
}

return 0;
}
12 changes: 12 additions & 0 deletions examples/nucleo_g071rb/matrix/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<library>
<extends>modm:nucleo-g071rb</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_g071rb/matrix</option>
</options>
<modules>
<module>modm:platform:gpio</module>
<module>modm:platform:i2c.bitbang</module>
<module>modm:driver:is31fl3733</module>
<module>modm:build:scons</module>
</modules>
</library>

0 comments on commit 9b6aeee

Please sign in to comment.