diff --git a/docs/src/guide/custom-project.md b/docs/src/guide/custom-project.md index 493f732649..10442bafb6 100644 --- a/docs/src/guide/custom-project.md +++ b/docs/src/guide/custom-project.md @@ -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 ... ``` @@ -113,7 +115,7 @@ cannot remove any inherited modules. ... - modm:disco-f469ni + modm:disco-f469ni:b-03 ... ... diff --git a/docs/src/guide/discover.md b/docs/src/guide/discover.md index 9d60d69069..23058d900e 100644 --- a/docs/src/guide/discover.md +++ b/docs/src/guide/discover.md @@ -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 ... ``` @@ -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 diff --git a/examples/stm32f469_discovery/game_of_life/main.cpp b/examples/stm32f469_discovery/game_of_life/main.cpp index 662edac1bb..1b65cf0366 100644 --- a/examples/stm32f469_discovery/game_of_life/main.cpp +++ b/examples/stm32f469_discovery/game_of_life/main.cpp @@ -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. diff --git a/examples/stm32f469_discovery/lvgl/main.cpp b/examples/stm32f469_discovery/lvgl/main.cpp index c5cc0e338d..87c9ce96d8 100644 --- a/examples/stm32f469_discovery/lvgl/main.cpp +++ b/examples/stm32f469_discovery/lvgl/main.cpp @@ -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) { diff --git a/examples/stm32f469_discovery/touchscreen/main.cpp b/examples/stm32f469_discovery/touchscreen/main.cpp index 0bd3fb1e86..222f661795 100644 --- a/examples/stm32f469_discovery/touchscreen/main.cpp +++ b/examples/stm32f469_discovery/touchscreen/main.cpp @@ -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} diff --git a/src/modm/board/disco_f469ni/board.hpp b/src/modm/board/disco_f469ni/board.hpp.in similarity index 99% rename from src/modm/board/disco_f469ni/board.hpp rename to src/modm/board/disco_f469ni/board.hpp.in index dfd8e61ae3..183680baf2 100644 --- a/src/modm/board/disco_f469ni/board.hpp +++ b/src/modm/board/disco_f469ni/board.hpp.in @@ -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 diff --git a/src/modm/board/disco_f469ni/module.lb b/src/modm/board/disco_f469ni/module.lb index d703d96396..f2d80b9be4 100644 --- a/src/modm/board/disco_f469ni/module.lb +++ b/src/modm/board/disco_f469ni/module.lb @@ -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"): @@ -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) diff --git a/src/modm/board/disco_f469ni/module.md b/src/modm/board/disco_f469ni/module.md index 66f85db7bc..b781925fb5 100644 --- a/src/modm/board/disco_f469ni/module.md +++ b/src/modm/board/disco_f469ni/module.md @@ -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`.