久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 14014|回復(fù): 10
收起左側(cè)

安卓通過USBHost和stm32通信源代碼,包括安卓端和stm32端

  [復(fù)制鏈接]
ID:127084 發(fā)表于 2016-6-17 15:32 | 顯示全部樓層 |閱讀模式
以前的學(xué)習(xí)結(jié)果,為了f429,現(xiàn)貢獻(xiàn)給大家,大家可以直接用我這程序當(dāng)做安卓的串口調(diào)試助手,望大家喜歡,幫我加油頂貼。
給大家一個提示,這個安卓程序要求你的安卓設(shè)備支持Host功能,并且root,打開了usbhost權(quán)限哈。
809ec317f4dae6703b589bc73d38cc69.png


cbf89f3ecfebd9f22f71be2af028582b.png

  1. /**
  2.   ******************************************************************************
  3.   * @file    main.c
  4.   * @author  MCD Application Team
  5.   * @version V4.0.0
  6.   * @date    21-January-2013
  7.   * @brief   Virtual Com Port Demo main file
  8.   ******************************************************************************
  9.   * @attention
  10.   *
  11.   * [b]© COPYRIGHT 2013 STMicroelectronics[/b]
  12.   *
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14.   * You may not use this file except in compliance with the License.
  15.   * You may obtain a copy of the License at:
  16.   *
  17.   *        [url]http://www.st.com/software_license_agreement_liberty_v2[/url]
  18.   *
  19.   * Unless required by applicable law or agreed to in writing, software
  20.   * distributed under the License is distributed on an "AS IS" BASIS,
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22.   * See the License for the specific language governing permissions and
  23.   * limitations under the License.
  24.   *
  25.   ******************************************************************************
  26.   */


  27. /* Includes ------------------------------------------------------------------*/
  28. #include "hw_config.h"
  29. #include "usb_lib.h"
  30. #include "usb_desc.h"
  31. #include "usb_pwr.h"

  32. /* Private typedef -----------------------------------------------------------*/
  33. /* Private define ------------------------------------------------------------*/
  34. /* Private macro -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Extern variables ----------------------------------------------------------*/
  37. /* Private function prototypes -----------------------------------------------*/
  38. /* Private functions ---------------------------------------------------------*/

  39. /*******************************************************************************
  40. * Function Name  : main.
  41. * Description    : Main routine.
  42. * Input          : None.
  43. * Output         : None.
  44. * Return         : None.
  45. *******************************************************************************/
  46. void delay_ms(unsigned int m)
  47. {
  48.         while(m--);
  49. }
  50. /*******************************************************************************
  51. * Function Name  : USB_To_USART_Send_Data.
  52. * Description    : send the received data from USB to the UART 0.
  53. * Input          : data_buffer: data address.
  54.                    Nb_bytes: number of bytes to send.
  55. * Return         : none.
  56. *******************************************************************************/
  57. void USB_To_USART_Send_Data(uint8_t* data_buffer, uint8_t Nb_bytes)
  58. {
  59. //在此處處理用戶數(shù)據(jù)接收。
  60. }
  61. int main(void)
  62. {
  63.   Set_System();
  64.   Set_USBClock();
  65.   USB_Interrupts_Config();
  66.   USB_Init();
  67.   while (1)
  68.   {
  69.                 delay_ms(50);
  70.                 USART_To_USB_Send_Data((unsigned char *)"Hello",6);
  71.   }
  72. }
  73. #ifdef USE_FULL_ASSERT
  74. /*******************************************************************************
  75. * Function Name  : assert_failed
  76. * Description    : Reports the name of the source file and the source line number
  77. *                  where the assert_param error has occurred.
  78. * Input          : - file: pointer to the source file name
  79. *                  - line: assert_param error line source number
  80. * Output         : None
  81. * Return         : None
  82. *******************************************************************************/
  83. void assert_failed(uint8_t* file, uint32_t line)
  84. {
  85.   /* User can add his own implementation to report the file name and line number,
  86.      ex: printf("Wrong parameters value: file %s on line %d", file, line) */

  87.   /* Infinite loop */
  88.   while (1)
  89.   {}
  90. }
  91. #endif

  92. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
復(fù)制代碼

stm32f103虛擬串口程序.zip (368.2 KB, 下載次數(shù): 73)

安卓端Host程序.zip (1.33 MB, 下載次數(shù): 62)





回復(fù)

使用道具 舉報

