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[P].pPort ) so what is this refernce to .pPort
//#define digitalPinToBitMask(P) ( g_APinDescription[P].ulPin )
////#define analogInPinToBit(P) ( )
//#define portOutputRegister(port) ( &(port->PIO_ODSR) )
//#define portInputRegister(port) ( &(port->PIO_PDSR) )
//#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER )
//
///*
// * Pins descriptions
// * global array of all pins descriptions as what type
// * Arduino/hardware/arduino/sam/variants/arduino_due_x/variant.cpp
//
// */
//extern const PinDescription g_APinDescription[]=
//{
// // 0 .. 53 - Digital pins
// // ----------------------
// // 0/1 - UART (Serial)
// { PIOA, PIO_PA8A_URXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // URXD
// { PIOA, PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // UTXD
//
// // 2
<a href=""></a>[<a href="" target="_blank">^</a>]