{"id":1414,"date":"2024-06-25T09:02:35","date_gmt":"2024-06-25T01:02:35","guid":{"rendered":"https:\/\/xujiwei.com\/blog\/?p=1414"},"modified":"2024-06-25T09:02:35","modified_gmt":"2024-06-25T01:02:35","slug":"qmk-stm32f103-i2c-remap","status":"publish","type":"post","link":"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/","title":{"rendered":"\u6574\u4e2a\u5e26\u5c4f\u6570\u5b57\u5c0f\u952e\u76d8\u5427\uff0c\u5148\u641e\u5b9a QMK \u56fa\u4ef6\u652f\u6301 STM32F103 \u7684 I2C Remap"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<p class=\"ez-toc-title\">\u6587\u7ae0\u76ee\u5f55<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e163556f3c2\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e163556f3c2\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#%E5%85%8D%E8%B4%B9%E6%89%93%E6%A0%B7%E6%9D%A5%E6%B5%8B%E8%AF%95\" title=\"\u514d\u8d39\u6253\u6837\u6765\u6d4b\u8bd5\">\u514d\u8d39\u6253\u6837\u6765\u6d4b\u8bd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#%E7%85%A7%E7%8C%AB%E7%94%BB%E8%99%8E%E6%90%9E%E4%B8%AA%E5%8E%9F%E7%90%86%E5%9B%BE\" title=\"\u7167\u732b\u753b\u864e\u641e\u4e2a\u539f\u7406\u56fe\">\u7167\u732b\u753b\u864e\u641e\u4e2a\u539f\u7406\u56fe<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#%E4%BF%AE%E6%94%B9_QMK_%E5%9B%BA%E4%BB%B6\" title=\"\u4fee\u6539 QMK \u56fa\u4ef6\">\u4fee\u6539 QMK \u56fa\u4ef6<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#%E5%90%AF%E7%94%A8_I2C1\" title=\"\u542f\u7528 I2C1\">\u542f\u7528 I2C1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#%E5%90%AF%E7%94%A8_I2C_Remap\" title=\"\u542f\u7528 I2C Remap\">\u542f\u7528 I2C Remap<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#rulesmk_%E9%85%8D%E7%BD%AE_I2C_%E5%BC%95%E8%84%9A\" title=\"rules.mk \u914d\u7f6e I2C \u5f15\u811a\">rules.mk \u914d\u7f6e I2C \u5f15\u811a<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#%E6%B5%8B%E8%AF%95\" title=\"\u6d4b\u8bd5\">\u6d4b\u8bd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\" title=\"\u53c2\u8003\u8d44\u6599\">\u53c2\u8003\u8d44\u6599<\/a><\/li><\/ul><\/nav><\/div>\n<p>\u4e4b\u524d\u53c2\u8003\u7acb\u521b\u5f00\u6e90\u5e73\u53f0\u7684\u590f\u5929\u5927\u4f6c\uff0c\u505a\u4e86\u4e00\u4e2a\u57fa\u4e8e ATMega32A MCU + QMK \u56fa\u4ef6\u7684 40% \u914d\u5217\u952e\u76d8\uff0c\u4e0d\u8fc7\u6700\u540e\u53c8\u60f3\u7528\u8d77\u6765\u7684\u65f6\u5019\u53d1\u73b0\uff0c\u53ef\u80fd\u56e0\u4e3a ATMega32A \u7528\u7684\u662f\u8f6f\u4ef6\u6a21\u62df USB\uff0c\u6240\u4ee5\u5728 Mac \u4e0a\u7684\u517c\u5bb9\u6027\u6709\u70b9\u95ee\u9898\uff0c\u56e0\u6b64\u5c31\u60f3\u7740\u81ea\u5df1\u91cd\u65b0\u641e\u4e00\u4e2a\u952e\u76d8\u3002<\/p>\n<p>\u5728 QMK \u56fa\u4ef6\u7684 MCU \u652f\u6301\u5217\u8868\u91cc\u9762\u7ffb\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0 STM32F103C8T6 \u4e5f\u662f\u652f\u6301\u8303\u56f4\uff0c\u800c\u4e14\u641e\u4e00\u4e2a STM32duino-bootloader \u5c31\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7 USB \u5237\u673a\uff0c\u4e5f\u662f\u76f8\u5f53\u65b9\u4fbf\u4e86\u3002<\/p>\n<p>\u5173\u4e8e STM32F103 \u4f7f\u7528 STM32duino-bootloader\uff0c\u4e4b\u524d\u5df2\u7ecf\u5199\u4e86\u7bc7\u6587\u7ae0\u5206\u4eab <a href=\"https:\/\/mp.weixin.qq.com\/s?__biz=MzkxMTY0NDg0Ng==&amp;mid=2247484093&amp;idx=1&amp;sn=d83cffb9775e825791072c54b8de154c&amp;chksm=c118437cf66fca6a2dd98cd2d2371bd6e823dfce33bea5f9ef73e13215f54c34de2c3fcb9e88&amp;token=1043320760&amp;lang=zh_CN#rd\">\u505a\u952e\u76d8\u5fc5\u5907\uff0c\u629b\u6389ST-Link\uff0cSTM32F103\u901a\u8fc7USB\u70e7\u5f55\uff0cSTM32duino-bootloader\u8e29\u5751\u8bb0\u5f55<\/a> \u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%85%8D%E8%B4%B9%E6%89%93%E6%A0%B7%E6%9D%A5%E6%B5%8B%E8%AF%95\"><\/span>\u514d\u8d39\u6253\u6837\u6765\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4f46\u662f\u76f4\u63a5\u641e\u6574\u4e2a 40% \u914d\u5217\u952e\u76d8\uff0cPCB \u7684\u5c3a\u5bf8\u8d85\u8fc7\u4e86\u5609\u7acb\u521b\u514d\u8d39\u6253\u6837\u7684\u8303\u56f4\uff0c\u56e0\u6b64\u51c6\u5907\u5148\u641e\u4e2a\u6570\u5b57\u5c0f\u952e\u76d8\u6765\u9a8c\u8bc1\u4e00\u4e0b STM32F103 \u505a\u952e\u76d8\u7684\u539f\u7406\u56fe\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E7%85%A7%E7%8C%AB%E7%94%BB%E8%99%8E%E6%90%9E%E4%B8%AA%E5%8E%9F%E7%90%86%E5%9B%BE\"><\/span>\u7167\u732b\u753b\u864e\u641e\u4e2a\u539f\u7406\u56fe<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u641e\u952e\u76d8\u4e3b\u8981\u5c31\u662f\u786e\u5b9a\u884c\u548c\u5217\u7684\u5f15\u811a\uff0c\u4e3a\u4e86\u6700\u5927\u80fd\u652f\u6301 104 \u952e\uff0c\u5c31\u628a\u80fd\u7528\u7684\u5f15\u811a\u5168\u7528\u4e0a\u4e86\u3002<\/p>\n<p>\u53e6\u5916\u4e3a\u4e86\u4f7f\u7528 OLED \u5c4f\u5e55\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86 PB8\u3001PB9 \u4f5c\u4e3a I2C \u901a\u4fe1\u5f15\u811a\u3002<\/p>\n<p><img src=\"https:\/\/xujiwei.com\/blog\/wp-content\/uploads\/2024\/06\/qmk-stm32f103-i2c-remap-1.png\" alt=\"qmk-stm32f103-i2c-remap-1\" style=\"zoom:50%;\" \/><\/p>\n<p>\u539f\u7406\u56fe\u753b\u4e86\u4e4b\u540e\uff0c\u5148\u62ff\u5f00\u53d1\u677f\u6d4b\u8bd5\u4e00\u4e0b\u56fa\u4ef6\u80fd\u4e0d\u80fd\u7528\u5427\uff0c\u7136\u540e\u5c31\u53d1\u73b0 PB9\u3001PB8 \u5bf9\u5e94\u7684 STM32F103 I2C \u662f\u9700\u8981 Remap \u624d\u80fd\u4f7f\u7528\uff0c\u8fd9\u5c31\u5f97\u6539\u4e00\u4e0b QMK \u56fa\u4ef6\u4e86\u3002<\/p>\n<p><img src=\"https:\/\/xujiwei.com\/blog\/wp-content\/uploads\/2024\/06\/qmk-stm32f103-i2c-remap-2.png\" alt=\"qmk-stm32f103-i2c-remap-2\" style=\"zoom:50%;\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9_QMK_%E5%9B%BA%E4%BB%B6\"><\/span>\u4fee\u6539 QMK \u56fa\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u8fd9\u5c31\u8981\u4fee\u6539\u4e00\u4e0b QMK \u56fa\u4ef6\u6765\u8ba9\u5b83\u542f\u7528 I2C Remap\uff0c\u901a\u8fc7 PB8\u3001PB9 \u6765\u4f5c\u4e3a I2C \u901a\u4fe1\u5f15\u811a\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff1a\u6211\u8fd9\u91cc\u4e3a\u4e86\u53ef\u4ee5\u52a8\u6001\u6539\u952e\uff0c\u4f7f\u7528\u7684\u56fa\u4ef6\u662f vial-qmk\u3002<\/strong><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%90%AF%E7%94%A8_I2C1\"><\/span>\u542f\u7528 I2C1<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u8981\u5728 QMK \u56fa\u4ef6\u4e2d\u4f7f\u7528 I2C\uff0c\u9700\u8981\u5148\u542f\u7528\u4e00\u4e0b\uff0c\u5728\u6587\u4ef6 <code>mcuconf.h<\/code> \u4fee\u6539\u5bf9\u5e94\u7684\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-c\">\/\/ \u6587\u4ef6\u8def\u5f84 platforms\/chibios\/boards\/STM32_F103_STM32DUINO\/configs\/mcuconf.h\n#define STM32_I2C_USE_I2C1      TRUE<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E5%90%AF%E7%94%A8_I2C_Remap\"><\/span>\u542f\u7528 I2C Remap<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6839\u636e\u7f51\u4e0a\u641c\u7d22\u5230\u7684\u6559\u7a0b\uff0c\u8981\u542f\u7528 I2C Remap \u9700\u8981\u5148\u542f\u7528 AFIO \u65f6\u949f\uff0c\u9700\u8981\u4fee\u6539\u4e00\u4e0b\u521d\u59cb\u5316\u4ee3\u7801\u4e2d <code>boardInit<\/code> \u76f8\u5173\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u52a0\u4e0a\u4e86 <code>AFIO_MAPR_I2C1_REMAP<\/code> \u6807\u5fd7\u4f4d\u3002<\/p>\n<pre><code class=\"language-c\">\/\/ \u6587\u4ef6\u8def\u5f84 platforms\/chibios\/boards\/STM32_F103_STM32DUINO\/board\/board.c\nvoid boardInit(void) {\n   \/\/JTAG-DP Disabled and SW-DP Enabled\n   AFIO-&gt;MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE | AFIO_MAPR_I2C1_REMAP;\n   \/\/Set backup register DR10 to enter bootloader on reset\n   BKP-&gt;DR10 = RTC_BOOTLOADER_FLAG;\n}<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"rulesmk_%E9%85%8D%E7%BD%AE_I2C_%E5%BC%95%E8%84%9A\"><\/span>rules.mk \u914d\u7f6e I2C \u5f15\u811a<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6700\u540e\u5c31\u5728 <code>rules.mk<\/code> \u4e2d\u914d\u7f6e I2C \u5f15\u811a\uff0c\u5c31\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528 OLED \u5c4f\u5e55\u4e86\u3002<\/p>\n<pre><code class=\"language-c\">#define I2C_DRIVER              I2CD1\n#define I2C1_SCL_PIN            B8\n#define I2C1_SDA_PIN            B9<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95\"><\/span>\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u6700\u540e\u6d4b\u8bd5\u5c4f\u5e55\u5c31\u53ef\u4ee5\u6b63\u5e38\u663e\u793a\u4e86\uff1a<\/p>\n<p><img src=\"https:\/\/xujiwei.com\/blog\/wp-content\/uploads\/2024\/06\/qmk-stm32f103-i2c-remap-3.jpg\" alt=\"qmk-stm32f103-i2c-remap-3\" style=\"zoom:50%;\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\"><\/span>\u53c2\u8003\u8d44\u6599<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\u6a21\u5757\u7ec4\u5408\u952e\u76d8\uff1a <a href=\"https:\/\/oshwhub.com\/joba\/pkb16x4-atmega32a\">https:\/\/oshwhub.com\/joba\/pkb16x4-atmega32a<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/vial-kb\/vial-qmk\">https:\/\/github.com\/vial-kb\/vial-qmk<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/Oushuwen\/article\/details\/109164466\">https:\/\/blog.csdn.net\/Oushuwen\/article\/details\/109164466<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/williamgavin\/article\/details\/79776654\">https:\/\/blog.csdn.net\/williamgavin\/article\/details\/79776654<\/a><\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/77852801\/stm32f103-switch-i2c-pins\">https:\/\/stackoverflow.com\/questions\/77852801\/stm32f103-switch-i2c-pins<\/a><\/li>\n<li><a href=\"https:\/\/forum.chibios.org\/viewtopic.php?t=5859\">https:\/\/forum.chibios.org\/viewtopic.php?t=5859<\/a><\/li>\n<li><a href=\"https:\/\/electronics.stackexchange.com\/questions\/473721\/stm32f103-i2c-bare-metal-programming-question\">https:\/\/electronics.stackexchange.com\/questions\/473721\/stm32f103-i2c-bare-metal-programming-question<\/a><\/li>\n<li><a href=\"https:\/\/xuanxuanblingbling.github.io\/assets\/attachment\/stm32\/STM32%E4%B8%AD%E6%96%87%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8CV10.pdf\">https:\/\/xuanxuanblingbling.github.io\/assets\/attachment\/stm32\/STM32%E4%B8%AD%E6%96%87%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8CV10.pdf<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u53c2\u8003\u7acb\u521b\u5f00\u6e90\u5e73\u53f0\u7684\u590f\u5929\u5927\u4f6c\uff0c\u505a\u4e86\u4e00\u4e2a\u57fa\u4e8e ATMega32A MCU + Q &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/xujiwei.com\/blog\/2024\/06\/qmk-stm32f103-i2c-remap\/\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":1413,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[402],"tags":[395,413,410,417,386],"_links":{"self":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/1414"}],"collection":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/comments?post=1414"}],"version-history":[{"count":0,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/1414\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/media\/1413"}],"wp:attachment":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/media?parent=1414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/categories?post=1414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/tags?post=1414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}