![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
nader
Joined: 29 Aug 2004 Posts: 12
|
pdiusbd12 |
Posted: Mon Sep 06, 2004 10:39 am |
|
|
i try to handle pdiusbd12 with pic . i have a little problem on it.
if any want to see my code easily meil me 7 then i will send the code.
if any one have an information that think is good for this please tell me.
thanks. |
|
![](templates/subSilver/images/spacer.gif) |
Markus
Joined: 30 Oct 2003 Posts: 13
|
|
Posted: Mon Sep 06, 2004 1:58 pm |
|
|
nader, why don't you post your code on the forum?
You may also want to take a look at www.beyondlogic.org (as I suggested in your other thread) and at John Hyde's examples from his book "USB Design by Example". Here you can find sample codes for Philips' D11 and D12: http://www.intel.com/intelpress/usb/examples/download.htm
Markus
PS: What exactly are the problems you are experiencing? |
|
![](templates/subSilver/images/spacer.gif) |
nader
Joined: 29 Aug 2004 Posts: 12
|
d12 |
Posted: Tue Sep 07, 2004 1:25 am |
|
|
hi,thanks for interest.
do exactly what beyond logic siad.
at power up i have one bus reset intrrupt & one suspend change intrrupt & a lot of ENDP0 out intrrupt.
but when i read last transaction status register for this endpoint(endp0out) it is not a setup packet so
i can't begin the enumeration & windows after about 17 secend show " USB Device Not Recognized".
during this time i have tree pulses of good link led.(good link led is turn on & off tree time)
i also see philips site but nothing for help.if you know someone in philips that can help me please give me his or her email.
i really need some one suggestion or help.
i need a flow chart for when the d12 power up.i don't have problem with
the protocol.
i try to send my code to forums but its alittle large.
please see my code & help me
thanks a lot. |
|
![](templates/subSilver/images/spacer.gif) |
nader
Joined: 29 Aug 2004 Posts: 12
|
code |
Posted: Tue Sep 07, 2004 1:32 am |
|
|
void usb_init(void)
{
set_tris_usb_data(0x00); // make it out put
set_tris_usb_control(0x07); //deafult
D12_CS_N = 1; //deactive d12cs
D12_A0 = 0;
D12_WR_N = 1;
D12_RD_N = 1;
D12_RST_N = 1; //reset d12
}
//------------------------------------------------------------------//
void D12_Cmd(unsigned int8 Command)
{
D12_Data = Command;
D12_A0 = 1; //edge up
D12_WR_N = 0;
D12_CS_N = 0; //active d12cs
D12_WR_N = 1;
D12_A0 = 0; //edge dowm
D12_CS_N = 1; //off
delay_cycles(5); //500ns delay for next command
}
//------------------------------------------------------------------//
void D12_Data_Write(unsigned int8 Data)
{
D12_DATA = Data;
D12_WR_N = 0;
D12_CS_N = 0; //active d12cs
D12_WR_N = 1;
D12_CS_N = 1; //off
delay_cycles(5); //500ns delay for next command
}
//-----------------------------------------------------------------//
unsigned int8 D12_Data_Read(void)
{
unsigned int8 data;
set_tris_usb_data(0xFF); //make it input
D12_RD_N = 0;
D12_CS_N = 0; //active d12cs
data = D12_DATA; //get data
D12_RD_N = 1;
D12_CS_N = 1; //deactive d12cs
set_tris_usb_data(0xFF); //make it out put
delay_cycles(5);
return(data);
}
//----------------------------------------------------------------//
void D12_Cmd_write(unsigned char command,unsigned char *buffer,unsigned char count)
{
unsigned char i = 0;
d12_cmd(command);
while(count)
{
d12_data_write(*(buffer+i));
count--;
i++;
}
}
//----------------------------------------------------------------//
void D12_Cmd_read(unsigned char command,unsigned char *buffer,unsigned char count)
{
unsigned char i = 0;
d12_cmd(command);
while(count)
{
*(buffer+i) = d12_data_read();
count--;
i++;
}
}
//-----------------------------------------------------------------//
void usb_reconnect(void)
{
unsigned char buff[2];
//set mode disconnect
buff[0] = D12_NOLAZYCLOCK;
buff[1] = D12_SETTOONE|D12_CLOCK_4M;
D12_Cmd_write(D12_SET_MODE,buff,2);
//delay_ms(1000);
//set dma
buff[0] = 0xc0;
D12_Cmd_write(D12_SET_DMA,buff,1);
//set mode connect
buff[0] = 0x16; //soft connect
buff[1] = D12_SETTOONE|D12_CLOCK_4M;
D12_Cmd_write(D12_SET_MODE,buff,2);
}
//----------------------------------------------------------------//
void ErrorStallControlEndPoint(void)
{
unsigned char Buffer[] = { 0x01 };
D12_Cmd_write(D12_SET_ENDPOINT_STATUS + D12_ENDPOINT_EP0_IN, Buffer, 1);
D12_Cmd_write(D12_SET_ENDPOINT_STATUS + D12_ENDPOINT_EP0_OUT, Buffer, 1);
}
//----------------------------------------------------------------//
unsigned char D12ReadEndpoint(unsigned char Endpoint,unsigned char *Buffer)
{
unsigned char D12Header[2];
unsigned char BufferStatus = 0;
/* Select Endpoint */
D12_Cmd_read(Endpoint, &BufferStatus, 1);
/* Check if Buffer is Full */
if(BufferStatus & 0x01)
{
D12_Cmd_read(D12_READ_BUFFER, D12Header, 2);
if(D12Header[1]) /* Have some thing for read? */
D12_Cmd_read(D12_READ_BUFFER, Buffer, D12Header[1]);
/* Allow new packets to be accepted */
D12_Cmd_write(D12_CLEAR_BUFFER, NULL, 0);
}
return D12Header[1]; /* return the length of data read */
}
//----------------------------------------------------------------//
void D12WriteEndpoint(unsigned char Endpoint,unsigned char *Buffer,unsigned char Bytes)
{
unsigned char D12Header[2];
unsigned char BufferStatus = 0;
D12Header[0] = 0x00;
D12Header[1] = Bytes;
/* Select Endpoint */
D12_Cmd_read(Endpoint, &BufferStatus, 1);
/* Write Header */
D12_Cmd_write(D12_WRITE_BUFFER, D12Header, 2);
/* Write Packet */
if(Bytes)
D12_Cmd_write(D12_WRITE_BUFFER, Buffer, Bytes);
/* Validate Buffer */
D12_Cmd_write(D12_VALIDATE_BUFFER, NULL, 0);
}
//----------------------------------------------------------------//
void WriteBufferToEndPoint(void) //-for control endpoint send descriptor-//
{
if (BytesToSend == 0)
{
/* If BytesToSend is Zero and we get called again, assume buffer is smaller */
/* than Setup Request Size and indicate end by sending Zero Lenght packet */
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, NULL, 0);
}
else if (BytesToSend >= ENP0_BUFFER_SIZE)
{
/* Write another 8/16 Bytes to buffer and send */
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, pSendBuffer, ENP0_BUFFER_SIZE);
pSendBuffer += ENP0_BUFFER_SIZE;
BytesToSend -= ENP0_BUFFER_SIZE;
} else {
/* Buffer must have less than 8/16 bytes left */
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, pSendBuffer, BytesToSend);
BytesToSend = 0;
}
}
//----------------------------------------------------------------//
void loadfromcircularbuffer(void)
{
unsigned char Buffer[2+ENP1_BUFFER_SIZE];
unsigned char count;
// Read Buffer Full Status
D12_Cmd_read(D12_ENDPOINT_EP1_IN, Buffer, 1);
if(Buffer[0] == 0)
{
// Buffer Empty
if(inpointer != outpointer)
{
// We have bytes to send
count = 0;
do {
Buffer[count++] = circularbuffer[outpointer++];
if(outpointer >= MAX_BUFFER_SIZE) outpointer = 0;
if(outpointer == inpointer) break; // No more data
} while (count < ENP1_BUFFER_SIZE); // Maximum Buffer Size
// Now load it into EP1_In
D12WriteEndpoint(D12_ENDPOINT_EP1_IN, Buffer, count);
}
}
}
//--------------------------------------------------------------------//
void GetDescriptor(PUSB_SETUP_REQUEST SetupPacket)
{
switch((SetupPacket->wValue & 0xFF00) >> 8)
{
case TYPE_DEVICE_DESCRIPTOR:
pSendBuffer = (unsigned char *)&DeviceDescriptor;
BytesToSend = DeviceDescriptor.bLength;
if (BytesToSend > SetupPacket->wLength)
BytesToSend = SetupPacket->wLength;
WriteBufferToEndPoint();
break;
case TYPE_CONFIGURATION_DESCRIPTOR:
pSendBuffer = (unsigned char *)&ConfigurationDescriptor;
BytesToSend = sizeof(ConfigurationDescriptor);
if (BytesToSend > SetupPacket->wLength)
BytesToSend = SetupPacket->wLength;
WriteBufferToEndPoint();
break;
case TYPE_STRING_DESCRIPTOR:
switch (SetupPacket->wValue & 0xFF)
{
case 0 : pSendBuffer = (unsigned char *)&LANGID_Descriptor;
BytesToSend = sizeof(LANGID_Descriptor);
break;
case 1 : pSendBuffer = (unsigned char *)&Manufacturer_Descriptor;
BytesToSend = sizeof(Manufacturer_Descriptor);
break;
default : pSendBuffer = NULL;
BytesToSend = 0;
}
if(BytesToSend > SetupPacket->wLength)
BytesToSend = SetupPacket->wLength;
WriteBufferToEndPoint();
break;
default:
ErrorStallControlEndPoint();
break;
}
}
//--------------------------------------------------------------------//
void Process_EP0_OUT_Interrupt(void)
{
unsigned char Buffer[2];
USB_SETUP_REQUEST SetupPacket;
/* Check if packet received is Setup or Data - Also clears IRQ */
D12_Cmd_read(D12_READ_LAST_TRANSACTION + D12_ENDPOINT_EP0_OUT, (unsigned char *)&SetupPacket, 1);
// for debug
enp0++;
lcd_command(0x8B);
printf(lcd_write,"P0:%x",enp0);
//
IF(SetupPacket.bmRequestType & D12_LAST_TRAN_SETUP)
{
// for debug
lcd_command(0x8B);
printf(lcd_write,"welcome");
//
/* This is a setup Packet - Read Packet */
D12ReadEndpoint(D12_ENDPOINT_EP0_OUT, (char *)&SetupPacket);
/* Acknowlegde Setup Packet to EP0_OUT & Clear Buffer*/
D12_Cmd_write(D12_ACK_SETUP, NULL, 0);
D12_Cmd_write(D12_CLEAR_BUFFER, NULL, 0);
/* Acknowlegde Setup Packet to EP0_IN */
D12_Cmd_write(D12_ENDPOINT_EP0_IN, NULL, 0);
D12_Cmd_write(D12_ACK_SETUP, NULL, 0);
/* Parse bmRequestType */
switch (SetupPacket.bmRequestType & 0x7F) {
case STANDARD_DEVICE_REQUEST:
switch (SetupPacket.bRequest)
{
case GET_STATUS:
/* Get Status Request to Device should return */
/* Remote Wakeup and Self Powered Status */
Buffer[0] = 0x01;
Buffer[1] = 0x00;
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, Buffer, 2);
break;
case CLEAR_FEATURE:
case SET_FEATURE:
/* We don't support DEVICE_REMOTE_WAKEUP or TEST_MODE */
ErrorStallControlEndPoint();
break;
case SET_ADDRESS:
DeviceAddress = SetupPacket.wValue | 0x80;
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, NULL, 0);
CtlTransferInProgress = PROGRESS_ADDRESS;
break;
case GET_DESCRIPTOR:
GetDescriptor(&SetupPacket);
break;
case GET_CONFIGURATION:
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, &DeviceConfigured, 1);
break;
case SET_CONFIGURATION:
DeviceConfigured = SetupPacket.wValue & 0xFF;
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, NULL, 0);
if(DeviceConfigured)
LCD.RC0 = 1; /* turn on configure Led */
else
LCD.RC0 = 1; /* Device Not Configured */
break;
case SET_DESCRIPTOR:
default:
/* Unsupported - Request Error - Stall */
ErrorStallControlEndPoint();
break;
}
break;
case STANDARD_INTERFACE_REQUEST:
switch (SetupPacket.bRequest)
{
case GET_STATUS:
/* Get Status Request to Interface should return */
/* Zero, Zero (Reserved for future use) */
Buffer[0] = 0x00;
Buffer[1] = 0x00;
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, Buffer, 2);
break;
case SET_INTERFACE:
/* Device Only supports default setting, Stall may be */
/* returned in the status stage of the request */
if(SetupPacket.wIndex == 0 && SetupPacket.wValue == 0)
/* Interface Zero, Alternative Setting = 0 */
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, NULL, 0);
else
ErrorStallControlEndPoint();
break;
case GET_INTERFACE:
if(SetupPacket.wIndex == 0)
{ /* Interface Zero */
Buffer[0] = 0; /* Alternative Setting */
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, Buffer, 1);
break;
} /* else fall through as RequestError */
//case CLEAR_FEATURE:
//case SET_FEATURE:
/* Interface has no defined features. Return RequestError */
default:
ErrorStallControlEndPoint();
break;
}
break;
case STANDARD_ENDPOINT_REQUEST:
switch (SetupPacket.bRequest)
{
case CLEAR_FEATURE:
case SET_FEATURE:
/* Halt(Stall) feature required to be implemented on all Interrupt and */
/* Bulk Endpoints. It is not required nor recommended on the Default Pipe */
if(SetupPacket.wValue == ENDPOINT_HALT)
{
if(SetupPacket.bRequest == CLEAR_FEATURE)
Buffer[0] = 0x00;
else
Buffer[0] = 0x01;
switch (SetupPacket.wIndex & 0xFF)
{
case 0x01 : D12_Cmd_write(D12_SET_ENDPOINT_STATUS + \
D12_ENDPOINT_EP1_OUT, Buffer, 1);
break;
case 0x81 : D12_Cmd_write(D12_SET_ENDPOINT_STATUS + \
D12_ENDPOINT_EP1_IN, Buffer, 1);
break;
case 0x02 : D12_Cmd_write(D12_SET_ENDPOINT_STATUS + \
D12_ENDPOINT_EP2_OUT, Buffer, 1);
break;
case 0x82 : D12_Cmd_write(D12_SET_ENDPOINT_STATUS + \
D12_ENDPOINT_EP2_IN, Buffer, 1);
break;
default : /* Invalid Endpoint - RequestError */
ErrorStallControlEndPoint();
break;
}
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, NULL, 0); /* zero packet */
}
else
{
/* No other Features for Endpoint - Request Error */
ErrorStallControlEndPoint();
}
break;
case GET_STATUS:
/* Get Status Request to Endpoint should return */
/* Halt Status in D0 for Interrupt and Bulk */
switch (SetupPacket.wIndex & 0xFF)
{
case 0x01 : D12_Cmd_read(D12_READ_ENDPOINT_STATUS + \
D12_ENDPOINT_EP1_OUT, Buffer, 1);
break;
case 0x81 : D12_Cmd_read(D12_READ_ENDPOINT_STATUS + \
D12_ENDPOINT_EP1_IN, Buffer, 1);
break;
case 0x02 : D12_Cmd_read(D12_READ_ENDPOINT_STATUS + \
D12_ENDPOINT_EP2_OUT, Buffer, 1);
break;
case 0x82 : D12_Cmd_read(D12_READ_ENDPOINT_STATUS + \
D12_ENDPOINT_EP2_IN, Buffer, 1);
break;
default : /* Invalid Endpoint - RequestError */
ErrorStallControlEndPoint();
break;
}
if(Buffer[0] & 0x80)
Buffer[0] = 0x01;
else
Buffer[0] = 0x00;
Buffer[1] = 0x00;
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, Buffer, 2);
break;
default:
/* Unsupported - Request Error for Endpoint- Stall */
ErrorStallControlEndPoint();
break;
}
break;
case VENDOR_DEVICE_REQUEST:
case VENDOR_ENDPOINT_REQUEST:
switch (SetupPacket.bRequest)
{
case VENDOR_GET_ANALOG_VALUE:
set_adc_channel((SetupPacket.wIndex & 0x07));
delay_us(10);
ADGO = 1;
while(ADGO);
Buffer[0] = ADRESL;
Buffer[1] = ADRESH;
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, Buffer, 2);
break;
case VENDOR_SET_RB_HIGH_NIBBLE:
lcd_command(0xD4);
printf(lcd_write,"vender:%u",(SetupPacket.wIndex >> 4) );
/* zero length packet */
D12WriteEndpoint(D12_ENDPOINT_EP0_IN, NULL, 0);
break;
default:
ErrorStallControlEndPoint();
break;
}
break;
default:
ErrorStallControlEndPoint();
break;
}
}
else
{
///* This is a Data Packet */
}
}
#include "E:\ccs\pd12 cypress\TEST.h"
#include "USB_d12_defines.c"
#include "USB_variables.c"
#include "USB_18f452_defines.c"
#include "lcd_18F452.c"
//--------------------public variable-----------------------------//
unsigned int8 c = 0,b = 0,s = 0;
unsigned int8 enp0 = 0,enp1 = 0;
unsigned char circularbuffer[MAX_BUFFER_SIZE];
unsigned char inpointer;
unsigned char outpointer;
unsigned char * pSendBuffer;
unsigned char BytesToSend;
unsigned char CtlTransferInProgress;
unsigned char DeviceAddress;
unsigned char DeviceConfigured;
//---------------------define the usb descriptors-----------------//
USB_DEVICE_DESCRIPTOR DeviceDescriptor = {
sizeof(USB_DEVICE_DESCRIPTOR), /* bLength */
TYPE_DEVICE_DESCRIPTOR, /* bDescriptorType */
0x0110, /* bcdUSB USB Version 1.1 */
0, /* bDeviceClass */
0, /* bDeviceSubclass */
0, /* bDeviceProtocol */
ENP0_BUFFER_SIZE, /* bMaxPacketSize 8/16 Bytes */
0x04B4, /* USB Thermometer Example */
0x0002,
0x0000, /* bcdDevice */
1, /* iManufacturer String Index */
0, /* iProduct String Index */
0, /* iSerialNumber String Index */
1 /* bNumberConfigurations */
};
USB_CONFIG_DATA ConfigurationDescriptor = {
{ /* configuration descriptor */
sizeof(USB_CONFIGURATION_DESCRIPTOR),/* bLength */
TYPE_CONFIGURATION_DESCRIPTOR, /* bDescriptorType */
sizeof(USB_CONFIG_DATA), /* wTotalLength */
1, /* bNumInterfaces */
1, /* bConfigurationValue */
0, /* iConfiguration String Index */
0x80, /* bmAttributes Bus Powered,
No Remote Wakeup */
0x32 /* bMaxPower, 100mA */
},
{ /* interface descriptor */
sizeof(USB_INTERFACE_DESCRIPTOR), /* bLength */
TYPE_INTERFACE_DESCRIPTOR, /* bDescriptorType */
0, /* bInterface Number */
0, /* bAlternateSetting */
2, /* bNumEndpoints */
0xFF, /* bInterfaceClass (Vendor specific) */
0xFF, /* bInterfaceSubClass */
0xFF, /* bInterfaceProtocol */
0 /* iInterface String Index */
},
{ /* endpoint descriptor */
sizeof(USB_ENDPOINT_DESCRIPTOR), /* bLength */
TYPE_ENDPOINT_DESCRIPTOR, /* bDescriptorType */
0x01, /* bEndpoint Address EP1 OUT */
0x02, /* bmAttributes - Interrupt */
0x0008, /* wMaxPacketSize */
0x00 /* bInterval */
},
{ /* endpoint descriptor */
sizeof(USB_ENDPOINT_DESCRIPTOR), /* bLength */
TYPE_ENDPOINT_DESCRIPTOR, /* bDescriptorType */
0x81, /* bEndpoint Address EP1 IN */
0x02, /* bmAttributes - Interrupt */
0x0008, /* wMaxPacketSize */
0x00 /* bInterval */
}
};
/* LANGID String Descriptor Zero */
USB_LANGID_DESCRIPTOR LANGID_Descriptor = {
sizeof(USB_LANGID_DESCRIPTOR), /* bLength */
TYPE_STRING_DESCRIPTOR, /* bDescriptorType */
0x0409 /* LANGID US English */
};
/* ManufacturerString 1 */
USB_MANUFACTURER_DESCRIPTOR Manufacturer_Descriptor = {
sizeof(USB_MANUFACTURER_DESCRIPTOR),/* bLenght */
TYPE_STRING_DESCRIPTOR, /* bDescriptorType */
"B0e0y0o0n0d0 0L0o0g0i0c" /* ManufacturerString in UNICODE */
};
//----------------------------------------------------------------//
#include "USB_d12_functions.c"
//----------------------------------------------------------------//
void Usb_int_isr(void)
{
unsigned char IRQ[2],temp[2];
unsigned char Buffer[ENP1_BUFFER_SIZE];
unsigned char count;
unsigned char bytes;
/* Read Interrupt Register to determine source of interrupt */
D12_Cmd_read(D12_READ_INTERRUPT_REGISTER,Irq,2);
lcd_command(0x80);
/* Find the source of intrrupt */
IF(Irq != 0)
{
/* busreset */
if(IRQ[0] & D12_INT_BUSRESET)
{ // for debug
b++;
lcd_command(0x80);
printf(lcd_write,"B:%3u",b);
D12_SUSPEND = 1;
//
temp[0] = 0x80;
D12_Cmd_write(D12_SET_ADDRESS_ENABLE,temp,1);
temp[0] = 1;
D12_Cmd_write(D12_SET_ENDPOINT_ENABLE,temp,1);
}
/* suspend change */
if(IRQ[0] & D12_INT_SUSPENDCHANGE)
{ // for debug
s++;
lcd_command(0x86);
printf(lcd_write,"S:%3u",s);
//
}
/* endpoint 0 out */
if(IRQ[0] & D12_INT_ENDP0OUT)
{
Process_EP0_OUT_Interrupt();
}
/* endpoint 0 in */
if(IRQ[0] & D12_INT_ENDP0IN)
{ // for debug
enp1++;
lcd_command(0xC0);
printf(lcd_write,"P1:%3u",enp1);
//
if(CtlTransferInProgress == PROGRESS_ADDRESS)
{
D12_Cmd_write(D12_SET_ADDRESS_ENABLE,&DeviceAddress,1);
D12_Cmd_read(D12_READ_LAST_TRANSACTION + D12_ENDPOINT_EP0_IN, Buffer, 1);
CtlTransferInProgress = PROGRESS_IDLE;
}
else
{
D12_Cmd_read(D12_READ_LAST_TRANSACTION + D12_ENDPOINT_EP0_IN, Buffer, 1);
WriteBufferToEndPoint();
}
}
/* endpoint 1 out */
if(IRQ[0] & D12_INT_ENDP1OUT)
{
D12_Cmd_read(D12_READ_LAST_TRANSACTION + D12_ENDPOINT_EP1_OUT, Buffer, 1);
bytes = D12ReadEndpoint(D12_ENDPOINT_EP1_OUT, Buffer);
for(count = 0; count < bytes; count++)
{
circularbuffer[inpointer++] = Buffer[count];
if(inpointer >= MAX_BUFFER_SIZE)
inpointer = 0;
}
loadfromcircularbuffer(); //Kick Start
}
/* endpoint 1 in */
if(IRQ[0] & D12_INT_ENDP1IN)
{
D12_Cmd_read(D12_READ_LAST_TRANSACTION + D12_ENDPOINT_EP1_IN, Buffer, 1);
loadfromcircularbuffer();
}
/* endpoint 2 out */
if(IRQ[0] & D12_INT_ENDP2OUT)
{ /* clear the intrrupt flag */
D12_Cmd_read(D12_READ_LAST_TRANSACTION + D12_ENDPOINT_EP2_OUT, Buffer, 1);
Buffer[0] = 0x01; /* Stall Endpoint */
D12_Cmd_write(D12_SET_ENDPOINT_STATUS + D12_ENDPOINT_EP2_OUT, Buffer, 1);
}
/* endpoint 2 in */
if(IRQ[0] & D12_INT_ENDP2IN)
{
D12_Cmd_read(D12_READ_LAST_TRANSACTION + D12_ENDPOINT_EP2_IN, Buffer, 1);
Buffer[0] = 0x01; /* Stall Endpoint */
D12_Cmd_write(D12_SET_ENDPOINT_STATUS + D12_ENDPOINT_EP2_IN, Buffer, 1);
}
}
else
{
c++; /* number of unknown intrrupt*/
lcd_command(0xD4);
printf(lcd_write,"unknown int:%3u",c);
}
}
//-------------------------------------------------------//
void main()
{ unsigned char b[2];
inpointer = 0;
outpointer = 0;
lcd_init();
usb_init();
LCD.RC0 = 0; //turn off configure led//
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
disable_interrupts(GLOBAL);
delay_ms(2);
usb_reconnect();
while(1) //main loop
{
if(!D12_INT_N)
Usb_int_isr();
}
} |
|
![](templates/subSilver/images/spacer.gif) |
Markus
Joined: 30 Oct 2003 Posts: 13
|
Re: d12 |
Posted: Tue Sep 07, 2004 3:50 am |
|
|
Hi nader.
nader wrote: |
i need a flow chart for when the d12 power up.
|
I don't have enough time to get through your entire code, sorry. I developed a 16F876A firmware for the D11 several months ago. But I never used the D12.
But here is a LogFile that I once found very useful to locate my bugs: http://www.devasys.com/PD11x/hidmouse.txt It should work for your D12 as well.
Markus |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|