Ir ao conteúdo
  • Cadastre-se

Problema com Interface USB


Hayden

Posts recomendados

Olá a todos !!

Estou trabalhando em um projeto que utiliso o pic18f4550,

e o Mikroc em c!

Uma Interface usb ja fiz a parte da comunicação usb, funcionou tudo ok

no HID Terminal,mas eu preciso que essa interface seja reconhecida pelo sistemo operacional [xp,seven] como um teclado usb de pc !

O funcionamento e bem simples, tipo asim, tem 13 teclas e cada tecla

responde a uma letra do teclado!

Alguem poderia me dizer como eu faço esse projeto ser reconhecido

como um teclado usb ??

post-971697-13884962563589_thumb.jpg

Link para o comentário
Compartilhar em outros sites

ok vou postar agora!

ok vou postar agora!

////////////////////////////////////////////////////////////////////////////////
// *****PROJETO INTERFACE USB***** //
// *****Autor:Marcelo Hayden***** //
////////////////////////////////////////////////////////////////////////////////
unsigned char userWR_buffer[64]; //Buffer de transmissão serial
unsigned char userRD_buffer[64]; //Buffer de recepção serial
#define led porta.f0
#define cima portb.f0
#define baixo portb.f1
#define esquerda portb.f2
#define direita portb.f3 // definindo botões de funcão//
#define cancela portb.f4
#define escolhe portb.f5
#define toca portb.f6
#define estatis portb.f7
/////////////////////////////////////////////////////////////////////////////
void main(){
ADCON1=0x0F; //Configura os pinos de forma digital
trisa.ra0=0; // RA0 Como saida
trisb=255; //Configura o pino do botão como entrada
led=0; // led apagado
portb=0; //Todo o Portb em nivel baixo
////////////////////////////////////////////////////////////////////////////////
HID_Enable(&userRD_buffer, &userWR_buffer); //Inicializa a USB
////////////////////////////////////////////////////////////////////////////////
while (1){
////////////////////////////////////////////////////////////////////////////////
if (cima==0){
userWR_buffer[0]='Q'; //Carrega byte a ser enviado para o PC
while (!HID_Write(&userWR_buffer, 64)) ;} //Envia o byte

if (baixo==0){
userWR_buffer[0]='W'; //Carrega byte a ser enviado para o PC
while (!HID_Write(&userWR_buffer, 64)) ;} //Envia o byte

if (esquerda==0){
userWR_buffer[0]='E'; //Carrega byte a ser enviado para o PC
while (!HID_Write(&userWR_buffer, 64)) ;} //Envia o byte

if (direita==0){
userWR_buffer[0]='R'; //Carrega byte a ser enviado para o PC
while (!HID_Write(&userWR_buffer, 64)) ;} //Envia o byte
////////////////////////////////////////////////////////////////////////////////
led=1; //acende led de status
Delay_ms(500); //Delay para atualização
led=0; //apaga led de status
}
}
void interrupt(void)
{
HID_InterruptProc(); //Tratamento da interrupção de USB
}

Link para o comentário
Compartilhar em outros sites

Não pode ser outro compilador?

Eu usei o MikroC poucas vezes em 2008,para saber se minha interface USB estava funcionando em FullSpeed,pois o código exemplo funcionava.

Dei uma vasculhada para alterar os descritores para keybord,mas achei mais difícil fazer compilar no Mikroc que programar um Teclado USB em Assembly!

Link para o comentário
Compartilhar em outros sites

Ola vtrx!!

posso me adaptar sim sem problemas!!:D

essa é a parte que consta os descritores mas não faço ideia de como alterar

para que o sistema operacional possa reconhecer minha interface como um teclado usb !

obrigado pela ajuda!

#include "Definit.h"

#include "VARs.h"

//******************************************************************************

// The number of bytes in each report,

// calculated from Report Size and Report Count in the report descriptor

//******************************************************************************

unsigned char const HID_INPUT_REPORT_BYTES = 8;

unsigned char const HID_OUTPUT_REPORT_BYTES = 8;

