Alias undeclared

OP #4357273
Lesenswert?

hallo,
seit kurzem kann ich praktisch keinen Code mehr in Atmel Studio 7 
compilieren. Selbst bei ganz einfachen Dingen. Ich habe ein neues ASF 
Projekt für den Arduino DUE angelegt und nur einen Alias auf einen 
Portpin gesetzt. Fehlermeldung: 'IOPORT_PORTD' undeclared (first use in 
this function)


Hier der ganze Code:
#include <asf.h>


int main( void )
{
  board_init();

  // Insert application code here, after the board has been initialized.


  // create pin aliases
  #define LED_STATUS_PIN  IOPORT_CREATE_PIN( PORTD, 4 )

  // PIN direction OUTPUT.
  ioport_set_pin_dir( LED_STATUS_PIN, IOPORT_DIR_OUTPUT );

  // infinite loop
  while( 1 )
  {
    // some delay
    delay_ms( 500 );
  }   // end of while
}


Kann mir jemand weiterhelfen. Eigentlich ging das schon mal bei mir!
Angehängte Dateien:
OP #4357290
Lesenswert?

Die Fehlermeldung kommt von der ioport_pio.h. Sobald ich in der main() 
die Zeile drin habe, kann ich den Code nicht mehr compilieren. Ich hatte 
schon vermutet, daß irgendwas in meiner Datei ioport_pio.h nicht passt. 
Allerdings habe ich mir schon gerade die neueste Version von Atmel 
Studio neu installiert und ein komplett neues Projekt aufgesetzt. (ASF 
Board Projekt und Arduino DUE ausgewählt)
Angehängte Dateien:
Persönliche Seite #4357442
Lesenswert?

Ventil schrieb:
> Es gibt doch im ganzen Programm keine Zeile mit 'IOPORT_PORTD'.

Die wird vom als Screenshot geposteten Macro IPORT_CREATE_PIN erzeugt.

1
#define LED_STATUS_PIN IOPORT_CREATE_PIN( PORTD, 4 )

Und das ist das ominöse Macro:
1
#define IOPORT_CREATE_PIN(port, pin) ((IOPORT_ ## port) * 32 + (pin))

Das Resultat ist dann
1
#define LED_STATUS_PIN ((IOPORT_PORTD) * 32 + (4))
#4357455
Lesenswert?

Michael R. schrieb:
> Die Fehlermeldung kommt von der ioport_pio.h.

In deinem Screenshot stehen doch die verfügbare Porte drinne.
Da ist kein PORTD dabei, sondern nur PIOA bis PIOF

Also, schreib
1
// create pin alias
2
#define LED_STATUS_PIN IOPORT_CREATE_PIN(PIOD, 4)
und gut is.

Ausserdem sollst du dich an der Tafel stellen und 1000x schrieben:
"Ich darf Sourcecode nicht als Screenshot posten!"
OP #4357486
Lesenswert?

Genau, in meiner main.c ist oben ganz oben die <asf.h> includiert.

Hier ein Auszug aus der <asf.h> (die übrigens automatisch beim Projekt 
anlegen includiert wird:

#ifndef ASF_H
#define ASF_H

/*
 * This file includes all API header files for the selected drivers from 
ASF.
 * Note: There might be duplicate includes required by more than one 
driver.
 *
 * The file is automatically generated and will be re-written when
 * running the ASF driver selector tool. Any changes will be discarded.
 */

// From module: Common SAM compiler driver
#include <compiler.h>
#include <status_codes.h>

// From module: GPIO - General purpose Input/Output
#include <gpio.h>

// From module: Generic board support
#include <board.h>

// From module: IOPORT - General purpose I/O service
#include <ioport.h>

// From module: Interrupt management - SAM implementation
#include <interrupt.h>

// From module: PIO - Parallel Input/Output Controller
#include <pio.h>

// From module: PMC - Power Management Controller
#include <pmc.h>
#include <sleep.h>

// From module: Part identification macros
#include <parts.h>

// From module: SAM3X startup code
#include <exceptions.h>

// From module: System Clock Control - SAM3X/A implementation
#include <sysclk.h>

// From module: pio_handler support enabled
#include <pio_handler.h>

#endif // ASF_H



Hier wird die <ioport.h> includiert.
Hier ein Auszug aus dieser <ioport.h>

#if XMEGA
# include "xmega/ioport.h"
# if defined(IOPORT_XMEGA_COMPAT)
#  include "xmega/ioport_compat.h"
# endif
#elif MEGA
#  include "mega/ioport.h"
#elif UC3
# include "uc3/ioport.h"
#elif SAM
# if SAM4L
#  include "sam/ioport_gpio.h"
# elif (SAMD20 | SAMD21)
#  include "sam0/ioport.h"
# else
#  include "sam/ioport_pio.h"
# endif
#endif


Hier wird dann "sam/ioport_pio.h" includiert, da ich einen SAM3x8E 
verwende

Von hier kommt der Fehler. Komisch ist nur, daß dieser dann schon beim 
Anlegen des neuen Projektes kommt.
Übrigens: Ich kann in der main() nicht auf PORTD klicken und "Goto 
Implemention" aufrufen. Ist hier noch unbekannt, obwohl ich über asf.h 
-> ioport.h und sam/ioport_pio.h eigentlich alles includiert habe

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren