Please advise me on C++ coding structure
-
I like to rebuild my Raspberry Pi code to have "top down" structure. On top would be the device "primitives" class - for example LCD draw circle In middle I like to have hardware specifics, maybe even protocol (SPI,I2C) specifics - BCMx processor And finally the access to I/O "pins" I was thinking of "cascaded C++ " hierarchy but it would not be C++ hierarchy for real. Or just simple top class having supporting class as variable. Not sure how flexible that would be. The idea is to be able to add another "top" device and reuse the supporting classes. I hope this makes sense and if I have asked this before - just ignore OF. Thanks Cheers Vaclav
-
I like to rebuild my Raspberry Pi code to have "top down" structure. On top would be the device "primitives" class - for example LCD draw circle In middle I like to have hardware specifics, maybe even protocol (SPI,I2C) specifics - BCMx processor And finally the access to I/O "pins" I was thinking of "cascaded C++ " hierarchy but it would not be C++ hierarchy for real. Or just simple top class having supporting class as variable. Not sure how flexible that would be. The idea is to be able to add another "top" device and reuse the supporting classes. I hope this makes sense and if I have asked this before - just ignore OF. Thanks Cheers Vaclav
It actually more complex than that because on a Pi2,Pi3 you have 4 cores so you will have spinlocks/semaphores on all the devices. What are you doing with cores 1,2,3 at the moment are they still parked or in use? I assume your code isn't under linux given you have dragged the devices out to objects :-) Assuming baremetal I would strongly suggest you look at circle GitHub - rsta2/circle: A C++ bare metal environment for Raspberry Pi with USB[^] I am not sure you can develop much of a hierarchy it all needs to be fairly flat if you want to use the multicores, welcome to multicore programming :-)
In vino veritas