Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Please advise me on C++ coding structure

Please advise me on C++ coding structure

Scheduled Pinned Locked Moved C / C++ / MFC
hardwarec++tutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • V 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

      L Offline
      L Offline
      leon de boer
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups