{"id":1651,"date":"2025-04-09T16:30:39","date_gmt":"2025-04-09T08:30:39","guid":{"rendered":"https:\/\/aoofoo.com\/?p=1651"},"modified":"2025-04-09T21:35:17","modified_gmt":"2025-04-09T13:35:17","slug":"ota2-ota%e4%b8%b2%e5%8f%a3%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"https:\/\/aoofoo.com\/index.php\/2025\/04\/09\/ota2-ota%e4%b8%b2%e5%8f%a3%e8%ae%be%e8%ae%a1\/","title":{"rendered":"[OTA]2.OTA\u4e32\u53e3\u8bbe\u8ba1"},"content":{"rendered":"<h2>\u529f\u80fd\u80cc\u666f<\/h2>\n<p>\u6211\u4eec\u7684\u8f85\u52a9\u529f\u80fd\u4e2d\u6709\u4e32\u53e3 IAP \u529f\u80fd\uff08\u4e32\u53e3 In-Application Programming\uff09\uff0c\u8fd9\u9879\u529f\u80fd\u7528\u4e8e\u4e0b\u8f7d\u7a0b\u5e8f\u3002\u5f53\u9700\u8981\u4e0b\u8f7d\u5927\u91cf\u6570\u636e\u65f6\uff0c\u5355\u9760 CPU \u8bfb\u53d6\u6570\u636e\u5df2\u7ecf\u8ddf\u4e0d\u4e0a\u901f\u5ea6\uff0c\u56e0\u6b64\u6211\u4eec\u91c7\u7528 <strong>DMA + \u7a7a\u95f2\u4e2d\u65ad<\/strong> \u7684\u65b9\u6848\u6765\u9ad8\u6548\u642c\u8fd0\u6570\u636e\u3002<\/p>\n<ul>\n<li><strong>DMA\uff08\u76f4\u63a5\u5b58\u50a8\u5668\u8bbf\u95ee\uff09<\/strong> \u81ea\u52a8\u5730\u5c06\u6570\u636e\u4ece\u4e32\u53e3\u63a5\u6536\u7f13\u51b2\u533a\u642c\u8fd0\u5230\u5185\u5b58\u4e2d\u7684\u4e00\u4e2a\u6570\u7ec4\uff0c\u4e0d\u9700\u8981 CPU \u9010\u4e2a\u5b57\u8282\u5904\u7406\u3002<\/li>\n<li><strong>\u7a7a\u95f2\u4e2d\u65ad<\/strong> \u7528\u4e8e\u68c0\u6d4b\u5f53\u524d\u4e32\u53e3\u662f\u5426\u6682\u505c\u4e86\u6570\u636e\u63a5\u6536\u3002\u5f53\u4e32\u53e3\u6ca1\u6709\u6570\u636e\u8fdb\u6765\u65f6\uff0c\u7a7a\u95f2\u4e2d\u65ad\u4f1a\u88ab\u89e6\u53d1\uff0c\u6211\u4eec\u5c31\u5728\u4e2d\u65ad\u91cc\u505c\u6b62 DMA \u7684\u642c\u8fd0\uff0c\u8fd9\u6837\u5c31\u80fd\u51c6\u786e\u5730\u77e5\u9053\u672c\u6b21\u642c\u8fd0\u7684\u6570\u636e\u7ed3\u675f\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n<h2>\u6570\u636e\u5b58\u50a8\u548c\u6307\u9488\u7ba1\u7406<\/h2>\n<p>\u7531\u4e8e DMA \u6570\u636e\u642c\u8fd0\u901f\u5ea6\u975e\u5e38\u5feb\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u6570\u636e\u4e0d\u4f1a\u4e22\u5931\uff0c\u6211\u4eec\u5728\u5185\u5b58\u4e2d\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\u6765\u5b58\u653e\u8fd9\u4e9b\u6570\u636e\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u4f7f\u7528\u4e00\u7ec4\u6307\u9488\u6765\u7ba1\u7406\u8fd9\u5757\u5185\u5b58\u533a\u57df\uff1a<\/p>\n<ul>\n<li><strong>SE \u6307\u9488\u5bf9\uff08Start\/End \u6307\u9488\u5bf9\uff09<\/strong>\n<ul>\n<li>\u5305\u542b\u4e24\u4e2a\u6307\u9488\uff1a\n<ul>\n<li><strong>Start \u6307\u9488<\/strong>\uff1a\u6307\u5411\u6570\u636e\u63a5\u6536\u7684\u8d77\u59cb\u4f4d\u7f6e<\/li>\n<li><strong>End \u6307\u9488<\/strong>\uff1a\u6307\u5411\u6570\u636e\u63a5\u6536\u7684\u7ed3\u675f\u4f4d\u7f6e<\/li>\n<\/ul>\n<\/li>\n<li>\u6bcf\u6b21 DMA \u642c\u8fd0\u6570\u636e\u65f6\uff0c\u90fd\u4f1a\u7528\u8fd9\u5bf9\u6307\u9488\u8bb0\u5f55\u8be5\u6b21\u6570\u636e\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>IN \u6307\u9488<\/strong>\n<ul>\n<li>\u7528\u4e8e\u8bb0\u5f55\u6570\u636e\u5199\u5165\u7684\u4f4d\u7f6e\u3002<\/li>\n<li>\u5728\u521d\u59cb\u5316\u65f6\uff0cIN \u6307\u9488\u4e0e OUT \u6307\u9488\u90fd\u6307\u5411 SE \u6307\u9488\u5bf9\u91cc\u7684\u7b2c 0 \u4e2a\u6210\u5458\u7684\u8d77\u59cb\u4f4d\u7f6e\uff08[0]S\uff09\uff0c\u544a\u8bc9 DMA \u6570\u636e\u4e00\u5230\u5c31\u5b58\u5165\u4e00\u7ef4\u6570\u7ec4\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002<\/li>\n<li>\u5f53 DMA \u642c\u8fd0\u7ed3\u675f\u5e76\u89e6\u53d1\u7a7a\u95f2\u4e2d\u65ad\u65f6\uff0c\u4f1a\u5728\u4e2d\u65ad\u4e2d\u8bbe\u7f6e\u672c\u6b21\u6570\u636e\u7684\u7ed3\u675f\u4f4d\u7f6e\uff08[0]E\uff09\uff0c\u540c\u65f6\u66f4\u65b0 IN \u6307\u9488\uff0c\u8ba9\u4e0b\u6b21\u6570\u636e\u5b58\u5230\u4e0b\u4e00\u4e2a\u6709\u6548\u533a\u57df\uff0c\u6bd4\u5982[1]S\u5f00\u59cb\u7684\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>OUT \u6307\u9488<\/strong>\n<ul>\n<li>\u7528\u4e8e\u63d0\u53d6\u6570\u636e\u3002<\/li>\n<li>\u5f53 IN \u6307\u9488\u548c OUT \u6307\u9488\u4e0d\u91cd\u5408\u65f6\uff0c\u8bf4\u660e\u7f13\u51b2\u533a\u91cc\u6709\u6570\u636e\u53ef\u4ee5\u5904\u7406\u3002<\/li>\n<li>\u7cfb\u7edf\u4f1a\u901a\u8fc7\u5224\u65ad\u8fd9\u4e24\u4e2a\u6307\u9488\u6765\u51b3\u5b9a\u662f\u5426\u9700\u8981\u8bfb\u53d6\u6570\u636e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>END \u6307\u9488<\/strong>\n<ul>\n<li>\u8868\u793a SE \u6307\u9488\u5bf9\u91cc\u7684\u6700\u540e\u4e00\u4e2a\u6210\u5458\uff0c\u76f8\u5f53\u4e8e\u5185\u5b58\u533a\u57df\u7684\u8fb9\u754c\u3002<\/li>\n<li>\u5f53 IN \u6216 OUT \u6307\u9488\u79fb\u52a8\u65f6\uff0c\u5fc5\u987b\u68c0\u67e5\u662f\u5426\u8fbe\u5230\u4e86 END \u6307\u9488\u4f4d\u7f6e\uff0c\u9632\u6b62\u8d8a\u754c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>DMA \u5355\u6b21\u642c\u8fd0\u91cf\u4e0e\u7f13\u51b2\u533a\u7ba1\u7406<\/h2>\n<p>\u4e3a\u4e86\u9632\u6b62\u6570\u636e\u642c\u8fd0\u8fc7\u5feb\u5bfc\u81f4\u5185\u5b58\u6570\u7ec4\u6ea2\u51fa\uff0c\u6211\u4eec\u9700\u8981\u786e\u5b9a DMA \u6bcf\u6b21\u80fd\u642c\u8fd0\u7684\u6700\u5927\u6570\u636e\u91cf\u3002\u6bd4\u5982\uff1a<\/p>\n<ul>\n<li>\u5047\u8bbe\u4e00\u7ef4\u6570\u7ec4\u7684\u603b\u7a7a\u95f4\u4e3a 2048 \u5b57\u8282\uff0c\u4f46 DMA \u6bcf\u6b21\u6700\u5927\u642c\u8fd0\u91cf\u8bbe\u7f6e\u4e3a 256 \u5b57\u8282\u3002<\/li>\n<li>\u5982\u679c\u6570\u7ec4\u91cc\u5269\u4f59\u7684\u53ef\u7528\u7a7a\u95f4\u4e0d\u8db3 256 \u5b57\u8282\uff0c\u90a3\u4e48\u5c31\u4e0d\u80fd\u518d\u8ba9 DMA \u642c\u8fd0\u66f4\u591a\u6570\u636e\uff0c\u800c\u8981\u5c06\u7f13\u51b2\u533a\u7684\u5199\u5165\u6307\u9488\u56de\u6eda\u5230\u5f00\u59cb\u4f4d\u7f6e\u91cd\u65b0\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p>\u4e3a\u6b64\uff0c\u6211\u4eec\u4f1a\u7528\u4e00\u4e2a\u53d8\u91cf\u8bb0\u5f55\u5f53\u524d\u5df2\u7ecf\u5b58\u50a8\u7684\u6570\u636e\u91cf\uff0c\u4ee5\u4fbf\u968f\u65f6\u76d1\u63a7\u5269\u4f59\u7a7a\u95f4\u662f\u5426\u8db3\u591f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u8bdd\u8bed\u591a\u8bf4\u65e0\u76ca\u53ea\u4f1a\u8d8a\u6765\u8d8a\u8ff7\uff0c\u6211\u4eec\u76f4\u63a5\u770b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"corepress-code-pre\"><code>#define U0_RX_SIZE  2048 \/\/ \u4e00\u7ef4\u6570\u7ec4\u603b\u5927\u5c0f\r\n#define U0_RX_MAX   256  \/\/ \u5355\u6b21 DMA \u6700\u5927\u642c\u8fd0\u91cf\r\n#define NUM         10   \/\/ \u7f13\u5b58\u533a\u6570\u636e\u5757\u6570\u91cf\r\n\r\n\/\/ \u5b9a\u4e49\u4e00\u4e2a\u6570\u636e\u5757\u6307\u9488\u7ed3\u6784\u4f53\uff0c\u7528\u4e8e\u8868\u5f81\u4e00\u5757\u6570\u636e\u7684\u8d77\u59cb\u548c\u7ed3\u675f\u4f4d\u7f6e\r\ntypedef struct\r\n{\r\n    uint8_t* start; \/\/ \u6570\u636e\u5f00\u59cb\u4f4d\u7f6e\r\n    uint8_t* end;   \/\/ \u6570\u636e\u7ed3\u675f\u4f4d\u7f6e\r\n} UCB_URxBuffptr;\r\n\r\n\/\/ \u5b9a\u4e49\u4e00\u4e2a\u63a7\u5236\u5757\u7ed3\u6784\u4f53\uff0c\u7528\u4e8e\u7ba1\u7406\u6240\u6709\u6570\u636e\u5757\u53ca\u6570\u636e\u7684\u8bfb\u5199\r\ntypedef struct\r\n{\r\n    uint16_t URxCounter;                   \/\/ \u7528\u4e8e\u7d2f\u8ba1\u63a5\u6536\u5230\u7684\u6570\u636e\u5b57\u8282\u6570\r\n    UCB_URxBuffptr URxDataPtr[NUM];          \/\/ \u5b58\u50a8 NUM \u5757\u6570\u636e\u7684\u6307\u9488\r\n    UCB_URxBuffptr* URxDataIN;             \/\/ \u6570\u636e\u5199\u5165\u6307\u9488\uff1a\u5f53\u524d\u5199\u5165\u4f4d\u7f6e\r\n    UCB_URxBuffptr* URxDataOUT;            \/\/ \u6570\u636e\u8bfb\u53d6\u6307\u9488\uff1a\u5f53\u524d\u8bfb\u53d6\u4f4d\u7f6e\r\n    UCB_URxBuffptr* URxDataEND;            \/\/ \u7f13\u5b58\u533a\u7684\u7ed3\u675f\u6307\u9488\uff0c\u9632\u6b62\u8d8a\u754c\r\n} UCB_CB;<\/code><\/pre>\n<pre class=\"corepress-code-pre\"><code>\/\/\u6307\u9488\u521d\u59cb\u5316\r\nvoid PtrInit(void)\r\n{ \r\n    U0CB.URxDataIN  = &amp;U0CB.URxDataPtr[0];\r\n    U0CB.URxDataOUT = &amp;U0CB.URxDataPtr[0];\r\n    U0CB.URxDataEND = &amp;U0CB.URxDataPtr[NUM-1];\r\n    U0CB.URxDataIN-&gt;start = &amp;U0CB.URxDataPtr[0];\r\n    U0CB.URxCounter = 0 ;\r\n    \r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u529f\u80fd\u80cc\u666f \u6211\u4eec\u7684\u8f85\u52a9\u529f\u80fd\u4e2d\u6709\u4e32\u53e3 IAP \u529f\u80fd\uff08\u4e32\u53e3 In-Application Programming\uff09\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1651","post","type-post","status-publish","format-standard","hentry","category-ota"],"_links":{"self":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/comments?post=1651"}],"version-history":[{"count":5,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1651\/revisions"}],"predecessor-version":[{"id":1662,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1651\/revisions\/1662"}],"wp:attachment":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/media?parent=1651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/categories?post=1651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/tags?post=1651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}