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. Accessing struct member and getting error I do not know how to fix it.

Accessing struct member and getting error I do not know how to fix it.

Scheduled Pinned Locked Moved C / C++ / MFC
helphardwarec++data-structurestutorial
3 Posts 2 Posters 1 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 am stuck again. I have inherited this piece of code which basically associate SAM3X8E pins with hardware registers. I think it is pretty clever usage of array of struct and it works fine. The original code did not include convenient way to access ALL of the registers, so I am trying to build the missing registers from basis assignments. The registers are related to "port" ( designated PIOA.. thru PIOF) so if I can get the port assigned to a pin I can build all of the missing registers. Here is the code to get the the port info from first (test) pin: P_DB is a pointer to pins array. ( I have left all of the support code here FYI ) .... regtype TEST = *P_DB.pPort; *p_DB[0] fails same way //lcd_i2c.print( (int) P_DB[0].pPort, HEX); // test access first pin ... Now here is the error message from compiler ( on TEST) and I have no idea how to fix it: C:\DOCUME~1\Vaclav\LOCALS~1\Temp\build6265730787782115322.tmp\sketch\AAA_TFT_LCD.h: In member function 'void TFT_LCD::LCD_Writ_Bus(char, char, byte)': C:\DOCUME~1\Vaclav\LOCALS~1\Temp\build6265730787782115322.tmp\sketch\AAA_TFT_LCD.h:4370:30: error: request for member 'pPort' in '((TFT_LCD*)this)->TFT_LCD::P_DB', which is of non-class type 'volatile uint32_t* [16] {aka volatile long unsigned int* [16]}' regtype TEST = *P_DB.pPort; The error on (int) P_DB[0].pPort, code is pretty much same. I hope I have provided all of the info necessary so someone can suggest a solution on how to access the pPort member. /* Types used for the tables below */ // theae are indexes to array - what a trick //typedef struct _PinDescription //{ // Pio* pPort ; // uint32_t ulPin ; // uint32_t ulPeripheralId ; // EPioType ulPinType ; // uint32_t ulPinConfiguration ; // uint32_t ulPinAttribute ; // EAnalogChannel ulAnalogChannel ; /* Analog pin in the Arduino context (label on the board) */ // EAnalogChannel ulADCChannelNumber ; /* ADC Channel number in the SAM device */ // EPWMChannel ulPWMChannel ; // ETCChannel ulTCChannel ; //} PinDescription ; // ///* Pins table to be instanciated into variant.cpp */ //extern const PinDescription g_APinDescription[] ; //// Number of pins defined in PinDescription array //#define PINS_COUNT (79u) //#define NUM_DIGITAL_PINS (54u) //#define NUM_ANALOG_INPUTS (12u) // //#define digitalPinToPort(P) ( g_APinDescription

    L 1 Reply Last reply
    0
    • V Vaclav_

      I am stuck again. I have inherited this piece of code which basically associate SAM3X8E pins with hardware registers. I think it is pretty clever usage of array of struct and it works fine. The original code did not include convenient way to access ALL of the registers, so I am trying to build the missing registers from basis assignments. The registers are related to "port" ( designated PIOA.. thru PIOF) so if I can get the port assigned to a pin I can build all of the missing registers. Here is the code to get the the port info from first (test) pin: P_DB is a pointer to pins array. ( I have left all of the support code here FYI ) .... regtype TEST = *P_DB.pPort; *p_DB[0] fails same way //lcd_i2c.print( (int) P_DB[0].pPort, HEX); // test access first pin ... Now here is the error message from compiler ( on TEST) and I have no idea how to fix it: C:\DOCUME~1\Vaclav\LOCALS~1\Temp\build6265730787782115322.tmp\sketch\AAA_TFT_LCD.h: In member function 'void TFT_LCD::LCD_Writ_Bus(char, char, byte)': C:\DOCUME~1\Vaclav\LOCALS~1\Temp\build6265730787782115322.tmp\sketch\AAA_TFT_LCD.h:4370:30: error: request for member 'pPort' in '((TFT_LCD*)this)->TFT_LCD::P_DB', which is of non-class type 'volatile uint32_t* [16] {aka volatile long unsigned int* [16]}' regtype TEST = *P_DB.pPort; The error on (int) P_DB[0].pPort, code is pretty much same. I hope I have provided all of the info necessary so someone can suggest a solution on how to access the pPort member. /* Types used for the tables below */ // theae are indexes to array - what a trick //typedef struct _PinDescription //{ // Pio* pPort ; // uint32_t ulPin ; // uint32_t ulPeripheralId ; // EPioType ulPinType ; // uint32_t ulPinConfiguration ; // uint32_t ulPinAttribute ; // EAnalogChannel ulAnalogChannel ; /* Analog pin in the Arduino context (label on the board) */ // EAnalogChannel ulADCChannelNumber ; /* ADC Channel number in the SAM device */ // EPWMChannel ulPWMChannel ; // ETCChannel ulTCChannel ; //} PinDescription ; // ///* Pins table to be instanciated into variant.cpp */ //extern const PinDescription g_APinDescription[] ; //// Number of pins defined in PinDescription array //#define PINS_COUNT (79u) //#define NUM_DIGITAL_PINS (54u) //#define NUM_ANALOG_INPUTS (12u) // //#define digitalPinToPort(P) ( g_APinDescription

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Firstly (and not for the first time) please put <pre> tags around your code so it is easy to read, (use the code link above the edit window) thus:

      regtype TEST = \*P\_DB.pPort;         \*p\_DB\[0\] fails same way 
      //lcd\_i2c.print( (int) P\_DB\[0\].pPort, HEX); // test access first pin 
      

      As to the error, you have Pio* pPort; in your structure, but you are trying to assign it to a regtype variable, so it needs a cast, or some conversion to the correct variable type.

      V 1 Reply Last reply
      0
      • L Lost User

        Firstly (and not for the first time) please put <pre> tags around your code so it is easy to read, (use the code link above the edit window) thus:

        regtype TEST = \*P\_DB.pPort;         \*p\_DB\[0\] fails same way 
        //lcd\_i2c.print( (int) P\_DB\[0\].pPort, HEX); // test access first pin 
        

        As to the error, you have Pio* pPort; in your structure, but you are trying to assign it to a regtype variable, so it needs a cast, or some conversion to the correct variable type.

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        Thanks, but I found I already have the port data and do not need the access to the struct after all.

        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