ID:127084 發(fā)表于 2016-6-17 15:32 | 顯示全部樓層
回復(fù)
求解,怎么實現(xiàn)的。從前看到有人用藍(lán)牙當(dāng)串口就感覺很高端~

隨著USB的普及,串口的局限性,串口在產(chǎn)品設(shè)計中使用的越來越少,甚至在近幾年的一部分臺式機和絕大多數(shù)筆記本電腦都不帶串口接口了。不過老一代的設(shè)備還沒有淘汰,比如串口打印機,還有各種工業(yè)的控制器等等,它們還是用的串口接口,那么就導(dǎo)致了老設(shè)備在新計算機上面無法使用,為了解決這一尷尬情況,USB協(xié)會制定了CDC標(biāo)準(zhǔn),即:用USB通信來模擬串口通信,在計算機端就會直接識別為串口,原來開發(fā)的軟件不用做任何修改就可以繼續(xù)使用。
回復(fù)

使用道具 舉報

ID:130178 發(fā)表于 2016-7-12 15:16 | 顯示全部樓層
您好,這個很棒 謝謝
回復(fù)

使用道具 舉報

ID:123924 發(fā)表于 2018-1-10 11:38 | 顯示全部樓層
如何收藏??只好回復(fù)保存
回復(fù)

使用道具 舉報

ID:282409 發(fā)表于 2018-2-5 17:30 | 顯示全部樓層
51hei大小 發(fā)表于 2016-6-17 15:32
回復(fù)
求解,怎么實現(xiàn)的。從前看到有人用藍(lán)牙當(dāng)串口就感覺很高端~

可以直接使用USB轉(zhuǎn)串口芯片,比如CH340來實現(xiàn),CH340也是支持安卓系統(tǒng)的,接上就可以直接使用,給安卓手機擴(kuò)展出一個串口來。
還有一種應(yīng)用方式是安卓手機作為設(shè)備端,需要使用到USB 安卓HOST芯片,可以參考CH559這類單片機來做,也就是單片機的USB做主機,安卓的USB做設(shè)備,這樣通信。
回復(fù)

使用道具 舉報

ID:135990 發(fā)表于 2018-9-11 17:25 | 顯示全部樓層
需要使用otg線嗎
回復(fù)

使用道具 舉報

ID:184314 發(fā)表于 2019-6-11 15:18 | 顯示全部樓層
支持一下,剛好再看這方面的
回復(fù)

使用道具 舉報

ID:434018 發(fā)表于 2019-6-17 12:58 | 顯示全部樓層
It is very good!Thanks!
回復(fù)

使用道具 舉報

ID:434018 發(fā)表于 2019-6-17 16:50 | 顯示全部樓層
It is a good reference.Thanks!
回復(fù)

使用道具 舉報

ID:734898 發(fā)表于 2020-4-22 15:46 來自觸屏版 | 顯示全部樓層
在小米5 MIUI8 安卓6.0上,以及紅米k20pro MIUI11 安卓10上,都是打開之后直接閃退,提示拔出了usb設(shè)備。。。連接的時候也的確是彈出了應(yīng)用請求的,不知道是我單片機的問題還是安卓版本不兼容
回復(fù)

使用道具 舉報

ID:1014633 發(fā)表于 2022-3-31 16:22 | 顯示全部樓層
學(xué)藝一下 難得看待
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 久久男人| 毛片免费在线观看 | 成人免费毛片嘿嘿连载视频 | 91精品国产一区二区三区 | 亚洲精品一区二区三区在线 | 免费av网站在线观看 | 色日韩| 国产欧美一区二区三区视频在线观看 | aaa黄色片| 三级免费网站 | 午夜成人免费视频 | 黄色片网站在线观看 | 黄免费视频| 在线日韩一区 | 亚洲激情成人 | 久久婷婷网 | 亚洲三级小说 | 手机av片| 欧美日本在线观看 | 日韩欧美在线一区 | 少妇高潮露脸国语对白 | 91午夜精品亚洲一区二区三区 | 日韩视频免费在线观看 | 欧美性生交xxxxx久久久 | 在线黄网| 黑人黄色一级片 | 亚洲黄色小视频 | 免费观看黄色大片 | 欧美色图一区二区 | 国产免费网址 | 欧美日本| 免费一级黄色录像 | 中文字幕在线免费视频 | 中文字幕一区在线观看 | 一区二区国产精品 | 色哥网 | 久久精品欧美一区二区 | 久久久久一区 | 激情网站在线观看 | 91中文字幕在线 | 日韩精品中文字幕在线观看 |