USB driver development

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

USB driver development

跳至解决方案
3,486 次查看
nagendramurthy
Contributor II

can I need know the steps to develop USB driver for LPC1837 controller. using CMSIS architecture.  

0 项奖励
回复
1 解答
2,689 次查看
bernhardfink
NXP Employee
NXP Employee

Download LPCOpen for LPCXpresso using the link given in one of my earlier answers and go for the USB examples:

  • usbd_rom_cdc_vcom
  • usbd_rom_cdc_uart
  • usbd_rom_hid_sio
  • usbd_rom_hid_generic

It really depends on what you want/need to do with USB which of these examples is maybe the best starting point.

Regards,

NXP Support Team

在原帖中查看解决方案

0 项奖励
回复
14 回复数
2,689 次查看
bernhardfink
NXP Employee
NXP Employee

Just a small snapshot of links from a Google search. This addresses the PC side of things.

https://msdn.microsoft.com/en-us/library/windows/hardware/hh406260(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/hardware/hh706183(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/hardware/hh706187(v=vs.85).aspx

http://stackoverflow.com/questions/1562891/how-to-implement-a-usb-device-driver-for-windows

For a driver + USB profile on the MCU side I can only refer to the examples implemented in our LPCOpen software package. Take one of these examples and try to derive your own proprietary drive from it.

If you like to make it CMSIS compliant (whatever this means), then you can have a look into the documentation from ARM here:

http://www.keil.com/pack/doc/CMSIS/Driver/html/index.html

The Keil µVision middleware integrates such a driver.

Regards,

NXP Support Team

2,689 次查看
nagendramurthy
Contributor II

thank you bernhard. this was useful. 

can i know whether the LPCopen software package  is available for LPC 1837 or LPC18xx series controllers.  

0 项奖励
回复
2,689 次查看
bernhardfink
NXP Employee
NXP Employee
0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

Hello Bernhard, 

can you please help out to find the steps how a send a packet of data from PC to LPC18xx controller using the USB or can you provide me sample code regrading this. 

0 项奖励
回复
2,689 次查看
bernhardfink
NXP Employee
NXP Employee

"Send a packet of data" is something you can easily do on a UART or SPI, without using any protocol scheme.

For interfaces like USB or Ethernet you need to prepare the ground for sending data, whatever kind of data it is.

For the most easiest data the Virtual COM Port is maybe a good starting point, this opens a transparent channel for serial data, next to this comes the HID profile which also provides easy but low bandwidth capabilities.

Then there are profiles for synchronous data, for example audio, etc etc

So I can again only refer to the implemented examples which show in a basic way these type of things, you only need to identify the point in the code where the data is put into the OUT buffer, then you can position your own data there. What the opposite side, for example a Windows PC, is making out of your data contecnt is another story.

Regards,

NXP Support Team.

0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

Thank You for the detail answer. if can provide the implement example which show in a basic way type of things. this will be great help. 

0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

As you suggest a has following the steps from USB example to develop my code. 

Now i have again facing problems. i'm using CMSIS driver to develop the code. 

following are the header file been used. 

#include "Driver_USBD.h"
#include "rl_usb.h"
#include "usbd_config.h"
#include "usb_def.h"

code is error free.

CCS bit in the USB register (PORTSC1_D) is not getting set. can you tell be how this bit is set. 

in the data sheet it is mention that this bit is read only. 

pastedImage_1.png

0 项奖励
回复
2,689 次查看
bernhardfink
NXP Employee
NXP Employee

