Página 1 de 1

Arm + linux

MensagemEnviado: 03 Ago 2010 18:16
por m3t4l3ir0
:D :D :D :D :D Boa tarde, estou iniciando meu aprendizado com microprocessadores arm, estou usando o LPC2148 da nxp.

So queria saber se estou usando as flags certas no gcc :oops: .

E tambem se esse Makefile esta bom ou pode melhorar :oops: .

Makefile:

Código: Selecionar todos
TARGET   = armcnc

PROJDIRS := boot src

SRCFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
SRSFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.s")

OBJFILES    := $(patsubst %.s,%.o,$(SRSFILES)) $(patsubst %.c,%.o,$(SRCFILES));

AUXFILES := Makefile link.ld

CC = arm-elf-gcc
AS = arm-elf-as
LD = arm-elf-ld
OBJCPY = arm-elf-objcopy

CFLAGS := -Iinclude -fno-common -g -O0
ASFLAGS := -ahls -mapcs-32
LDFLAGS := -Map $(TARGET).map -T link.ld

all: $(OBJFILES)
   $(LD) $(LDFLAGS) -o $(TARGET) $(OBJFILES)
   $(OBJCPY) -O ihex $(TARGET) $(TARGET).hex

clean:
   rm $(OBJFILES)
   rm $(TARGET)
   rm $(TARGET).hex
   rm $(TARGET).map


main.c:

Código: Selecionar todos
#include <cpu.h>
#include <display.h>

char * texto = "Display :)"; // Somenta pra ver se o segmento de dados esta sendo copiado pro lugar certo

void main ( void )
{

   CPU_Init();
   DSP_Init();
   
   PrintXY(0,0,"Testando");
   PrintXY(0,1,texto);

}


display.c:

Código: Selecionar todos
#include <system.h>

#include <cpu.h>

#include <display.h>

#define ENABLE 1
#define DISABLE 0

void DSP_Init ( void )
{

   SetBit(FIO1DIR,P16); // D4
   SetBit(FIO1DIR,P17); // D5
   SetBit(FIO1DIR,P18); // D6
   SetBit(FIO1DIR,P19); // D7

   SetBit(FIO1DIR,P20); // EN
   SetBit(FIO1DIR,P21); // RS

   DSP_Rs(DISABLE);
   DSP_En(DISABLE);

   DSP_Delay();

   DSP_Command(0x33);
   DSP_Command(0x32);
   DSP_Command(0x28);
   DSP_Command(0x0C);
   DSP_Command(0x06);
   DSP_Command(0x01);

   DSP_PrintXY(0,0," ArmCNC Project ");

}

void DSP_Delay ( void )
{
   unsigned long tmp;

   for(tmp=0;tmp<1000;tmp++);
}

void DSP_Rs ( char data )
{
   switch ( data )
   {
      case ENABLE:
         SetBit(FIO1PIN,P21);
      break;

      case DISABLE:
         ClrBit(FIO1PIN,P21);
   }

}

void DSP_En ( char data )
{
   switch ( data )
   {
      case ENABLE:
         SetBit(FIO1PIN,P20);
      break;

      case DISABLE:
         ClrBit(FIO1PIN,P20);
      break;
   }
}

void DSP_Strobe ( void )
{

   DSP_Delay();
   DSP_En(ENABLE);
   DSP_Delay();
   DSP_En(DISABLE);
   DSP_Delay();

}

void DSP_Data ( unsigned char data )
{

   unsigned long OLDMASK = FIO1MASK;

   DSP_Rs(ENABLE);

   FIO1MASK = 0xFFF0FFFF;
   FIO1PIN = ( ( data >> 4 ) << 16 );
   FIO1MASK = OLDMASK;

   DSP_Strobe();

   FIO1MASK = 0xFFF0FFFF;
   FIO1PIN = ( ( data ) << 16 );
   FIO1MASK = OLDMASK;

   DSP_Strobe();

}

void DSP_Command ( unsigned char data )
{

   unsigned long OLDMASK = FIO1MASK;

   DSP_Rs(DISABLE);

   FIO1MASK = 0xFFF0FFFF;
   FIO1PIN = ( ( data >> 4 ) << 16 );
   FIO1MASK = OLDMASK;

   DSP_Strobe();

   FIO1MASK = 0xFFF0FFFF;
   FIO1PIN = ( ( data ) << 16 );
   FIO1MASK = OLDMASK;

   DSP_Strobe();

}

void DSP_Clear ( void )
{
}

void DSP_GotoXY( int x, int y)
{
   switch ( y )
   {
      case 0:
         DSP_Command(0x80 | x);
      break;

      case 1:
         DSP_Command(0xC0 | x);
      break;
   }
}

void DSP_Put ( char data )
{
   DSP_Data ( data );
}

void DSP_PutXY ( int x, int y, char data )
{
   DSP_GotoXY(x,y);
   DSP_Put(data);
}

void DSP_PrintXY ( int x, int y, char * data )
{
   int tmp = 0;

   DSP_GotoXY(x,y);
   while(data[tmp]!='\0')
   {
      DSP_Put(data[tmp]);
      tmp++;
   }
}

MensagemEnviado: 03 Ago 2010 20:18
por fabim
carai, linux no 2148 ? isso que é programador.!!

MensagemEnviado: 03 Ago 2010 20:22
por m3t4l3ir0
carai, linux no 2148 ? isso que é programador.!!


Haha o gzip faz milagres.

so queria mesmo saber se esse Makefile ta certo.

e que semana passada tava fazendo umas modificaćões e acabei apagando todos os arquivos c hehe.

MensagemEnviado: 03 Ago 2010 23:00
por Sergio38br
Num é linux , é GCC....para arm...

[ ]'s
Sergio

MensagemEnviado: 04 Ago 2010 09:21
por tcpipchip
uclinux roda a partir do LPC23xx