PONTEIRO C.

Software e Hardware para uC PIC

Moderadores: andre_luis, 51, guest2003, Renie

Mensagempor chipselect » 27 Out 2008 16:24

fazer isso:

Dst = &BufferDescriptor;

o "Dst" tá declarado como um ponteiro para "unsigned short int", não pode mudar para:
struct TBufferDescriptor *Dst;
??

outra coisa que vc poderia melhorar é a declaração do TBufferDescriptor, em vez de:
typedef struct TBufferDescriptor{ // definí um tipo
unsigned short Status;
unsigned short ByteCount;
unsigned int Address;
};

seria algo do tipo:
typedef struct TBufferDescriptor{ // definí um tipo
unsigned short Status;
unsigned short ByteCount;
unsigned int Address;
}BufferDescriptor;

daí vc pode tirar o "struct" quando vai declarar uma variável pra essa estrutura, ficarndo assim:

BufferDescriptor variavel; // antes tinha que ser struct TBufferDescriptor variavel...

nos compiladores que uso, eu declaro assim:
typedef struct { // definí um tipo
unsigned short Status;
unsigned short ByteCount;
unsigned int Address;
}TBufferDescriptor;

TBufferDescriptor variavel;
chipselect
Word
 
Mensagens: 744
Registrado em: 16 Out 2006 18:50

Mensagempor msamsoniuk » 27 Out 2008 17:34

uia! teu mcu eh 16 bits ? vc gosta tanto de short hehehe tenta assim:

Código: Selecionar todos
void CopyBufferDescriptor(void){
unsigned char *Src, *Dst;
unsigned char Tmp, I;

  Src = 0;

  Tmp = ((USTATCopy >> 2) & 0x1F); // get Endpoint and direction
  switch (Tmp){
  case  0: // EP0 OUT
       Src = &BDEP0OUTStat;
  break;
  case  1: // EP0 IN
       Src = &BDEP0INStat;
  break;
  case  2: // EP1 OUT
       Src = &BDEP1OUTStat;
  break;
  case  3: // EP1 IN
       Src = &BDEP1INStat;
  break;
  }

  if (Src != 0){  // copy endpoint descriptor
    Dst = (unsigned char *) &BufferDescriptor;

    for (I = 0 ; I = (sizeof(BufferDescriptor) - 1)); I++){
      *Dst++ = *Src++;
    }
  }
}


isso pq vc tem q considerar o seguinte:

1 - sizeof() retorna o tamanho em bytes
2 - *Src++ ou *Dst++ incrementam escalando o tamanho da variavel... para dar certo, eles tem que ser char, como eu fiz... ou vc medir sizeof()/2 :)
3 - uma outra possibilidade seria usar memcpy().
Avatar do usuário
msamsoniuk
Dword
 
Mensagens: 2935
Registrado em: 13 Out 2006 18:04

Mensagempor Djalma Toledo Rodrigues » 31 Out 2008 15:31

Pessoal cadê o Fabim ? Foi excluido daqui do Fórum é?
Avatar do usuário
Djalma Toledo Rodrigues
Dword
 
Mensagens: 2334
Registrado em: 03 Ago 2008 13:22

Anterior

Voltar para PIC

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x