The level of information you provide for your setup (hardware, software, compiler etc) is by far not enough (effectively it's near to zero) to give you any hint what you might do wrong.

I can only repeat what I have already said:  take an existing example, run it on a convenient hardware and learn from it.

And by the way:  there is nothing to misunderstand in the CCS bit description of the PORTSC1_D register. This bit is set by when the USB block identified successfully a device attachment.

Regards,

NXP Support Team

0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

Hello Bernhard, 

as you said  information provided by me was less. i have provided you the more information. please take a look and lets me know where is the fault or error. 

0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

Hello Bernhard, 

as you send information was less. i have provided you the more information. please take a look and lets me know where is the fault or error.

Thank you

0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

Hello Bernhard, 

Here are the details about hardware,  software and compiler. 

Hardware: This is a customized board. controller used is LPC1837 from NXP. these has two USB port. USB0 and USB1. we are using only USB0 with B type connector.

pin configuration are

USB0_PPWR - Not used,

USB0_PWR_FAULT- Port 8 pin 0.

USB0_IND0-Port 8 pin 2. 

USB0_IND1- Not used. 

USB0_DM -  connected to signal D+

USB0_DP - connected to signal  D-

USB0_VBUS - connected to signal VCC.

compiler - keil 5 version 

Software: we are using CMSIS driver to develop the code. 

following is my code please take a look at it and inform where i'm  going wrong. 

problems statement : this code is not able to communicate with PC.  this not able to send  or receive data from PC. 

 

 #include <stdint.h>
#include <stdbool.h>
#include "Driver_USBD.h"
#include "USB_LPC18xx.h"
#include "LPC18xx.h"
#include "rl_usb.h"
#include "usbd_config.h"
#include "usb_def.h"

/* The size of the packet buffer. */
#define PACKET_BUFFER_SIZE 4096
#define TRUE 1
#define FALSE 0

/* Application defined LUSB interrupt status
#define LUSB_DATA_PENDING _BIT(0)*/

/* Packet buffer for processing */
static uint8_t g_rxBuff[PACKET_BUFFER_SIZE];
static uint8_t g_txBuff[PACKET_BUFFER_SIZE];

usbd_data_t USB_data;

uint8_t Data_Received;

/*import USB 0 control block declarations*/
extern ARM_DRIVER_USBD Driver_USBD0;

/*declare USBD control block pointers*/
static ARM_DRIVER_USBD *USBDDrv = NULL;

extern usbdRequestStatus USBD_Device0_Endpoint0_SetupPacketReceived (const USB_SETUP_PACKET *setup_packet, uint8_t **buf, int32_t *len);
void USBSignalDeviceEvent(uint32_t u4l_event);
void USBSignalEndpointEvent(uint8_t u4l_ep_addr,uint32_t u4l_event);
extern void USBD_Device0_Initialize (void);

*****************************************************************************/
int main()
{
uint32_t u4l_status;
int32_t u4l_event;
uint8_t *u1l_data ;
uint8_t **u1l_len[64];
uint8_t data[64];
int32_t *len;
uint8_t address;

ARM_USBD_STATE s1l_status;
USBDDrv = &Driver_USBD0;
address =0x32;
u4l_event = 1024;
u1l_data = data;
len = &u4l_event;
/*initialize USB 0 drivers*/
USBDDrv->Initialize(USBSignalDeviceEvent, USBSignalEndpointEvent);

/*power up USB 0 controllers*/
USBDDrv->PowerControl(ARM_POWER_FULL);

/* USBD device connect */
USBDDrv->DeviceConnect();

/*event vbus on and HIGH enable*/
//USBD_SignalDeviceEvent(ARM_USBD_EVENT_VBUS_ON);

/* checking whether the USB is ready to communicate */
s1l_status = USBDDrv->DeviceGetState();

/* USB end point configured for read operation */
USBDDrv->EndpointConfigure(0x01,
ARM_USB_ENDPOINT_CONTROL,1024);

if(s1l_status.active==1)
{
/* USB end point transfer the read data to USB_data which
of STRUCT type USB_data_t*/
USBDDrv->EndpointTransfer(0x01,
(uint8_t *)&USB_data,1024);

}

/* USBD device connect
USBDDrv->DeviceDisconnect();*/

/*power up USB 0 controllers
USBDDrv->PowerControl(ARM_POWER_OFF);*/

/*initialize USB 0 drivers
USBDDrv->Uninitialize();*/
}

/******************************************************************************
* ARM_SignalUnitEvent
* Description: This routine provides the event status of the can controller
*
* Inputs:
* u4l_event uint32_t type of event.
*
* Outputs:
* None
*
* Returns:
* None
*****************************************************************************/
void USBSignalDeviceEvent(uint32_t u4l_event)
{
/* action to be taken when VBUS_ON event occurs */
if((ARM_USBD_EVENT_VBUS_ON == u4l_event))
{
/* do nothing */
}
/* action to be taken when VBUS_OFF event occurs */
if(ARM_USBD_EVENT_VBUS_OFF == u4l_event)
{
/* do nothing */
}
/* action to be taken when HIGH SPEED event occurs */
if(ARM_USBD_EVENT_HIGH_SPEED == u4l_event)
{
/* do nothing */
}
/* action to be taken when RESET event occurs */
if((ARM_USBD_EVENT_RESET == u4l_event))
{
/* do nothing */
}
/* action to be taken when SUSPEND event occurs */
if(ARM_USBD_EVENT_SUSPEND == u4l_event)
{
/* do nothing */
}
/* action to be taken when RESUME event occurs */
if(ARM_USBD_EVENT_RESUME == u4l_event)
{
/* do nothing */
}
}
/*****************************************************************************
* USB_SignalObjectEvent
* Description: This routine provides the object event status of the can
* controller.
*
* Inputs:
* u4l_obj_idx uint32_t event object id.
* u4l_event uint32_t type of event.
*
* Outputs:
* None
*
* Returns:
* None
*****************************************************************************/
void USBSignalEndpointEvent(uint8_t u4l_ep_addr,uint32_t u4l_event)
{

USB_SETUP_PACKET *u1l_setup_packet;
uint8_t u1l_rec_bytes;
uint8_t *u1l_data;
int32_t u1l_len;

/*check if the event object id is 1 and sent event is complete */
if((ARM_USBD_EVENT_SETUP == u4l_event))
{
/* Read setup packet received over Control Endpoint*/
USBDDrv->ReadSetupPacket(u1l_data);
/*set the data received flag to indicate the test as pass*/
Data_Received = TRUE;
}

/*check if the event object id is 0*/
if((ARM_USBD_EVENT_OUT == u4l_event))
{
/*number of bytes recevied */
u1l_rec_bytes=USBDDrv->EndpointTransferGetResult(
0x01);
}
/* check for the event recevice */
if((ARM_USBD_EVENT_IN == u4l_event))
{
/*number of bytes recevied */
USBDDrv->EndpointTransferGetResult(0x01);
}
}

0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

Hello Bernhard, 

I came to know the reason why PC is not recognizing the Device(my hardware board ). This is due to missing of .inf in PC side or due to missing of  driver device  software for this device in PC side.

The controller is LPC1837 which is NXP make.  can you get me the inf file for this controller or device driver software. 

otherwise if you know where can i get the information about this or if you can provide me contact person who deals with this kind of activity. This will be a great pleasure. 

Thanking you 

Regards

Nagendra Murthy M

Intellipredikt Technologies.  

0 项奖励
回复
2,690 次查看
bernhardfink
NXP Employee
NXP Employee

Download LPCOpen for LPCXpresso using the link given in one of my earlier answers and go for the USB examples:

  • usbd_rom_cdc_vcom
  • usbd_rom_cdc_uart
  • usbd_rom_hid_sio
  • usbd_rom_hid_generic

It really depends on what you want/need to do with USB which of these examples is maybe the best starting point.

Regards,

NXP Support Team

0 项奖励
回复
2,689 次查看
nagendramurthy
Contributor II

can i know the steps  how a send a packet of data from PC to LPC18xx controller using the USB. or a sample code. 

can  i know  how to configure the USB, usb class, usb sub class. VID and PID. 

0 项奖励
回复