unsigned char const HID_FEATURE_REPORT_BYTES = 2;

//******************************************************************************

// Byte constants

//******************************************************************************

unsigned char const NUM_ENDPOINTS = 2;

unsigned char const ConfigDescr_wTotalLength = USB_CONFIG_DESCRIPTOR_LEN + USB_INTERF_DESCRIPTOR_LEN + USB_HID_DESCRIPTOR_LEN + (NUM_ENDPOINTS * USB_ENDP_DESCRIPTOR_LEN);

unsigned char const HID_ReportDesc_len = 47;

unsigned char const Low_HID_ReportDesc_len = HID_ReportDesc_len;

unsigned char const High_HID_ReportDesc_len = HID_ReportDesc_len >> 8;

unsigned char const Low_HID_PACKET_SIZE = HID_PACKET_SIZE;

unsigned char const High_HID_PACKET_SIZE = HID_PACKET_SIZE >> 8;

//******************************************************************************

// Descriptor Tables

//******************************************************************************

unsigned char const DescTables[uSB_DEVICE_DESCRIPTOR_ALL_LEN*2] = {

// Device Descriptor

USB_DEVICE_DESCRIPTOR_LEN, 0, // bLength - Length of Device descriptor (always 0x12)

USB_DEVICE_DESCRIPTOR_TYPE, 0, // bDescriptorType - 1 = DEVICE descriptor

0x00, 0, // bcdUSB - USB revision 2.00 (low byte)

0x02, 0, // (high byte)

0x00, 0, // bDeviceClass - Zero means each interface operates independently (class code in the interface descriptor)

0x00, 0, // bDeviceSubClass

0x00, 0, // bDeviceProtocol

EP0_PACKET_SIZE, 0, // bMaxPacketSize0 - maximum size of a data packet for a control transfer over EP0

0x34, 0, // idVendor - Vendor ID (low byte)

0x12, 0, // (high byte)

0x01, 0, // idProduct - Product ID (low byte)

0x00, 0, // (high byte)

0x01, 0, // bcdDevice - ( low byte)

0x00, 0, // (high byte)

0x01, 0, // iManufacturer - String1

0x02, 0, // iProduct - String2

0x00, 0, // iSerialNumber - ( None )

0x01, 0, // bNumConfigurations - 1

// Configuration Descriptor

USB_CONFIG_DESCRIPTOR_LEN, 0, // bLength - Length of Configuration descriptor (always 0x09)

USB_CONFIG_DESCRIPTOR_TYPE, 0, // bDescriptorType - 2 = CONFIGURATION descriptor

ConfigDescr_wTotalLength, 0, // wTotalLength - Total length of this config. descriptor plus the interface and endpoint descriptors that are part of the configuration.

0x00, 0, // ( high byte)

0x01, 0, // bNumInterfaces - Number of interfaces

0x01, 0, // bConfigurationValue - Configuration Value

0x00, 0, // iConfiguration - String Index for this configuration ( None )

0xA0, 0, // bmAttributes - attributes - "Bus powered" and "Remote wakeup"

50, 0, // MaxPower - bus-powered draws 50*2 mA from the bus.

// Interface Descriptor

USB_INTERF_DESCRIPTOR_LEN, 0, // bLength - Length of Interface descriptor (always 0x09)

USB_INTERFACE_DESCRIPTOR_TYPE, 0, // bDescriptorType - 4 = INTERFACE descriptor

0x00, 0, // bInterfaceNumber - Number of interface, 0 based array

0x00, 0, // bAlternateSetting - Alternate setting

NUM_ENDPOINTS, 0, // bNumEndPoints - Number of endpoints used in this interface

0x03, 0, // bInterfaceClass - assigned by the USB

0x00, 0, // bInterfaceSubClass - Not A boot device

0x00, 0, // bInterfaceProtocol - none

0x00, 0, // iInterface - Index to string descriptor that describes this interface ( None )

// HID Descriptor

USB_HID_DESCRIPTOR_LEN, 0, // bLength - Length of HID descriptor (always 0x09)

USB_HID_DESCRIPTOR_TYPE, 0, // bDescriptorType - 0x21 = HID descriptor

0x01, 0, // HID class release number (1.01)

0x01, 0,

0x00, 0, // Localized country code (none)

0x01, 0, // # of HID class descriptor to follow (1)

0x22, 0, // Report descriptor type (HID)

Low_HID_ReportDesc_len, 0,

High_HID_ReportDesc_len, 0,

// EP1_RX Descriptor

USB_ENDP_DESCRIPTOR_LEN, 0, // bLength - length of descriptor (always 0x07)

USB_ENDPOINT_DESCRIPTOR_TYPE, 0, // bDescriptorType - 5 = ENDPOINT descriptor

0x81, 0, // bEndpointAddress - In, EP1

USB_ENDPOINT_TYPE_INTERRUPT, 0, // bmAttributes - Endpoint Type - Interrupt

Low_HID_PACKET_SIZE, 0, // wMaxPacketSize - max packet size - low order byte

High_HID_PACKET_SIZE, 0, // - max packet size - high order byte

1, 0, // bInterval - polling interval (1 ms)

// EP1_TX Descriptor

USB_ENDP_DESCRIPTOR_LEN, 0, // bLength - length of descriptor (always 0x07)

USB_ENDPOINT_DESCRIPTOR_TYPE, 0, // bDescriptorType - 5 = ENDPOINT descriptor

0x01, 0, // bEndpointAddress - Out, EP1

USB_ENDPOINT_TYPE_INTERRUPT, 0, // bmAttributes - Endpoint Type - Interrupt

Low_HID_PACKET_SIZE, 0, // wMaxPacketSize - max packet size - low order byte

High_HID_PACKET_SIZE, 0, // - max packet size - high order byte

1, 0, // bInterval - polling interval (1 ms)

// HID_Report Descriptor

0x06, 0, // USAGE_PAGE (Vendor Defined)

0xA0, 0,

0xFF, 0,

0x09, 0, // USAGE ID (Vendor Usage 1)

0x01, 0,

0xA1, 0, // COLLECTION (Application)

0x01, 0,

// The Input report

0x09, 0, // USAGE ID - Vendor defined

0x03, 0,

0x15, 0, // LOGICAL_MINIMUM (0)

0x00, 0,

0x26, 0, // LOGICAL_MAXIMUM (255)

0x00, 0,

0xFF, 0,

0x75, 0, // REPORT_SIZE (8)

0x08, 0,

0x95, 0, // REPORT_COUNT (2)

HID_INPUT_REPORT_BYTES, 0,

0x81, 0, // INPUT (Data,Var,Abs)

0x02, 0,

// The Output report

0x09, 0, // USAGE ID - Vendor defined

0x04, 0,

0x15, 0, // LOGICAL_MINIMUM (0)

0x00, 0,

0x26, 0, // LOGICAL_MAXIMUM (255)

0x00, 0,

0xFF, 0,

0x75, 0, // REPORT_SIZE (8)

0x08, 0,

0x95, 0, // REPORT_COUNT (2)

HID_OUTPUT_REPORT_BYTES, 0,

0x91, 0, // OUTPUT (Data,Var,Abs)

0x02, 0,

// The Feature report

0x09, 0, // USAGE ID - Vendor defined

0x05, 0,

0x15, 0, // LOGICAL_MINIMUM (0)

0x00, 0,

0x26, 0, // LOGICAL_MAXIMUM (255)

0x00, 0,

0xFF, 0,

0x75, 0, // REPORT_SIZE (8)

0x08, 0,

0x95, 0, // REPORT_COUNT (2)

HID_FEATURE_REPORT_BYTES, 0,

0xB1, 0, // FEATURE (Data,Var,Abs)

0x02, 0,

// End Collection

0xC0, 0 // END_COLLECTION

};

//******************************************************************************

unsigned char const LangIDDescr[8] = {

0x04, 0,

USB_STRING_DESCRIPTOR_TYPE, 0,

0x09, 0, // LangID (0x0409) - Low

0x04, 0 // - High

};

//******************************************************************************

unsigned char const ManufacturerDescr[48] = {

24, 0,

USB_STRING_DESCRIPTOR_TYPE, 0,

'V', 0, 0, 0,

'e', 0, 0, 0,

'n', 0, 0, 0,

'd', 0, 0, 0,

'o', 0, 0, 0,

'r', 0, 0, 0,

'-', 0, 0, 0,

'N', 0, 0, 0,

'a', 0, 0, 0,

'm', 0, 0, 0,

'e', 0, 0, 0

};

//******************************************************************************

unsigned char const ProductDescr[56] = {

28, 0,

USB_STRING_DESCRIPTOR_TYPE, 0,

'i', 0, 0, 0,

'n', 0, 0, 0,

't', 0, 0, 0,

'e', 0, 0, 0,

'r', 0, 0, 0,

'f', 0, 0, 0,

'a', 0, 0, 0,

'c', 0, 0, 0,

'e', 0, 0, 0,

'-', 0, 0, 0,

'u', 0, 0, 0,

's', 0, 0, 0,

'b', 0, 0, 0

};

