USB Interface Design of Embedded ECG Blood Pressure Monitor

This article focuses on the USB communication protocol and the control method of its interface chip. For clinical needs, it has designed and implemented a miniaturized device with ECG, blood pressure intelligent monitoring and USB high-speed data transmission functions, providing electronic medical record query and printing of ECG and blood pressure data And network transmission and other functions are very important for improving the level of family health care.

Design of USB interface circuit of monitor

The main control chip of the system adopts 32-bit high-performance embedded ARM microprocessor S3C44B0X, and the USB special control chip selects USBN9603. USBN9603 has 7 built-in FIFO ports, including 1 bidirectional control port, 3 transmit ports and 3 receive ports, each with 64 bytes.

The interface circuit of USB controller and S3C44B0X is shown as in Fig. 1. The USB controller is designed as Bank2, that is, the nGCS2 memory select line is used as the chip select line of USBN9603, then the chip select address of the chip is 0x4000000. This article uses a parallel data interface, and the lower 8-bit data lines D0 ~ D7 of the two chips are connected to transmit communication data in parallel. Connect MODE0 and MODE1 pins to ground, configure USBN9603 as non-multiplexed mode, because this working mode requires address line A0 as the selection line for accessing USBN9603 on-chip registers DATA_IN, DATA_OUT and ADDR registers, it needs to be connected to the 32-bit address bus A18 to A0 of the USB controller. When reading and writing the USBN9603, it is divided into two bus cycles: First, set the address line A0 high, that is, set the bus address to 0x4040000, and write the address of the register to be accessed from the data line D [0: 7] , The address is sent to the chip in the first bus cycle; then, in the second cycle, set A0 low, that is, set the bus address to 0x4000000, read and write D [0: 7] can read and write to the register operating. The entire USB communication process is mainly to handle various interrupt events including receiving and sending data, connect the INT pin of USBN9603 to the external interrupt EINT0 pin of S3C44B0X, and set the USB interrupt to the vector interrupt request mode. Since the DMA method is not used, DACK needs to be set high, and the DMA request line DRQ is left floating. The USB cable has 4 wires, D + and D- are USB differential signal lines, and the other two are the 5V power line and the ground line. USBN9603 supports low-speed and full-speed USB communication. Connect a 1.5KΩ pull-up resistor to the D + signal line to make it work in full-speed mode.

Implementation of USB interface firmware of monitor

The operation of the USB communication process starts from the host. A token packet is sent out according to the agreed timing, including information such as operation type, direction, peripheral address and endpoint number, and then the data sender is specified in the token to send out a packet Or indicate that there is no data transmission. The USB peripheral should respond with a confirmation packet, indicating that the transmission was successful.

This article adopts a master-slave USB communication structure. The host computer sends various pre-agreed protocol commands to collect ECG and blood pressure data and initialize the system equipment. It mainly includes the following types of data: ECG data In units of segments, each segment includes 32KB of ECG data and 6B acquisition time information. Several segments are transmitted at a time, which has a large amount of data and high requirements for transmission reliability. Blood pressure data includes diastolic and systolic pressures and their acquisition time. A total of 10B, because blood pressure monitoring is more frequent, each time the blood pressure monitoring data will be transmitted for a period of time, the data volume is also relatively large; download the upgraded version of firmware and other file information. The data flow of these three types of data is relatively large, and the reliability requirements are relatively high. All three types of data use block transmission channel types. In addition, each USB transmission must have a control transmission channel. Therefore, three channels need to be used, namely control channel, BulkIN channel and BulkOUT channel.

USB firmware data structure

This article refers to the four types of descriptors required by the host computer in the control transmission of the USB device configuration enumeration phase, which are: device descriptor, configuration descriptor, interface descriptor and endpoint descriptor, in which the higher order description Character will inform the host of any other low-level descriptor information.

The device descriptor is the first descriptor that the host reads when the device is connected. Each device can only have one device descriptor, which contains the information of the entire device and the configuration number supported by the device. There are 18 fields in total. Each USB device has one or more configuration descriptors, including the device's power management and the interface number supported by the device configuration. When the device receives the request to obtain the configuration descriptor, it transmits the configuration descriptor and all its interfaces and endpoints And other auxiliary descriptors to the host, this article sets up a configuration, the descriptor has a total of 8 fields. The interface contains a set of endpoints. This article sets up an interface, and its descriptor has 9 fields, which provide the host computer with information such as the number and type of endpoints used by the device. Each interface descriptor has zero or more endpoint descriptors, which contain the information required for communication between the host and the endpoint. Endpoint 0 serves as the control endpoint to communicate. Endpoint 1 and endpoint 2 are block transfer modes, and their descriptors contain the endpoint. Information such as number, transmission direction, endpoint transmission type, and maximum transmission bytes of data packets.

USB firmware communication process

After the USB firmware framework process enters the communication module, the firmware first calls the initialization routine, configures the USB interface device, and puts it into an operating state, and then enables the interrupt. The main function of USB communication is implemented in the interrupt service, the main program is only in Wait for whether there is a key to exit in a loop. When an interrupt signal is detected, it will enter the interrupt service subroutine, determine the interrupt type according to the value of the register MAEV, and enter the corresponding process.

