muratmert4
Usta Üye
Programınız nedir. Kodlarınıza bir bakalım.
#include <18F4550.h>
#device ADC=10
#fuses HSPLL,USBDIV,PLL2,PUT,CPUDIV1,VREGEN,NOWDT,NOPROTECT,NOLVP,NODEBUG,NOMCLR
#use delay(clock=48000000)
//#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL2,CPUDIV1,VREGEN,NOBROWNOUT // 8MHZ
//#use delay(clock=48000000)
#define USB_HID_DEVICE TRUE
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //Uçnokta1'de Kesme transferi aktif
#define USB_EP1_RX_ENABLE USB_ENABLE_INTERRUPT
#define USB_EP1_TX_SIZE 64 //Uçnokta1 için maksimum alınacak ve gonderilecek
#define USB_EP1_RX_SIZE 64 //veri boyutu (64 byte)
#include <pic18_usb.h>
#include <USB_Konfigurasyon.h> //USB konfigurasyon bilgileri bu dosyadadır.
#include <usb.c>
//////////////
#use fast_io(c)
/////////////
//#define low output_low(PIN_C1)
//#define high output_high(PIN_C2)
#define UcNokta1 1
#define servono paket[0]
#define hata paket[1]
#define port_durum paket[2]
#define sure paket[3]
/////////////
unsigned int8 paket[64];
int8 giden_paket[32];
//int8 x,y,z;
void sola();
void dur();
void sagadon();
void main(void)
{ setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_ccp1(CCP_OFF);
setup_vref(FALSE);
setup_CCP1(CCP_OFF);
setup_CCP2(CCP_OFF);
set_tris_c(0x00011000);
output_c(0b00000011);
usb_init();
usb_task();
usb_wait_for_enumeration(); //Cihaz, hazır olana kadar bekle
if(usb_enumerated())
output_high(pin_d0);
for (;;)
{
while(usb_enumerated())
{
if (usb_kbhit(1)) //Eğer pc'den yeni bir paket geldiyse
{
usb_get_packet(UcNokta1, paket, 64); //paketi oku
// SERVO MOTORU SAG-SOL-ORTA HAKARET ETTIRIYORUZ
switch(sure) // Paketin ilk elemanındaki komutu oku ve ilgili göreve git
{
case 'A':
// sola();
output_low(PIN_C1);
output_high(PIN_C2);
delay_us(500);
usb_put_packet(1, giden_paket, 64, USB_DTS_TOGGLE);
break;
case 'B':
// sagadon();
output_high(PIN_C1);
output_low(PIN_C2);
delay_us(500);
usb_put_packet(1, giden_paket, 64, USB_DTS_TOGGLE);
break;
case 'C':
// dur();
output_high(PIN_C1);
output_high(PIN_C2);
delay_us(500);
usb_put_packet(1, giden_paket, 64, USB_DTS_TOGGLE);
break;
//////////////////////////////////////////
}}}}}
const char USB_DEVICE_DESC[USB_DESC_DEVICE_LEN] ={
//starts of with device configuration. only one possible
USB_DESC_DEVICE_LEN, //the length of this report ==1
0x01, //the constant DEVICE (DEVICE 0x01) ==2
0x00,0x02, //usb version in bcd
0x00, //class code ==5
0x00, //subclass code ==6
0x00, //protocol code ==7
USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8
0x11,0x11, //vendor id
0x11,0x11, //product id
0x00,0x01, //device release number ==13,14
0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below) ==15
0x02, //index of string descriptor of the product ==16
0x00, //index of string descriptor of serial number ==17
USB_NUM_CONFIGURATIONS //number of possible configurations ==18
};
this.usbHidPort1.ProductId = Int32.Parse("1111", System.Globalization.NumberStyles.HexNumber);
this.usbHidPort1.VendorId = Int32.Parse("1111", System.Globalization.NumberStyles.HexNumber);
usbHidPort1.CheckDevicePresent();