
Moderadores: andre_luis, 51, guest2003, Renie
fabim escreveu:1° ponteiros risorvidos..
2° definições de tipos..
PASCAL.
type TBufferDescriptor =
record
Status: byte;
ByteCount: byte;
Address: word;
end;
var BufferDescriptor : TBufferDescriptor;
Ele esta dizendo o seguinte.
cria variavel BufferDescriptor
Byte 0 = Status
byte 1 = ByteCount
byte 2 = Address // aqui é uma word..INT. então é byte 2e3
Quero modificar o valor do byte 1"Bytecount".
BufferDescriptor.Bytecount := 22;
quero ler o valor de bytecount.
Meu_Byte := BufferDescriptor.Bytecount;
Como fica este tipo de estrutura no C.?
Especificamente utilizando as nomenclaturas que eu coloquei á cima ?
Fabim
fabim escreveu:tchelo.
Observe que em pascal, é feita a definição depois de criar o tipo de varitavel.
1° eu crio a Tmeu_tipo_de_var..
Defino uma variavel como tipo Tmeu
Minha_var : Tmeu_tipo_de_var. <<
nesta criação de tipo de var em C.
struct {
unsigned char Status;
unsigned char Bytecount;
unsigned short Address;
} TBufferDestriptor;
Eu ja estou criando a variavel propriamente dito né ?
Ou seja não preciso fazer mensão de um nome para um tipo..
ficaria simplesmente assim.
struct {
unsigned char Status;
unsigned char Bytecount;
unsigned short Address;
} BufferDestriptor;
?
Fabim
0x82: //Endpoint para Host
begin
Ep = SetUpPacket.wIndex and 0x8F; // endpoint number <-- changed 11-10-2008
case SetUpPacket.bRequest of
USB_GET_STATUS: //GetEndpointStatus; <-- contents changed 11-10-2008
begin
case Ep of
USB_EP00_OUT : BuffEP0IN[0] = bit(BDEP0OUTStat and USB_BSTALL);
USB_EP00_IN : BuffEP0IN[0] = bit(BDEP0INStat and USB_BSTALL);
USB_EP01_OUT : BuffEP0IN[0] = bit(BDEP1OUTStat and USB_BSTALL);
USB_EP01_IN : BuffEP0IN[0] = bit(BDEP1INStat and USB_BSTALL);
end;
BuffEP0IN[1] = 0;
BDEP0INCnt = 2;
BDEP0INStat = 0xC8; // data 1 packet, sets UOWN bit: go
end;
USB_SYNCH_FRAME: begin end;
end
end
else
begin
case (SetUpPacket.bmRequestType and 0x60) >> 5 of
0: // Standard request
1: ClassSpecificRequest; // Class specific request
2: begin // no action end; // CheckforVendorRequest;
end;
end;
fabim escreveu:1° ponteiros, risorvidos..
2° definições de tipos, risorvidos..
3° função switch.
Se eu bem entendi no C.
switch (salario){
case minimo { a = "coitado"};
case menos_minimo{a = "putz_fudeu"};
case menos_menio_minimo{a = "so no brasil mesmo"};
}
Bem, a estrutura é simples,
"VAI PARA VALOR = A REFERIDO EM SALARIO"
pascal é
CASE salario OF
begin
minimo: a := "coitado";
menos_minimo: a := "putz f****";
menos_menio_minimo: a := "so no brasil mesmo";
end;
Mesmissima coisa, mudou só a forma da sintaxi..
agóra to com um pau aqui..
- Código: Selecionar todos
0x82: //Endpoint para Host
begin
Ep = SetUpPacket.wIndex and 0x8F; // endpoint number <-- changed 11-10-2008
case SetUpPacket.bRequest of
USB_GET_STATUS: //GetEndpointStatus; <-- contents changed 11-10-2008
begin
case Ep of
USB_EP00_OUT : BuffEP0IN[0] = bit(BDEP0OUTStat and USB_BSTALL);
USB_EP00_IN : BuffEP0IN[0] = bit(BDEP0INStat and USB_BSTALL);
USB_EP01_OUT : BuffEP0IN[0] = bit(BDEP1OUTStat and USB_BSTALL);
USB_EP01_IN : BuffEP0IN[0] = bit(BDEP1INStat and USB_BSTALL);
end;
BuffEP0IN[1] = 0;
BDEP0INCnt = 2;
BDEP0INStat = 0xC8; // data 1 packet, sets UOWN bit: go
end;
USB_SYNCH_FRAME: begin end;
end
end
else
begin
case (SetUpPacket.bmRequestType and 0x60) >> 5 of
0: // Standard request
1: ClassSpecificRequest; // Class specific request
2: begin // no action end; // CheckforVendorRequest;
end;
end;
Este fragmento, faz mensão da seguinte forma.
switch (X)
{
// se x estiver aqui dentro executa valor de X
}
else // se não
{
// executa o que estiver aqui dentro.
}
Pois bem, o que eu coloquei À cima é aceito pelo C ?
e esta certa a forma que eu raciocinei.?
case 0x82: //é um case complementar de uma estrutura
Ep = (SetUpPacket.wIndex & 0x8F);
switch (SetUpPacket.bRequest){
case USB_GET_STATUS: // com Ep1
switch (Ep){
case USB_EP00_OUT : BuffEP0IN[0] = bit(...._BSTALL);break;
case USB_EP00_IN : BuffEP0IN[0] = bit(..._BSTALL);break;
case USB_EP01_OUT : BuffEP0IN[0] = bit(..._BSTALL);break;
case USB_EP01_IN : BuffEP0IN[0] = bit(..._BSTALL);break;
}
BuffEP0IN[1] = 0;
BDEP0INCnt = 2;
BDEP0INStat = 0xC8; // data 1 packet, sets UOWN bit: go
break;
case USB_SYNCH_FRAME: ; // comp Ep 2
break;
defalt: // não bateu com nada à cima então...
switch ((SetUpPacket.bmRequestType & 0x60) >> 5){
0: ; break;
1: ClassSpecificRequest; break;
2: ; break;
}
}
break;
case 0x82: //é um case complementar de uma estrutura
Ep = (SetUpPacket.wIndex & 0x8F);
switch (SetUpPacket.bRequest) {
case USB_GET_STATUS:
switch (Ep) {
case USB_EP00_OUT:
BuffEP0IN[0] = bit(BDEP0OUTStat & USB_BSTALL);
break;
case USB_EP00_IN:
BuffEP0IN[0] = bit(BDEP0INStat & USB_BSTALL);
break;
case USB_EP01_OUT:
BuffEP0IN[0] = bit(BDEP1OUTStat & USB_BSTALL);
break;
case USB_EP01_IN:
BuffEP0IN[0] = bit(BDEP1INStat & USB_BSTALL);
break;
}
BuffEP0IN[1] = 0;
BDEP0INCnt = 2;
BDEP0INStat = 0xC8; // data 1 packet, sets UOWN bit: go
break;
case USB_SYNCH_FRAME:;
break;
defalt:
switch ((SetUpPacket.bmRequestType & 0x60) >> 5) {
case 0:
ClassSpecificRequest0();
break;
case 1:
ClassSpecificRequest1();
break;
case 2:
ClassSpecificRequest2();
break;
}
}
break;
Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante