📄 sampleapp.c
字号:
/*
**********************************************************************
* Micrium, Inc.
* 949 Crestview Circle
* Weston, FL 33327-1848
*
* uC/USB-Bulk
*
* (c) Copyright 2003 - 2004, Micrium, Inc.
* All rights reserved.
*
***********************************************************************
----------------------------------------------------------------------
File : SampleApp.c
Purpose : USB BULK Sample Application
---------------------------END-OF-HEADER------------------------------
*/
#include <stdio.h>
#include <windows.h>
#include "USBBULK.h"
/*********************************************************************
*
* _MessageBox
*
*/
static void _MessageBox(const char * s) {
MessageBox(NULL, s, "USB Bulk sample application", MB_OK);
}
/*********************************************************************
*
* _SendReceive1
*
*/
static int _SendReceive1(unsigned char DataTx) {
unsigned char DataRx;
int r;
printf("Writing one byte\n");
r = USBBULK_Write(&DataTx, 1);
if (r == 0) {
_MessageBox("Could not write to device");
}
printf("Reading one byte\n");
r = USBBULK_Read (&DataRx, 1);
if (r == 0) {
_MessageBox("Could not read from device (time out)");
}
if (DataRx != (DataTx + 1)) {
_MessageBox("Wrong data read");
return 1;
}
printf("Operation succesful!\n\n");
return 0;
}
/*********************************************************************
*
* _Test
*
*/
int Test(void) {
int r;
r = _SendReceive1(0x12);
if (r) {
return r;
}
r = _SendReceive1(0x13);
return r;
}
/*********************************************************************
*
* main
*
* Function description
*/
int main(int argc, char* argv[]) {
int r;
if (USBBULK_Open() == NULL) {
_MessageBox("Unable to connect to USB BULK device");
return 1;
}
r = Test();
USBBULK_Close();
if (r == 0) {
_MessageBox("Communication with USB BULK device succesful!");
}
return r;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -