Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature currently requires accessing the site using the built-in Safari browser.
#include <18F4550.h>
#DEVICE ADC=8
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#define USB_HID_DEVICE FALSE //deshabilitamos el uso de las directivas HID
#define USB_EP1_TX_ENABLE USB_ENABLE_BULK //turn on EP1(EndPoint1) for IN bulk/interrupt transfers
#define USB_EP1_RX_ENABLE USB_ENABLE_BULK //turn on EP1(EndPoint1) for OUT bulk/interrupt transfers
#define USB_EP1_TX_SIZE 2 //size to allocate for the tx endpoint 1 buffer
#define USB_EP1_RX_SIZE 2 //size to allocate for the rx endpoint 1 buffer
#include ".\librerias\pic18_usb.h" //libreria suministrada por picc para el manejo de pic 18fxxx
#include ".\librerias\PicUSB.h" //Configuración del USB y los descriptores para este dispositivo ,ademas la identificacion del dispositivo ( id - vendor)
#include ".\librerias\usb.c" //handles usb setup tokens and get descriptor reportsç
void main(void) {
int8 recibe[2]; //declaramos variables
int8 envia[0];
int8 x,y,i;
int16 dato;
/*set_tris_b(0x00);
//set_tris_d(0x7f);
output_b(0x00);*/
usb_init(); //inicializamos el USB
usb_task(); //habilita periferico usb e interrupciones
usb_wait_for_enumeration(); //esperamos hasta que el PicUSB sea configurado por el host
//es decir esperar hasta que el dispositivo lo reconozca el pc
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
while (TRUE){
if(usb_enumerated()){//si el PicUSB está configurado
if (usb_kbhit(1)){//si el endpoint de salida contiene datos del host
usb_get_packet(1,recibe,1); //cojemos el paquete de tamaño 1bytes del EP1 y almacenamos en recibe
if( recibe [0]=='1'){// si llego un "1" entonces activa el conversor
set_adc_channel(0);
delay_us(4);
dato=read_adc();
delay_us(10);
envia[0]=dato;
usb_put_packet(1,envia,,USB_DTS_TOGGLE); //enviamos el paquete de tamaño 1byte del EP1 al PC**/
}
}
}
}
}