Accessing struct member and getting error I do not know how to fix it.
-
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
-
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
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 aregtype
variable, so it needs a cast, or some conversion to the correct variable type. -
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 aregtype
variable, so it needs a cast, or some conversion to the correct variable type.