#include <18F45K50.h>
#device ADC= 10
#fuses NOCPUDIV, PLLEN, PLL3X, HSH, PRIMARY, NOIESO, NOFCMEN
#use delay(crystal = 48000000)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define USB_HID_DEVICE TRUE //Tells the CCS PIC USB firmware to include HID handling code.
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for IN bulk/interrupt transfers
#define USB_EP1_TX_SIZE 64 //Numero de byte de envio (maximo 64 bytes)
#define USB_EP1_RX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for OUT bulk/interrupt transfers
#define USB_EP1_RX_SIZE 64 //Numero de byte de Recepcion (maximo 64 bytes)
#define USB_CONFIG_PID 0001
#define USB_CONFIG_VID 4660
#use FIXED_IO( D_outputs=PIN_D3,PIN_D1 )
#define drksyn PIN_A0
#define gaz PIN_A1
#define led1 PIN_D1
#define led2 PIN_D3
#include <lcd.c>
#include <pic18_usb.h>
#include <USB_Konfigurasyon.h>
#include <One_Wire.c>
#include <usb_desc_hid.h>
#include <usb.c>
unsigned int a;
unsigned int8 gelen_paket[64];
unsigned int8 giden_paket[64];
#INT_EXT
void DRS()
{
output_low(led2);
output_low(led2);
delay_ms(2000);
}
void main()
{
set_tris_a(0x03);
set_tris_d(0x09);
set_tris_b(0xFF);
output_d(0x00);
setup_adc(ADC_CLOCK_DIV_2);
setup_adc_ports(sAN0|sAN1);
enable_interrupts(global);
enable_interrupts(INT_EXT);
usb_init();
usb_task();
usb_wait_for_enumeration();
while(TRUE)
{
while(usb_enumerated())
{
//if (usb_kbhit(1)) //Eğer pc'den yeni bir paket geldiyse
//{
usb_get_packet(1, gelen_paket, 64); //paketi oku
//}
a = read_adc();
output_high(led1);
delay_ms(a);
output_low(led1);
output_high(led2);
delay_ms(a);
output_low(led2);
usb_put_packet(1, giden_paket,64, USB_DTS_TOGGLE);
delay_ms(20);
}
}
}