cancel
Showing results for 
Search instead for 
Did you mean: 

One .ioc project for different hardware configurations

MGuth.1
Associate III

Hi all

 

First of all, merry christmas to all of you. As I got a little spare time between the years I'm thinking about a STM32 project again. 

I'm wondering if there's a best practice for one hex file supporting several hardware configurations. The configuration could be set by reading a config file or by checking IDs from each peripheral.

To be clear: the STM32 MCU is the same for each configuration. I'm thinking about supporting different GNSS-, Display-, WiFi- Modules etc. Having one library for each component (e.g. display module) calling the correct method for each driver IC (e.g. ST7789V instead of a ILI9488).

To make life's of consumers and me as a "sw provider" easier, it would be great to provide one hex only that supports every possible hardware composition.

 

First approach coming to my mind is to check the config file at boot, setting a flag which then is used in the libraries to differ between display IC A or B respectively the methods.

But I guess there's a better option for that?! :D

 

Best

Matthias

5 REPLIES 5
AScha.3
Chief II

Hi,

1. you cannot use one (ioc) hardware definition for totally different hardware.

2. you CAN make a hardware definition, that includes all variants you need, but decide at program start, maybe by configuration file from a eeprom or just some dip-switches , what hardware is to be used here.

With dip switches to select actual hardware i seen on some SPS controllers, where you can set : ok, i have 4 analog IN, 8 dig. IN, 12 dig. OUT , 2 x serial comm. ...etc.

But there is an obvious end to "flexible hardware selection" : you cannot use the same pins for a hi speed USB, and connect to CAN transceiver and use for display and memory interface and wire all together. 🙂 

If you feel a post has answered your question, please click "Accept as Solution".
TDK
Guru

HAL isn't really set up for this. There's nothing stopping you from calling HAL_SPI_Init and HAL_SPI_DeInit (for an SPI example) selectively, but you're fighting against the current here, and CubeMX won't let you define multiple peripherals that use the same pins. 

If you feel a post has answered your question, please click "Accept as Solution".
MGuth.1
Associate III

Thanks for your answers. I feel like my question was a little misleading.
I'm aware, that I can't use one CubeMX Project/.ioc-file for different types of hardware and connect all together (e.g. it's not possible to have both a display and memory connected to one FMC-interface)

I'm wondering about having different components of the same type. Let's say there are two devices (A and B). Both devices are identical except for a different display driver unit. Let's say device A uses a ST7789V, device B uses an ILI9341. They are connected to the same interface using the same pins.
However for device A with the ST7789v I'd need to send a 0xB1 as a command via the FMC interface for the "RGB Interface Control". On device B with ILI9341 it'd be a 0xB0.

Still thinking that using flags set at the boot-up of the device and checked in a "kind of HAL-"library when calling the specific function is the way to go?!

And who setting those "magic" flags ?   Nobody.

You can check for similar hardware the chip, by ID register or some response to identify the connected TFT or so (some Arduino libs doing this), 

or use some dip switches, to define , what is used / connected and set your hardware and libs according to this.

If you feel a post has answered your question, please click "Accept as Solution".

If the interface is set up the same way in both cases, the IOC file should work for both of them.

Your code should be able to differentiate and send the right command. This will be in user code somewhere.

if (ST7789) {
    // send 0xB1
else if (ILI9341) {
    // send 0xB0
} else {
    // error
}

 

If you feel a post has answered your question, please click "Accept as Solution".