在公司做的第一個項目,希望能幫助需要這些東西的人。
主要是USB通信我調(diào)試了4天,用的STM最新的USB固件,我們公司有老員工的USB通信實列因為太老我沒用直接自己寫的。
電路板是淘寶買的C8T6核心板,最簡單的好像是10塊錢
單片機源程序如下:
- #include "hw_config.h"
- #include "usb_lib.h"
- #include "usb_pwr.h"
- #include "stm32f10x_it.h"
- #include "usart.h"
- #include "myusb.h"
- #include "adc.h"
- #define LED PBout(12)
- uint32_t nMSGNum=0;
- uint32_t pMSG[64];
- uint8_t nCurIndex=0;
- void outputdebug()
- {
- #ifdef DEBUG
- uint32_t nMSGNumCur=nMSGNum;
- uint8_t nStopIndex=nMSGNumCur%64;
- uint8_t nCount=0;
- for(;nCurIndex!=nStopIndex;)
- {
- nCount=nCurIndex<nStopIndex?(nStopIndex-nCurIndex):(nStopIndex+64-nCurIndex);
-
- printf("%d\t%x\n",nMSGNumCur-nCount,pMSG[nCurIndex]);
-
- nCurIndex=(nCurIndex+1)%64;
- }
- #endif
- }
- int main(void)
- {
- u8 bLed=0;
- Set_System();
- delay_init();
- while (1)
- {
- HW_Proc();
- outputdebug();
- bLed=bLed==0?1:0;
- LED=bLed;
- delay_ms(100);
- }
- }
復制代碼
所有資料51hei提供下載:
STM32_HIDBattery.7z
(193.9 KB, 下載次數(shù): 274)
2019-1-23 14:40 上傳
點擊文件名下載附件
Keil5代碼 下載積分: 黑幣 -5
|