cancel
Showing results for 
Search instead for 
Did you mean: 

Why we need C++ for modern hardware

vybor
Associate III

Modern microcontrollers have a lot of perifhery. Several buses of different types.

STM32 hardware has outgrown C. Too much complex perifhery to manage with procedural language.

ST software is much behind of ST hardware.

 

Look at any I2C or SPI open source C library. Any can be used with one device of some type only.

In case of I2C there are lines like this in header:

#define SSD1306_I2C_PORT hi2c1

#define SSD1306_I2C_ADDR (0x3C << 1)

and

extern I2C_HandleTypeDef SSD1306_I2C_PORT;

in C file.

If somebody need one device on differnt port or on different device address he have to edit source files of library.

If somebody need more devices of the same type on different device addresses and/or on different ports, he have to throw away library and write own solution.

It is not possible to get library and make something like this:

i2c_device1 = create_i2c_device(port1, dev_adr1, params1...);

i2c_device2 = create_i2c_device(port1, dev_adr2, params2...);

i2c_device3 = create_i2c_device(port2, dev_adr3, params3...);

 

It's impossible to use two OLED i2c displyas with open source C libraries. It's inacceptable.

I convert C library to C++ and can use

  ssd1306cpp oled1
    { &hi2c1, dev1_adr, disp1_buf, disp1_w, disp1_h, buf1_sz };

  ssd1306cpp oled2
    { &hi2c2, dev2_adr, disp2_buf, disp2_w, disp2_h, buf2_sz };

We definitly need C++ to manage great ST hardware.

 

1 REPLY 1
TDK
Super User

Related/duplicate:

Generation code to CPP files - STMicroelectronics Community

 

> It's impossible to use two OLED i2c displyas with open source C libraries.

Huh? I do that. It's working okay for me.

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