//******************************************************************************

unsigned char const StrUnknownDescr[4] = {

2, 0,

USB_STRING_DESCRIPTOR_TYPE, 0

};

//******************************************************************************

//******************************************************************************

// Initialization Function

//******************************************************************************

void InitUSBdsc()

{

Byte_tmp_0[0] = NUM_ENDPOINTS;

Byte_tmp_0[0] = ConfigDescr_wTotalLength;

Byte_tmp_0[0] = HID_ReportDesc_len;

Byte_tmp_0[0] = Low_HID_ReportDesc_len;

Byte_tmp_0[0] = High_HID_ReportDesc_len;

Byte_tmp_0[0] = Low_HID_PACKET_SIZE;

Byte_tmp_0[0] = High_HID_PACKET_SIZE;

DescTables;

LangIDDescr;

ManufacturerDescr;

ProductDescr;

StrUnknownDescr;

}

//******************************************************************************

Link para o comentário
Compartilhar em outros sites

Olá vtrx eu passo sim sem problema !!

me passa seu email e eu te mando o projeto completo !!

eu to usando o microc v.8 por que ele tem o definite.h e vars.h

nas versões mais novas não achei esses archivos!

Ola vtrx!

eu mandei nesse email [email protected] o projeto todo e o link para baixar e versão que eu uso ah e vou manda um de onde eu tirei as fontes do projeto e modifiquei pro meu uso abraço !

Tenho outro problema no MikroC.

Minha versão (6.2.1.0) ,não compila este código.

Ou voce me passa o projeto completo ou o Link para pegar a versão que usa.

Ola vtrx eu mandei o projeto no email z80s que consta em seu perfil.

e mandei um link junto pra baixar a versão que eu uso do mikroc

e vou te mando a fonte do projeto horiginal que eu modifiquei !

obrigado !

Link para o comentário
Compartilhar em outros sites

Vou olhar!.

Eu estava terminado um Soft para aprender e brincar com PWM por Software sem usar timer com 8 ou 16 leds(depende dos ports livres).

Estou terminado os códigos do Pic em ASM,C18 e o que o pessoal gosta,CCS.

Mas voltando ao assunto,nuca fui fã do MikroC,só usei para testar minha primeira interface USB,que era em ASM ,e estava comparando o tempo que o Windows demorarva a 'conectar' em FullSpeed no meu ASM.

Aguarde que vou olhar.

Não gosto deste compilador.

Testa o código aí,eu baxei,vacinei ,mas na hora de compilar da um aviso de 'demo limit'.

//******************************************************************************
//
// File Version 1.01
//
//******************************************************************************

#include "Definit.h"
#include "VARs.h"

//******************************************************************************
// The number of bytes in each report,
// calculated from Report Size and Report Count in the report descriptor
//******************************************************************************
unsigned char const HID_INPUT_REPORT_BYTES = 1;
unsigned char const HID_OUTPUT_REPORT_BYTES = 1;

