-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[driver] Fix ILI9341 and add SPI example for it
Signed-off-by: delphi <cpp.create@gmail.com>
- Loading branch information
Showing
4 changed files
with
83 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2016, Sascha Schade | ||
* Copyright (c) 2017, 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/driver/display/ili9341_spi.hpp> | ||
using namespace Board; | ||
|
||
namespace display | ||
{ | ||
using Spi = SpiMaster1; | ||
using Cs = modm::platform::GpioA4; | ||
using Sck = modm::platform::GpioA5; | ||
using Miso = modm::platform::GpioA6; | ||
using Mosi = modm::platform::GpioA7; | ||
using DataCommands = modm::platform::GpioB0; | ||
using Reset = modm::platform::GpioB1; | ||
using Backlight = modm::platform::GpioB10; | ||
} | ||
|
||
modm::Ili9341Spi< | ||
display::Spi, | ||
display::Cs, | ||
display::DataCommands, | ||
display::Reset, | ||
display::Backlight | ||
> tft; | ||
|
||
/* | ||
* Blinks the green user LED with 1 Hz. | ||
* It is on for 90% of the time and off for 10% of the time. | ||
*/ | ||
|
||
int | ||
main() | ||
{ | ||
using namespace modm::literals; | ||
Board::initialize(); | ||
display::Spi::connect< | ||
display::Sck::Sck, display::Miso::Miso, display::Mosi::Mosi>(); | ||
display::Spi::initialize<SystemClock, 1125_kHz>(); | ||
tft.initialize(); | ||
LedGreen::set(); | ||
tft.setColor(modm::glcd::Color::black()); | ||
int16_t w = tft.getWidth(); | ||
int16_t h = tft.getHeight(); | ||
tft.drawLine({0,0}, {w, h}); | ||
tft.drawLine({w,0}, {0, h}); | ||
|
||
while (true) | ||
{ | ||
LedGreen::set(); | ||
modm::delay(900ms); | ||
|
||
LedGreen::reset(); | ||
modm::delay(100ms); | ||
} | ||
|
||
return 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,2 @@ | ||
# Replace this with your custom programmer | ||
source [find interface/stlink-v2.cfg] |
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,12 @@ | ||
<library> | ||
<extends>modm:blue-pill</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/stm32f103c8t6_blue_pill/graphics</option> | ||
<option name="modm:build:openocd.cfg">openocd.cfg</option> | ||
</options> | ||
<modules> | ||
<module>modm:build:scons</module> | ||
<module>modm:driver:ili9341</module> | ||
<module>modm:platform:spi:1</module> | ||
</modules> | ||
</library> |
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