ARM USB Communication

Publisher:数字驿站Latest update time:2019-12-11 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Use ZLG's dynamic link library for dynamic loading.


ARM is Context-M3-1343.


Host computer communication software developed in C++ Builder 6.


The USB communication code is as follows:



//---------------------------------------------------------------------------


#include

#pragma hdrstop


#include "Unit1.h"

//#include "zyUSBDev.h"


//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

        : TForm(Owner)

{

}

//---------------------------------------------------------------------------


void __fastcall TForm1::Button1Click(TObject *Sender)

{

    unsigned char sendbuf[1024],recbuf[1024];

    int i;


    unsigned char Substitution;

    for (i = 0; i < sizeof(sendbuf); i++)

    {

        sendbuf[i] = Inbyte; //Put the hexadecimal byte into the send buffer 4096 bytes

        recbuf[i] = 0; // Clear the receive buffer

    }


    /******************* Let's start using the dynamic library **************************/

    int ret;

    AnsiString m_Disp = " china";

    unsigned char cmd[2],ack;

    cmd[0] = sizeof(sendbuf) / 256; //The high 8 bits of the length of the number of bytes to be sent

    cmd[1] = sizeof(sendbuf) % 256; // lower 8 bits


    HINSTANCE handle;

    FARPROC lpFarProc;

    int __stdcall (*pFun)(int,unsigned char*,int,int);//change


    handle = LoadLibrary("zyUSBDev.dll");

    lpFarProc = GetProcAddress(handle, "zyUSB_ReadData");

    pFun = (int(__stdcall*)(int,unsigned char*,int,int))lpFarProc;  //__cdecl


    //Step 5: Use logical endpoint 2 to receive a large amount of data from the USB device

    ret = pFun(2, recbuf, sizeof(sendbuf), 1000);

    if (ret != sizeof(sendbuf))

    {

        if (ret <= 0)

        {

            m_Disp = "Logical endpoint 2 receive data error: No valid data was received.";

        }

        else if (ret > 0)

        {

            m_Disp = "Logical endpoint 2 receive data error: Partial data received.";

        }


        // MessageBox("Logical endpoint 2 receiving data error");

        return;

    }


    // Display the received bytes

    m_Disp = "";

    int temp = 0;

    temp = recbuf[0] + recbuf[1] * 256;

    m_Disp= IntToStr(temp) + " ";

    for (i = 0; i < sizeof(sendbuf); i++)

        m_Disp = m_Disp + recbuf[i] + " ";


    Memo1->Text = m_Disp;

    FreeLibrary(handle);

}

//---------------------------------------------------------------------------


Keywords:ARM Reference address:ARM USB Communication

Previous article:Azure ARM (7) ARM Template - Edit using Visual Studio
Next article:Bootloader program upgrade principle and code analysis based on ARM Cortex-M0+ core

Recommended ReadingLatest update time:2024-11-23 19:26

Advantages and parameters of USB2.0 high-speed card reader solution
GL823K is a USB 2.0 single LUN card reader controller that supports SD/MMC/MSPRO flash memory cards. It supports USB 2.0 high-speed transmission. As a single-chip solution for USB 2.0 flash card readers, the GL823K complies with the Universal Serial Bus Specification version 2.0, USB Storage Class Specification versio
[Microcontroller]
Advantages and parameters of USB2.0 high-speed card reader solution
Display Chinese characters on the ARM experiment board LCD
1. Experimental Purpose 1. Write a program that can display Chinese characters on the ARM experiment board LCD; 2. Establish a cross-compilation environment in the Ubuntu system and compile the above program to generate a .o file; 3. Create a root file system and download it to the development board for verification.
[Microcontroller]
Simple example of arm-Linux dynamic library compilation
This article tells a simple example and explains "compiling dynamic libraries" very well.  1. Preparation  1. Use oracle VM Virtualbox software to install the Ubuntu virtual machine  2. Download the relevant software and transfer it to the virtual machine, and install the cross compiler.  2. Compile and apply  This
[Microcontroller]
Simple example of arm-Linux dynamic library compilation
Design of Embedded Intelligent Instrument System Based on ARM and DSP
1 Introduction With the increasing requirements of intelligent instruments and control systems for real-time signal processing and the rapid development of large-scale integrated circuit technology, there is an increasingly urgent need for a high-performance design solution to adapt to it. Combining DSP tec
[Test Measurement]
Design of Embedded Intelligent Instrument System Based on ARM and DSP
ARM Study Notes 010 New Problems in Gcc Compilation
The previous division problem has not been solved yet, and now there is the following problem (without adding the raise function): The reasons given online are: I'm getting the "relocation truncated to fit: R_ARM_PC24 against symbol" error message when linking, what does this mean? You will get this error message
[Microcontroller]
ARM Study Notes 010 New Problems in Gcc Compilation
In-depth analysis of the design of a dental chair control system based on ARM embedded technology
1 Introduction At present, the market for high-end dental chair equipment is basically dominated by foreign companies. Generally, they are expensive and the technology is not transferable. As people pay more and more attention to oral health, it is particularly necessary to develop a high-end integrated oral diagnosis
[Microcontroller]
In-depth analysis of the design of a dental chair control system based on ARM embedded technology
Control of the display through the AV port based on ARM MCU
Design Background ARM processor is the most popular embedded processor in the world, widely used in embedded fields such as personal communication. This article discusses the method of using a CPU based on the ordinary ARM7 core to display on a display that needs to be displayed through an AV port, such as in the dis
[Power Management]
Control of the display through the AV port based on ARM MCU
Research on embedded video monitoring system based on S3C2410
1 System Hardware Structure This system adopts modular structural design concept, and divides the equipment into main control module and various functional modules. There is a unified or specific interface form between the main control module and each functional module. Users can choose different functi
[Security Electronics]
Research on embedded video monitoring system based on S3C2410
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号