The USB communication of the device mainly realizes the Bulk transmission function of ECG and blood pressure data. Based on the communication protocol of USB bus to send and receive data, the monitor also has a specific application layer communication protocol. After the firmware receives the user communication command, it parses the control command and executes the corresponding routine. For example, to transmit the ECG and blood pressure data command 0x10, after receiving the 0x10 command code, the firmware obtains information such as the length of the data to be transmitted, the selected transmission flag of the ECG or blood pressure, and its record number from the command parameters, and calls GetRecordData () according to the record number. Look up the data from the Flash storage area and store it in the sending buffer of BulkState. If ECG data is transmitted, the acquisition time of the ECG data must also be obtained through GetTIme (). After all the data to be sent is ready to start transmission, because the maximum buffer of Bulk transmission is 64B, first send 64B data, and then in the TX_EV routine to determine whether the host computer is successfully received, if successful, the next batch of block input transaction is transmitted, otherwise Need to resend, repeat the above process cyclically until the data is sent.

USB firmware module routines

initialization

The initialization routine of the USB interface includes the initialization operation of the USBN9603 chip and the initialization of user variables, and then the device enumeration operation starts. In the initialization phase, the firmware needs to operate the registers of the USBN9603 in strict order.

USB device enumeration process

Connect the USB cable of the system to a USB connection port (hub or host root hub), the device is in the power-on state; there are two A 15KΩ pull-up resistor. At this time, the pull-up resistor will raise the level of the data signal line to notify the hub that a new device is connected; then, the hub uses the interrupt channel to report the events that occurred to the host. The hub connected to the device sends a Set_Port_Feature request, causing the hub to send a USB hardware reset command to the port for 10ms, and then recognize the speed of the device. At this point, the device has completed the initialization operation. When the host proves that the device has left the reset state, it starts USB control transmission on the default channel of endpoint 0 and enters the enumeration phase.

Block Transfer Standard Routine

The sending routine of the firmware implements the block transfer function to the host through the endpoint 1, and its flow is shown in FIG. 3. Taking ECG data upload as an example, after receiving the ECG data upload request from the host via endpoint 0, the firmware stores the data to be transferred into the writePtr buffer, and at the same time, stores the data and size to be transmitted into bulkState

The firmware receiving routine receives data from the host through endpoint 2. The host first sends an OUT signaling to endpoint 2. SIE automatically receives the data from the transceiver and stores it in FIFO2. FIFO2 will automatically update the status of the receive control register RXC. After the hardware operation is completed, USBN9603 will transfer a receive interrupt to the S3C44B0X processor, and the firmware will execute the receive interrupt service routine.

Implementation of USB communication protocol on the host side

WDM drivers include device function drivers and bus drivers. Among them, the bus driver is provided by Windows, and the host software in this article includes the following three levels: application program in user mode, Win32API dynamic connection library for USB communication, and WDM device function driver in core mode. The dynamic link library encapsulates the function of accessing the core mode driver and provides an access interface for the user application. The user application only needs to call to achieve the transmission of specific data, and the core of the host-side software design is how to develop WDM device functions driver.

Install the Windows2000 DDK on the Windows2000 platform, use Visual C ++ 6.0 as the development tool, and use the DriverWorks toolkit and kernel code debugging tool module SofTICE, and the USB bus monitoring tool Bus Hound to develop the WDM driver.

According to the DriverWizard wizard prompt, select the device type as USB; select the IRP processing method of the I / O request packet as the IRP queuing method; create the device interface as a 128-bit globally unique identifier (GUID) identifier, so that the CreateFile () function opens When a device is used, WDM can identify and access the device's driver through the GUID; the configuration control, BulkIN, and BulkOUT three endpoints transmit commands and data respectively. Configure three IOCTL control commands: MYUSB_IOCTL_COMMAND is a control command for the host to send communication commands, and its IoctlCode is 0x812; MYUSB_IOCTL_BULK_READ and MYUSB_IOCTL_BULK_WRITE send the read and write commands for Bulk data transmission, and their IoctlCode are 0x814 and 0x815, respectively. After all the settings are completed, the .inf installation information file is generated. Under these frameworks, host device drivers that communicate with device firmware can be written based on application requirements.

When the host requests to read and write ECG or blood pressure data in Bulk mode, it will give IOCTL IRP with IOCTL_CODE of MYUSB_IOCTL_ BULK_READ, and the processing routine is BulkReadWrite (). To achieve the BULK data reading and writing function by passing different parameters, you first need to obtain the channel number, input / output buffer and its size from the IRP, and call FindPipe () to obtain the channel instance required by the IRP. Construct a URB on the channel, call SubmitUrb () to send the URB, realize the communication with the underlying USB class driver, and complete the Bulk data transmission function.

Kitchen special lamps referred to Cabinet Lights, originated in the 1980s. Bentley by American lighting designer. Mick was first applied in its "wedding. Amber, "works. Bentley. Mick has been advocating a different light have different functions, and will bring a different spatial effect. Some lighting has specific unique features, while others are multi-purpose. In fact, many areas within the housing needs with more than two different lighting effects.


Cabinet Light after years of development has increased from simple quartz lamp (spotlight) to today, we have achieved each section has a dedicated cabinet lighting. But also from the original halogen light source, the development of fluorescent light, then into today's LED light source. Truly meet the safety, energy conservation, environmental protection requirements. Cabinet light plastic material with aluminum and PC-based.


Cabinet lighting is mainly used for wall cabinets local lighting. General kitchen lighting lights are mounted above the kitchen, the lights shine down from the upper and therefore will be affected by cabinet light cabinet plate blocked resulting in insufficient lighting, cabinet lighting you can take care of such details of life, with infrared sensor switch cabinet lighting cabinet lights to add a bit more sense of fashion technology.


DIY modular lighting

Cabinet Light,White Cabinet Light,Jewellery Cabinet Lighting,Kitchen Cabinet Lighting.

Shenzhen Mingxue Optoelectronics CO.,Ltd , https://www.led-lamp-china.com

This entry was posted in on