unsigned char const HID_FEATURE_REPORT_BYTES = 2;
//******************************************************************************
// Byte constants
//******************************************************************************
unsigned char const NUM_ENDPOINTS = 2;
unsigned char const ConfigDescr_wTotalLength = USB_CONFIG_DESCRIPTOR_LEN + USB_INTERF_DESCRIPTOR_LEN + USB_HID_DESCRIPTOR_LEN + (NUM_ENDPOINTS * USB_ENDP_DESCRIPTOR_LEN);
unsigned char const HID_ReportDesc_len = 63;

unsigned char const Low_HID_ReportDesc_len = HID_ReportDesc_len;
unsigned char const High_HID_ReportDesc_len = HID_ReportDesc_len >> 8;

unsigned char const Low_HID_PACKET_SIZE = HID_PACKET_SIZE;
unsigned char const High_HID_PACKET_SIZE = HID_PACKET_SIZE >> 8;

// Descriptor Tables

unsigned char const DescTables[] = {

// Device Descriptor
USB_DEVICE_DESCRIPTOR_LEN, 0, // bLength - Length of Device descriptor (always 0x12)
USB_DEVICE_DESCRIPTOR_TYPE, 0, // bDescriptorType - 1 = DEVICE descriptor
0x00, 0, // bcdUSB - USB revision 2.00 (low byte)
0x02, 0, // (high byte)
0x00, 0, // bDeviceClass - Zero means each interface operates independently (class code in the interface descriptor)
0x00, 0, // bDeviceSubClass
0x00, 0, // bDeviceProtocol
EP0_PACKET_SIZE, 0, // bMaxPacketSize0 - maximum size of a data packet for a control transfer over EP0
0x34, 0, // idVendor - Vendor ID (low byte)
0x12, 0, // (high byte)
0x01, 0, // idProduct - Product ID (low byte)
0x00, 0, // (high byte)
0x01, 0, // bcdDevice - ( low byte)
0x00, 0, // (high byte)
0x01, 0, // iManufacturer - String1
0x02, 0, // iProduct - String2
0x00, 0, // iSerialNumber - ( None )
0x01, 0, // bNumConfigurations - 1

// Configuration Descriptor
USB_CONFIG_DESCRIPTOR_LEN, 0, // bLength - Length of Configuration descriptor (always 0x09)
USB_CONFIG_DESCRIPTOR_TYPE, 0, // bDescriptorType - 2 = CONFIGURATION descriptor
ConfigDescr_wTotalLength, 0, // wTotalLength - Total length of this config. descriptor plus the interface and endpoint descriptors that are part of the configuration.
0x00, 0, // ( high byte)
0x01, 0, // bNumInterfaces - Number of interfaces
0x01, 0, // bConfigurationValue - Configuration Value
0x00, 0, // iConfiguration - String Index for this configuration ( None )
0xA0, 0, // bmAttributes - attributes - "Bus powered" and "Remote wakeup"
50, 0, // MaxPower - bus-powered draws 50*2 mA from the bus.

// Interface Descriptor
USB_INTERF_DESCRIPTOR_LEN, 0, // bLength - Length of Interface descriptor (always 0x09)
USB_INTERFACE_DESCRIPTOR_TYPE, 0, // bDescriptorType - 4 = INTERFACE descriptor
0x00, 0, // bInterfaceNumber - Number of interface, 0 based array
0x00, 0, // bAlternateSetting - Alternate setting
NUM_ENDPOINTS, 0, // bNumEndPoints - Number of endpoints used in this interface
0x03, 0, // bInterfaceClass - assigned by the USB
0x00, 0, // bInterfaceSubClass - Not A boot device
0x00, 0, // bInterfaceProtocol - none
0x00, 0, // iInterface - Index to string descriptor that describes this interface ( None )

// HID Descriptor
USB_HID_DESCRIPTOR_LEN, 0, // bLength - Length of HID descriptor (always 0x09)
USB_HID_DESCRIPTOR_TYPE, 0, // bDescriptorType - 0x21 = HID descriptor
0x01, 0, // HID class release number (1.01)
0x01, 0,
0x00, 0, // Localized country code (none)
0x01, 0, // # of HID class descriptor to follow (1)
0x22, 0, // Report descriptor type (HID)
Low_HID_ReportDesc_len, 0,
High_HID_ReportDesc_len, 0,

// EP1_RX Descriptor
USB_ENDP_DESCRIPTOR_LEN, 0, // bLength - length of descriptor (always 0x07)
USB_ENDPOINT_DESCRIPTOR_TYPE, 0, // bDescriptorType - 5 = ENDPOINT descriptor
0x81, 0, // bEndpointAddress - In, EP1
USB_ENDPOINT_TYPE_INTERRUPT, 0, // bmAttributes - Endpoint Type - Interrupt
Low_HID_PACKET_SIZE, 0, // wMaxPacketSize - max packet size - low order byte
High_HID_PACKET_SIZE, 0, // - max packet size - high order byte
1, 0, // bInterval - polling interval (1 ms)

// EP1_TX Descriptor
USB_ENDP_DESCRIPTOR_LEN, 0, // bLength - length of descriptor (always 0x07)
USB_ENDPOINT_DESCRIPTOR_TYPE, 0, // bDescriptorType - 5 = ENDPOINT descriptor
0x01, 0, // bEndpointAddress - Out, EP1
USB_ENDPOINT_TYPE_INTERRUPT, 0, // bmAttributes - Endpoint Type - Interrupt
Low_HID_PACKET_SIZE, 0, // wMaxPacketSize - max packet size - low order byte
High_HID_PACKET_SIZE, 0, // - max packet size - high order byte
1, 0, // bInterval - polling interval (1 ms)
//Keyboard descriptor
0x05, 0,
0x01, 0, // USAGE_PAGE (Generic Desktop)
0x09, 0,
0x06, 0, // USAGE (Keyboard)
0xa1, 0,
0x01, 0, // COLLECTION (Application)
0x05, 0,
0x07, 0, // USAGE_PAGE (Keyboard)
0x19, 0,
0xe0, 0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0,
0xe7, 0, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0,
0x00, 0, // LOGICAL_MINIMUM (0)
0x25, 0,
0x01, 0, // LOGICAL_MAXIMUM (1)
0x75, 0,
0x01, 0, // REPORT_SIZE (1)
0x95, 0,
0x08, 0, // REPORT_COUNT (8)
0x81, 0,
0x02, 0, // INPUT (Data,Var,Abs)
0x95, 0,
0x01, 0, // REPORT_COUNT (1)
0x75, 0,
0x08, 0, // REPORT_SIZE (8)
0x81, 0,
0x03, 0, // INPUT (Cnst,Var,Abs)
0x95, 0,
0x05, 0, // REPORT_COUNT (5)
0x75, 0,
0x01, 0, // REPORT_SIZE (1)
0x05, 0,
0x08, 0, // USAGE_PAGE (LEDs)
0x19, 0,
0x01, 0, // USAGE_MINIMUM (Num Lock)
0x29, 0,
0x05, 0, // USAGE_MAXIMUM (Kana)
0x91, 0,
0x02, 0, // OUTPUT (Data,Var,Abs)
0x95, 0,
0x01, 0, // REPORT_COUNT (1)
0x75, 0,
0x03, 0, // REPORT_SIZE (3)
0x91, 0,
0x03, 0, // OUTPUT (Cnst,Var,Abs)
0x95, 0,
0x06, 0, // REPORT_COUNT (6)
0x75, 0,
0x08, 0, // REPORT_SIZE (8)
0x15, 0,
0x00, 0, // LOGICAL_MINIMUM (0)
0x25, 0,
0x65, 0, // LOGICAL_MAXIMUM (101)
0x05, 0,
0x07, 0, // USAGE_PAGE (Keyboard)
0x19, 0,
0x00, 0, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0,
0x65, 0, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0,
0x00, 0, // INPUT (Data,Ary,Abs)
0xc0, 0, // END_COLLECTION
};
//******************************************************************************
unsigned char const LangIDDescr[8] = {
0x04, 0,
USB_STRING_DESCRIPTOR_TYPE, 0,
0x09, 0, // LangID (0x0409) - Low
0x04, 0 // - High
};
//******************************************************************************
unsigned char const ManufacturerDescr[68] = {
34, 0,
USB_STRING_DESCRIPTOR_TYPE, 0,
'B', 0, 0, 0,
'u', 0, 0, 0,
'c', 0, 0, 0,
'h', 0, 0, 0,
'y', 0, 0, 0,
's', 0, 0, 0,
' ', 0, 0, 0,
'S', 0, 0, 0,
'o', 0, 0, 0,
'l', 0, 0, 0,
'u', 0, 0, 0,
't', 0, 0, 0,
'i', 0, 0, 0,
'o', 0, 0, 0,
'n', 0, 0, 0,
's', 0, 0, 0
};
//******************************************************************************
unsigned char const ProductDescr[100] = {
50, 0,
USB_STRING_DESCRIPTOR_TYPE, 0,
'B', 0, 0, 0,
'u', 0, 0, 0,
'c', 0, 0, 0,
'h', 0, 0, 0,
'y', 0, 0, 0,
's', 0, 0, 0,
' ', 0, 0, 0,
'A', 0, 0, 0,
'r', 0, 0, 0,
'c', 0, 0, 0,
'a', 0, 0, 0,
'd', 0, 0, 0,
'e', 0, 0, 0,
' ', 0, 0, 0,
'C', 0, 0, 0,
'o', 0, 0, 0,
'n', 0, 0, 0,
't', 0, 0, 0,
'r', 0, 0, 0,
'o', 0, 0, 0,
'l', 0, 0, 0,
'l', 0, 0, 0,
'e', 0, 0, 0,
'r', 0, 0, 0
};

