Skip to content

Commit

Permalink
[board] Fix DISCO-F469NI rev B-03 touch sensor address
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Feb 11, 2022
1 parent 52ea9b3 commit b18385c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
8 changes: 5 additions & 3 deletions docs/src/guide/custom-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ discover all of modm yet. You can now choose from two levels of customization:

## Using a Board Support Package

Use lbuild to discover the specific BSP configuration you want to use:
Use lbuild to discover the specific BSP configuration you want to use.
Some board configurations support different hardware revisions, so check your
hardware to select the right one:

```
$ lbuild discover
Parser(lbuild)
╰── Repository(modm @ ../../ext/modm) modm: a barebone embedded library generator
├── Option(target) = REQUIRED in [stm32f469ngh6, stm32f469nih6, stm32f469vet6, ...
├── Config(modm:disco-f469ni) STM32F469IDISCOVERY
├── Config(modm:disco-f469ni:b-03) in [b-01, b-03] STM32F469IDISCOVERY
...
```

Expand All @@ -113,7 +115,7 @@ cannot remove any inherited modules.
<library>
<repositories>...</repositories>

<extends>modm:disco-f469ni</extends>
<extends>modm:disco-f469ni:b-03</extends>

<options>...</options>
<modules>...</modules>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/guide/discover.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ format. The `modm/repo.lb` file must be declared to find all modm modules:
Parser(lbuild)
╰── Repository(modm @ .) modm: a barebone embedded library generator
├── Option(target) = REQUIRED in [stm32f469ngh6, stm32f469nih6, stm32f469vet6, ...
├── Config(modm:disco-f469ni) STM32F469IDISCOVERY
├── Config(modm:disco-f469ni:b-03) in [b-01, b-03] STM32F469IDISCOVERY
...
```

Expand Down Expand Up @@ -54,7 +54,7 @@ modules for this specific target. We will choose the `stm32f469nih6` device:
Parser(lbuild)
╰── Repository(modm @ .) modm: a barebone embedded library generator
├── Option(target) = stm32f469nih6 in [stm32f407vgt6, stm32f469nih6, ...
├── Config(modm:disco-f469ni) STM32F469IDISCOVERY
├── Config(modm:disco-f469ni:b-03) in [b-01, b-03] STM32F469IDISCOVERY
...
├── Module(modm:board) Board Support Packages
│ ╰── Module(modm:board:disco-f469ni) STM32F469IDISCOVERY
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32f469_discovery/game_of_life/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ constexpr modm::MemoryTraits traits = SCALE >= 4 ? modm::MemoryFastData : modm::
void read_touch()
{
static Touch::Data touchData;
static Touch touchSensor(touchData);
static Touch touchSensor(touchData, TouchAddress);
static bool initialized = false;
if (not initialized) {
// Configure the touchscreen to sample with 60Hz in active and monitor mode.
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32f469_discovery/lvgl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static lv_color_t* buf;
static constexpr size_t buf_size = LV_HOR_RES_MAX * LV_VER_RES_MAX;

Touch::Data touchData;
Touch touch{touchData};
Touch touch{touchData, TouchAddress};

void my_touchpad_read(lv_indev_drv_t*, lv_indev_data_t* data)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32f469_discovery/touchscreen/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LineDrawer : public modm::pt::Protothread
{
public:
LineDrawer() :
touch(touchData),
touch(touchData, TouchAddress),
display{Board::getDisplay()},
px{-1, -1}, py{-1, -1},
c{modm::color::html::White, modm::color::html::White}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ using Scl = GpioB8;
using Sda = GpioB9;
using I2cMaster = I2cMaster1;
using Touch = modm::Ft6x06< I2cMaster >;
constexpr uint8_t TouchAddress = {{touch_address}};
}

namespace usb
Expand Down
11 changes: 9 additions & 2 deletions src/modm/board/disco_f469ni/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
def init(module):
module.name = ":board:disco-f469ni"
module.description = FileReader("module.md")
# Revisions = [b-03, b-01]

def prepare(module, options):
if not options[":target"].partname.startswith("stm32f469nih"):
Expand All @@ -39,10 +40,16 @@ def build(env):
env.outbasepath = "modm/src/modm/board"
env.substitutions = {
"with_logger": True,
"with_assert": env.has_module(":architecture:assert")
"with_assert": env.has_module(":architecture:assert"),
"touch_address": 0x38 if env[":disco-f469ni"] == "b-03" else 0x2a,
}
env.template("../board.cpp.in", "board.cpp")
env.copy('.')
env.copy("board_display.cpp")
env.copy("board_dsi.cpp")
env.copy("board_init.cpp")
env.copy("board_otm8009a.cpp")
env.copy("board_sdram.cpp")
env.template("board.hpp.in")
env.collect(":build:openocd.source", "board/stm32f469discovery.cfg")

env.collect(":platform:cortex-m:linkerscript.memory", linkerscript_memory)
Expand Down
14 changes: 14 additions & 0 deletions src/modm/board/disco_f469ni/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ Access to the capacitive touchscreen is provided in the `Board::ft6` namespace.
Call `Board::initializeTouchscreen()` to setup the peripherals.

[Product Link](https://www.st.com/en/evaluation-tools/32f469idiscovery.html)


## Hardware Revisions

The revision B-03 has a different touch sensor address from B-01, which is
provided as `Board::ft6::TouchAddress`:

```cpp
Board::ft6::Touch::Data data;
Board::ft6::Touch touchSensor(data, Board::ft6::TouchAddress);
```
If you have an earlier revision, you can extend your configuration from
`modm:disco-f469ni:b-01`.

0 comments on commit b18385c

Please sign in to comment.