Hola todos!
Estoy trabajando con MPLAB v3.51 y XC16 v1.31 para un dsPIC33EP512MU810 intentando implementar el protocolo MiWi. Ya lo hice funcionar en un PIC18F26J50 en XC8, asi que ahora intento mudar el framework del protocolo, pero cuando cambio de compilador me da problemas en la definicion de uniones para crear un tipo de variable.
El primer problema que note es que tengo definida esta union:
typedef union _API_UINT16_UNION
{
uint8_t v[2];
uint16_t Val;
}API_UINT16_UNION;
la cual uso luego (y por cierto, todo esto viene dado por la libreria MLA propia de Microchip) dentro de una estructura:
typedef struct
{
union
{
uint8_t Val;
struct
{
uint8_t packetType : 2; // type of packet. Possible types are
// * PACKET_TYPE_DATA - Data type
// * PACKET_TYPE_COMMAND - Command type
// * PACKET_TYPE_ACK - Acknowledgement type
// * PACKET_TYPE_RESERVE - Reserved type
uint8_t broadcast : 1; // 1: broadcast, 0: unicast
uint8_t secEn : 1; // 1: secure the MAC payload, 0: send plain text
uint8_t repeat : 1; // 1: allow repeaters to forward the message, 0: send message directly
uint8_t ackReq : 1; // 1: acknowledgement required, 0: no acknowldgement
uint8_t destPrsnt : 1; // 1: destination address in the packet, 0: destination address not in the packet
uint8_t sourcePrsnt : 1; // 1: source address in the packet, 0: source address not in the packet
} bits;
} flags;
uint8_t *DestAddress; // destination address
bool altDestAddr; // use the alternative network address as destination in the packet
bool altSrcAddr; // use the alternative network address as source in the packet
API_UINT16_UNION DestPANID; // PAN identifier of the destination
} MAC_TRANS_PARAM;
pero no compila el programa ya que me genera este tipo de error:
MIWI_framework/driver/../../MIWI_framework/miwi/../driver/drv_mrf_miwi.h:76:9: error: expected specifier-qualifier-list before 'API_UINT16_UNION'
intente colocar un 'espicificador', pero asoma otro problema:
volatile API_UINT16_UNION DestPANID;
MIWI_framework/miwi/../../MIWI_framework/miwi/../driver/drv_mrf_miwi.h:76:43: error: expected ':', ',', ';', '}' or '__attribute__' before 'DestPANID'
Intente colocar un 'atributo' antes y despues de DestPANID e igual no funciona, sigue asomando el mismo error, de igual forma intente colocando el atributo en la definicion propia de la union pero tampoco funciona. Por lo que la estructura no reconoce esta parte de la variable, y luego, cuando uso la estructura me genera errores de que no reconoce ese miembro dentro de la misma:
MIWI_framework/miwi/miwi_mesh.c:3870:20: error: 'MAC_TRANS_PARAM' has no member named 'DestPANID'
Luego me di cuenta que tengo el mismo problema con otra union (de nuevo, propia de la libreria MLA de Microchip):
typedef union __CONNECTION_STATUS
{
uint8_t Val;
struct _CONNECTION_STAUTS_bits
{
uint8_t RXOnWhenIdle :1; //1 = transceiver always on, 0 = transceiver sleeps when idle
uint8_t directConnection :1; //1 = can talk to this device directly, 0 = must route to this device
uint8_t longAddressValid :1; //1 = long address valid, 0 = long address unknown
uint8_t shortAddressValid :1; //1 = short address valid, 0 = short address unknown
uint8_t FinishJoin :1; //1 = already finish joining procedure, 0 = in the process of join
uint8_t isFamily :1; //1 = family member (parent/child), 0 = not family
uint8_t filler :1;
uint8_t isValid :1; //1 = this entry is valid, 0 = this entry is not valid
} bits;
} CONNECTION_STATUS;
typedef struct __CONNECTION_ENTRY
{
#if !defined(PROTOCOL_P2P)
API_UINT16_UNION PANID; // PAN Identifier of the peer device. May not necessary in P2P protocol
API_UINT16_UNION AltAddress; // Alternative address of the peer device. Not necessary in P2P protocol
#endif
uint8_t Address[MY_ADDRESS_LENGTH]; // Permanent address of peer device
CONNECTION_STATUS status;
#if ADDITIONAL_NODE_ID_SIZE > 0
uint8_t PeerInfo[ADDITIONAL_NODE_ID_SIZE]; // Additional Node ID information, if defined in application layer
#endif
} CONNECTION_ENTRY;
MIWI_framework/miwi/miwi_mesh.c:3861:54: error: 'CONNECTION_ENTRY' has no member named 'status'
Asi que asumo que mi problema es con la definicion en general de las uniones, pero no logro ver el error. Puede alguien ayudarme, darme alguna idea por favor?