unsigned char const StrUnknownDescr[4] = {
2, 0,
USB_STRING_DESCRIPTOR_TYPE, 0
};

//******************************************************************************
// Initialization Function
//******************************************************************************
void InitUSBdsc()
{
Byte_tmp_0[0] = NUM_ENDPOINTS;
Byte_tmp_0[0] = ConfigDescr_wTotalLength;
Byte_tmp_0[0] = HID_ReportDesc_len;
Byte_tmp_0[0] = Low_HID_ReportDesc_len;
Byte_tmp_0[0] = High_HID_ReportDesc_len;
Byte_tmp_0[0] = Low_HID_PACKET_SIZE;
Byte_tmp_0[0] = High_HID_PACKET_SIZE;


DescTables;

LangIDDescr;
ManufacturerDescr;
ProductDescr;
StrUnknownDescr;

}
//******************************************************************************

Altere seu 'USBdsc.c',para o código acima (cole).

Não vou insistir neste compilador.

Se souber programar em C(C18) eu tenho algo pronto.

Link para o comentário
Compartilhar em outros sites

Olá Vtrx!

Funcionou! ele da aquela mensagen de demo limit ae eu tirei um trexo do programa e ele

recomheceu como um teclado!!!!!!:D

muito obrigado pela força!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

agora eu estou com um problema não consigo enviar as letras que eu quero

tipo eu abro o word e mando o programa enviar a letra 'Q' quando eu aperto a chave

pra enviar o cursor começa a desser pro fim da pagina em vez de mostrar o caracter

sem querer explorar voce meu amigo ! e se não for pedir de mais ,voce poderia postar

um pequeno trecho para eu adaptar no meu programa enviando esse caracter 'Q'

agradeço muito a sua ajuda ,foi fundamental no meu projeto obrigado !!!!!

Link para o comentário
Compartilhar em outros sites

Tenho muita coisa 'engavetada',mas nada em MikroC...

Olha,vou dar uma 'forçada' em voce,heheh.

Seu circuito,como um teclado,não envia o caracter que voce colocou no código.

voce tem que enviar o Code Key equivalente,por exemplo;

Para a letra 'q' minúscula,o código Hex é 0x14.

voce enviaria um Byte(unsigned char)com valor 0x14;

Vai ter que ler os códigos;

-> Tabela ASCII/USB -<

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!