{"id":774,"date":"2021-04-08T14:26:05","date_gmt":"2021-04-08T14:26:05","guid":{"rendered":"https:\/\/picockpit.com\/raspberry-pi\/?p=774"},"modified":"2023-11-23T02:13:08","modified_gmt":"2023-11-23T02:13:08","slug":"c-extension-for-micropython-on-raspberry-pi-pico","status":"publish","type":"post","link":"https:\/\/picockpit.com\/raspberry-pi\/zh\/c-extension-for-micropython-on-raspberry-pi-pico\/","title":{"rendered":"\u5728Raspberry Pi Pico\u4e0a\u4e3aMicroPython\u63d0\u4f9bC\u8bed\u8a00\u6269\u5c55"},"content":{"rendered":"<p>\u8fd9\u662f\u4e00\u4efd\u5173\u4e8e\u5982\u4f55\u5728Raspberry Pi Pico\u4e0a\u7f16\u5199\u548c\u8fd0\u884cMicroPython\u7684\u57fa\u672cC\u8bed\u8a00\u6269\u5c55\u7684\u6307\u5357\u3002\u6211\u5c06\u4ecb\u7ecd\u6269\u5c55MicroPython\u7684\u539f\u56e0\uff0c\u5982\u4f55\u7f16\u5199\u6269\u5c55\u6a21\u5757\uff0c\u5982\u4f55\u7f16\u8bd1\u4ee5\u53ca\u5982\u4f55\u5728Pico\u4e0a\u5b89\u88c5\u5b83\u3002\u5982\u679c\u4f60\u60f3\u9605\u8bfb\u66f4\u591a\u5173\u4e8e\u8fd9\u4e2a\u4e3b\u9898\u7684\u5185\u5bb9\uff0c\u8bf7\u53c2\u8003 <a href=\"https:\/\/docs.micropython.org\/en\/latest\/develop\/extendingmicropython.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.micropython.org\/en\/latest\/develop\/extendingmicropython.html<\/a><\/p>\n\n\n\n<h2>\u7b80\u4ecb<\/h2>\n<h3>\u4e3a\u4ec0\u4e48\u8981\u6269\u5c55MicroPython\uff1f<\/h3>\n<p>\u4f60\u53ef\u80fd\u60f3\u6269\u5c55MicroPython\uff0c\u8fd9\u53ef\u80fd\u6709\u591a\u79cd\u539f\u56e0\u3002\u7531\u4e8eMicroPython\u662fPython\u7684\u7cbe\u7b80\u7248\uff0c\u5f53\u6d89\u53ca\u5230\u8ba1\u7b97\u91cf\u5927\u7684\u4efb\u52a1\u65f6\uff08\u7c7b\u4f3c\u4e8ePython\uff09\uff0cMicroPython\u7684\u8868\u73b0\u4e0d\u662f\u5f88\u597d\u3002\u53e6\u4e00\u65b9\u9762\uff0cC\u8bed\u8a00\u786e\u5b9e\u5f88\u9002\u5408\u6b64\u7c7b\u4efb\u52a1\u3002Micropython\u7684C\u8bed\u8a00\u6269\u5c55\u4f7f\u4f60\u80fd\u591f\u901a\u8fc7C\u8bed\u8a00\u8fdb\u884c\u8fd9\u4e9b\u8ba1\u7b97\uff0c\u5e76\u5728MicroPython\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u7ed3\u679c\u3002\u8fd9\u53ef\u4ee5\u4f7f\u4e00\u4e9b\u7a0b\u5e8f\u7684\u901f\u5ea6\u63d0\u9ad8\u4e00\u4e2a\u6570\u91cf\u7ea7\u3002<\/p>\n<p>\u7b2c\u4e8c\u4e2a\u539f\u56e0\u53ef\u80fd\u662f\uff0c\u4f60\u60f3\u5728MicroPython\u4e2d\u8fde\u63a5\u4e00\u4e9b\u4f7f\u7528C\u8bed\u8a00API\u7684\u786c\u4ef6\u3002&nbsp;<\/p>\n<h3>MicroPython C\u8bed\u8a00\u6269\u5c55\u7684\u7c7b\u578b<\/h3>\n<p>\u6709\u51e0\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\u6765\u6269\u5c55MicroPython\uff1a\u5916\u90e8C\u6a21\u5757\u548c.py\u6587\u4ef6\u4e2d\u7684\u672c\u5730\u673a\u5668\u4ee3\u7801\u3002<\/p>\n<p>\u8981\u8fd0\u884c\u4e00\u4e2a\u5916\u90e8C\u6a21\u5757\uff0c\u4f60\u9700\u8981\u628a\u5b83\u91cd\u65b0\u7f16\u8bd1\u5230MicroPython\u56fa\u4ef6\u4e2d\u3002\u8fd9\u662f\u4e00\u4e2a\u76f8\u5f53\u590d\u6742\u7684\u8fc7\u7a0b\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u672c\u6307\u5357\u5c06\u91cd\u70b9\u4ecb\u7ecd\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u3002\u5982\u679c\u4f60\u5bf9\u8fd9\u79cd\u65b9\u6cd5\u611f\u5174\u8da3\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u4e9b\u7f51\u9875\u4e0a\u9605\u8bfb\u66f4\u591a\u4fe1\u606f\u3002&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"https:\/\/docs.micropython.org\/en\/latest\/develop\/cmodules.html\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.micropython.org\/en\/latest\/develop\/cmodules.html<\/a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"https:\/\/www.raspberrypi.org\/forums\/viewtopic.php?t=300352\" target=\"_blank\" rel=\"noopener\">https:\/\/www.raspberrypi.org\/forums\/viewtopic.php?t=300352<\/a><\/p>\n<p>.py\u662f\u4e00\u4e2a\u5b58\u50a8\u5df2\u7f16\u8bd1\u7684\u672c\u5730\u673a\u5668\u4ee3\u7801\u7684\u6587\u4ef6\uff0c\u53ef\u4ee5\u52a8\u6001\u94fe\u63a5\u3002\u8fd9\u4f7f\u5f97\u5b83\u66f4\u52a0\u7075\u6d3b\uff0c\u56e0\u4e3a\u4f60\u4e0d\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\u6574\u4e2aMicroPython\u56fa\u4ef6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u5199\u6269\u5c55\u6a21\u5757<\/h2>\n\n\n\n<p>\u7f16\u5199\u6269\u5c55\u6a21\u5757\u662f\u6269\u5c55MicroPython\u7684\u6700\u7b80\u5355\u7684\u90e8\u5206\u3002\u6211\u5c06\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u544a\u8bc9\u4f60\u5982\u4f55\u505a\u3002\u9996\u5148\uff0c\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\uff0c\u540d\u4e3a <em>\u4e8b\u5b9efib<\/em>.\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u7a97\u53e3\uff0ccd\u8fdb\u5165\u65b0\u76ee\u5f55\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\uff0c\u540d\u4e3a <em>\u4e8b\u5b9efib.c<\/em>.\u5982\u679c\u4f60\u5728Dekstop\u4e0b\u7684Raspberry Pi\u4e0a\u521b\u5efa\u4e86\u8be5\u76ee\u5f55\uff0c\u8be5\u547d\u4ee4\u770b\u8d77\u6765\u50cf\u8fd9\u6837\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"cd ~\/Desktop\/factfibtouch factfib.c\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">cd<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">~\/<\/span><span style=\"color: #D8DEE9\">Desktop<\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">factfib<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">touch<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">factfib<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9\">c<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u5f00\u653e\u5f0f <span style=\"color: #008000;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\"><em>\u4e8b\u5b9efib.c<\/em><\/span><span style=\"color: #000000;\"> \u5728\u4f60\u559c\u6b22\u7684\u6587\u672c\u7f16\u8f91\u5668\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/span><\/span><\/span><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#include &quot;py\/dynruntime.hSTATIC mp_int_t factorial_helper(mp_int_t x) {   if (x < 1) {      return 1;   }   return x*factorial_helper(x-1);}STATIC mp_obj_t factorial(mp_obj_t x_obj) {   mp_int_t x = mp_obj_get_int(x_obj);   mp_int_t rslt = factorial_helper(x);   return rslt;}STATIC MP_DEFINE_CONST_FUN_OBJ_1(factorial_obj, factorial);STATIC mp_int_t fibonacci_helper(mp_int_t x) {   if (x <= 0) {      return 0;   }   else if (x == 1) {      return 1;   }   else {      return (fibonacci_helper(x-1) + fibonacci_helper(x-2));   }}STATIC mp_obj_t fibonacci(mp_obj_t x_obj) {   mp_int_t x = mp_obj_get_int(x_obj);   mp_int_t rslt = fibonacci_helper(x);   return mp_obj_new_int(rslt);}STATIC MP_DEFINE_CONST_FUN_OBJ_1(fibonacci_obj, fibonacci);mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) {   MP_DYNRUNTIME_INIT_ENTRY   mp_store_global(MP_QSTR_factorial, MP_OBJ_FROM_PTR(&amp;factorial_obj));   mp_store_global(MP_QSTR_fibonacci, MP_OBJ_FROM_PTR(&amp;fibonacci_obj));   MP_DYNRUNTIME_INIT_EXIT}\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9FF\">#<\/span><span style=\"color: #D8DEE9\">include<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">py\/dynruntime.<\/span><span style=\"color: #D8DEE9\">h<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">STATIC<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">factorial_helper<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> (<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">      <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #88C0D0\">factorial_helper<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">STATIC<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">mp_obj_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">factorial<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">mp_obj_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">x_obj<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">mp_obj_get_int<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">x_obj<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">rslt<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">factorial_helper<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">rslt<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">STATIC<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">MP_DEFINE_CONST_FUN_OBJ_1<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">factorial_obj<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">factorial<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">STATIC<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">fibonacci_helper<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> (<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&lt;=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">      <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #81A1C1\">else<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> (<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">==<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">      <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #81A1C1\">else<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">      <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> (<\/span><span style=\"color: #88C0D0\">fibonacci_helper<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">fibonacci_helper<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #B48EAD\">2<\/span><span style=\"color: #D8DEE9FF\">))<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">STATIC<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">mp_obj_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">fibonacci<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">mp_obj_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">x_obj<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">mp_obj_get_int<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">x_obj<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #D8DEE9\">mp_int_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">rslt<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">fibonacci_helper<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">x<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">mp_obj_new_int<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">rslt<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">STATIC<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">MP_DEFINE_CONST_FUN_OBJ_1<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">fibonacci_obj<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">fibonacci<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">mp_obj_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">mpy_init<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">mp_obj_fun_bc_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9\">self<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">size_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">n_args<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">size_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">n_kw<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">mp_obj_t<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9\">args<\/span><span style=\"color: #D8DEE9FF\">) <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #D8DEE9\">MP_DYNRUNTIME_INIT_ENTRY<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #88C0D0\">mp_store_global<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">MP_QSTR_factorial<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">MP_OBJ_FROM_PTR<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #81A1C1\">&amp;<\/span><span style=\"color: #D8DEE9\">factorial_obj<\/span><span style=\"color: #D8DEE9FF\">))<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #88C0D0\">mp_store_global<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">MP_QSTR_fibonacci<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">MP_OBJ_FROM_PTR<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #81A1C1\">&amp;<\/span><span style=\"color: #D8DEE9\">fibonacci_obj<\/span><span style=\"color: #D8DEE9FF\">))<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">   <\/span><span style=\"color: #D8DEE9\">MP_DYNRUNTIME_INIT_EXIT<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u8ba9\u6211\u89e3\u91ca\u4e00\u4e0b\u4e0a\u9762\u7684\u4ee3\u7801\u3002\u5728MicroPython\u548cPython\u4e2d\uff0c\u6bcf\u4e2a\u53d8\u91cf\u90fd\u662f\u4e00\u4e2a\u5bf9\u8c61\u3002\u56e0\u6b64\u5728C\u8bed\u8a00\u4e2d\uff0c\u6211\u4eec\u628a\u5b83\u4eec\u8868\u793a\u4e3a <em>mp_obj_t<\/em>.\u4f46\u662fC\u7a0b\u5e8f\u53ea\u80fd\u4f7f\u7528C\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u6211\u4eec\u9700\u8981\u5c06\u5bf9\u8c61\u8f6c\u5316\u4e3aC\u7c7b\u578b\u3002\u8fd9\u5c31\u662f\u6240\u8c13\u7684Marshalling\uff0cMicroPython\u63d0\u4f9b\u4e86\u4ece\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u63d0\u53d6\u4efb\u4f55C\u7c7b\u578b\u7684\u51fd\u6570\u3002<\/p>\n\n\n\n<p>\u5965\u5229\u5f17-\u7f57\u5e03\u68ee\u7684\u8fd9\u4e2a\u7f51\u9875\u5bf9\u6cd5\u8b66\u5de5\u4f5c\u5f88\u6709\u5e2e\u52a9\u3002 <a rel=\"noreferrer noopener\" href=\"https:\/\/mpy-c-gen.oliverrobson.tech\/\" target=\"_blank\">https:\/\/mpy-c-gen.oliverrobson.tech\/<\/a>.\u6b64\u5916\uff0c\u4f60\u53ef\u4ee5\u5728MicroPython\u6587\u6863\u4e2d\u627e\u5230\u8c03\u96c6\u7684\u4f8b\u5b50 <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.micropython.org\/en\/latest\/develop\/natmod.html\" target=\"_blank\">https:\/\/docs.micropython.org\/en\/latest\/develop\/natmod.html<\/a>.\u5982\u679c\u4f60\u9700\u8981\u8fdb\u4e00\u6b65\u89e3\u91ca\uff0c\u6211\u5efa\u8bae\u4f60\u9605\u8bfb\u8fd9\u7bc7\u6587\u7ae0\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6784\u5efa\u6269\u5c55<\/h2>\n\n\n\n<p>\u6211\u4eec\u901a\u8fc7\u4f7f\u7528Makefile\u5c06\u6269\u5c55\u7a0b\u5e8f\u6784\u5efa\u6210\u4e00\u4e2a.mpy\u6587\u4ef6\u3002\u4f46\u6211\u4eec\u9700\u8981\u5148\u8bbe\u7f6e\u4e00\u4e9b\u4e1c\u897f\u3002\u786e\u4fdd\u4f60\u7684\u7ec8\u7aef\u4ecd\u7136\u6253\u5f00\u5728 <em>\u4e8b\u5b9efib<\/em> \u76ee\u5f55\u3002\u7136\u540e\u514b\u9686MicroPython\u7684GitHub\u4ed3\u5e93\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"sudo apt-get install build-essential libreadline-dev libffi-dev git pkg-config gcc-arm-none-eabi libnewlib-arm-none-eabigit clone --recurse-submodules\u00a0https:\/\/github.com\/micropython\/micropython.gitpip3\u00a0install\u00a0'pyelftools&gt;=0.25'\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">sudo<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">apt<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">get<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">install<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">build<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">essential<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">libreadline<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">dev<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">libffi<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">dev<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">git<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">pkg<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">config<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">gcc<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">arm<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">none<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">eabi<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">libnewlib<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">arm<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">none<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">eabi<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">git<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">clone<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">--<\/span><span style=\"color: #D8DEE9\">recurse<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">submodules<\/span><span style=\"color: #D8DEE9FF\">\u00a0https<\/span><span style=\"color: #ECEFF4\">:<\/span><span style=\"color: #616E88\">\/\/github.com\/micropython\/micropython.git<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">pip3<\/span><span style=\"color: #D8DEE9FF\">\u00a0<\/span><span style=\"color: #D8DEE9\">install<\/span><span style=\"color: #D8DEE9FF\">\u00a0<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">pyelftools&gt;=0.25<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u8fd9\u4e9b\u5b89\u88c5\u4f1a\u82b1\u8d39\u4e00\u4e9b\u65f6\u95f4\uff0c\u5982\u679c\u4f60\u60f3\u8282\u7701\u65f6\u95f4\u5e76\u4e14\u77e5\u9053\u81ea\u5df1\u5728\u505a\u4ec0\u4e48\uff0c\u4f60\u53ea\u9700\u8981\u4ecemicropython\u4ed3\u5e93\u514b\u9686\/py\u548c\/tools\u76ee\u5f55\uff0c\u7136\u540e\u628a\u5b83\u4eec\u653e\u5728\u4e00\u4e2a <em>\u5fae\u8f6f<\/em> \u6587\u4ef6\u5939\u5185\u7684&nbsp;<em>\u4e8b\u5b9efib<\/em> \u6587\u4ef6\u5939\uff08\u8df3\u8fc7\u7b2c\u4e8c\u4e2a\u547d\u4ee4\uff09\u3002<\/p>\n\n\n\n<p>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u8fd9\u6bb5\u65f6\u95f4\u6765\u7f16\u5199Makefile\u3002\u53ea\u9700\u6267\u884c<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"touch Makefile\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">touch<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">Makefile<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u5e76\u5728\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u6253\u5f00\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"MPY_DIR = micropythonMOD = factfibSRC = factfib.cARCH = armv7minclude $(MPY_DIR)\/py\/dynruntime.mk\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">MPY_DIR<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">micropython<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">MOD<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">factfib<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">SRC<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">factfib<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9\">c<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">ARCH<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">armv7m<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">include<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">$<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">MPY_DIR<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">py<\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">dynruntime<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9\">mk<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u4f60\u53ef\u80fd\u5df2\u7ecf\u6ce8\u610f\u5230\uff0c\u6211\u4eec\u5c06 <em>ARCH <\/em>\u53d8\u91cf\u4e3a <em>armv7m<\/em> \u867d\u7136\u76ae\u514b\u662f <em>armv6m<\/em>.\u6211\u4eec\u5fc5\u987b\u8fd9\u6837\u505a\uff0c\u56e0\u4e3a <em>armv6m<\/em> \u67b6\u6784\uff08\u5728\u6211\u5199\u8fd9\u7bc7\u6587\u7ae0\u7684\u65f6\u5019\uff09\u4e0d\u652f\u6301 <em>dynruntime.mk<\/em> \u5de5\u5177\u3002<\/p>\n\n\n\n<p>\u4f46\u5e78\u8fd0\u7684\u662f\uff0c\u6211\u4eec\u4ecd\u7136\u53ef\u4ee5\u4e3aPico\u7f16\u8bd1\u4e00\u4e2a\u6709\u6548\u7684\u6269\u5c55\u3002\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539 <em>dynruntime.mk <\/em>\u6587\u4ef6\uff0c\u5b83\u5e94\u8be5\u4f4d\u4e8e <em>micropython\/py\/dynruntime.mk\u3002&nbsp;<\/em>\u6253\u5f00\u5b83\u5e76\u5728armv7m\u7684\u67b6\u6784\u914d\u7f6e\u4e0b\u627e\u5230CFLAGS\u53d8\u91cf\uff08\u5e94\u8be5\u662f\u7b2c64\u884c\uff09\u3002\u6539\u53d8&nbsp;<em>-mcpu=cortex-m3<\/em> \u81f3&nbsp;<em>-mcpu=cortex-m0<\/em> \u5e76\u4fdd\u5b58\u8be5\u6587\u4ef6\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"86\" src=\"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/04\/dynruntimeChange-300x86.png\" alt=\"\u5c06-mcpu=cortex-m3\u6539\u4e3a-mcpu=cortex-m0\" class=\"wp-image-780\" style=\"width:648px;height:186px\" srcset=\"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/04\/dynruntimeChange-300x86.png 300w, https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/04\/dynruntimeChange-768x219.png 768w, https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/04\/dynruntimeChange.png 946w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n<\/div>\n\n\n<p>\u7136\u540e\u5728\u4e00\u5207\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u6267\u884c<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"make\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">make<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u548c&nbsp;<em>\u4e8b\u5b9efib.mpy<\/em> \u6587\u4ef6\u5c06\u88ab\u521b\u5efa\u3002<\/p>\n\n\n\n<h2>\u5b89\u88c5\u5e76\u6d4b\u8bd5\u8be5\u6269\u5c55<\/h2>\n\n\n\n<p>\u6700\u540e\u4e00\u6b65\u662f\u5b89\u88c5\u548c\u6d4b\u8bd5\u3002\u4e3a\u6b64\u6211\u4eec\u5229\u7528Micropython\u5728Raspberry Pi Pico\u4e0a\u521b\u5efa\u7684\u6587\u4ef6\u7cfb\u7edf\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u7528MicroPython\u56fa\u4ef6\u95ea\u8fc7Pico\u3002\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528Thonny IDE\uff08\u9884\u88c5\u5728Raspbian\/Raspberry Pi OS\u4e0a\uff09\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u6ca1\u6709\u4f7f\u7528Raspberry Pi\u4e3a\u4f60\u7684Pico\u7f16\u7a0b\uff0c\u6216\u8005\u4f60\u4ee5\u524d\u4ece\u672a\u5728Pico\u4e0a\u4f7f\u7528\u8fc7MicroPython\uff0c\u90a3\u4e48\u8bf7\u53c2\u8003Raspberry Pi\u7684MicroPython\u5165\u95e8\u6307\u5357\u3002 <a href=\"https:\/\/www.raspberrypi.org\/documentation\/rp2040\/getting-started\/#getting-started-with-micropython\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.raspberrypi.org\/documentation\/rp2040\/getting-started\/#getting-started-with-micropython<\/a><\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fWindows\uff0c\u4f60\u5e94\u8be5\u770b\u770b\u8fd9\u7bc7\u5173\u4e8eRaspberry Pi Pico\u548cMicroPython\u5728Windows\u4e0a\u7684\u535a\u6587\u3002 <a href=\"https:\/\/picockpit.com\/raspberry-pi\/raspberry-pi-pico-and-micropython-on-windows\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/picockpit.com\/raspberry-pi\/raspberry-pi-pico-and-micropython-on-windows\/<\/a><\/p>\n\n\n\n<p>\u5728\u4f60\u7528MicroPython\u56fa\u4ef6\u5237\u65b0\u4f60\u7684Pico\u540e\uff0c\u5173\u95edThonny\uff0c\u5e76\u5b89\u88c5rshell\u3002\u6211\u4eec\u4f7f\u7528rshell\u6765\u4ece\u547d\u4ee4\u884c\u8bbf\u95ee\u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"sudo pip3 install rshellrshell --version\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">sudo<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">pip3<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">install<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">rshell<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">rshell<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">--<\/span><span style=\"color: #D8DEE9\">version<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u5982\u679c\u4e00\u5207\u8bbe\u7f6e\u6b63\u786e\uff0c\u8fd9\u5c06\u6253\u5370\u51farhsell\u7248\u672c\u3002\u7136\u540e\u62d4\u6389pico\u7684\u63d2\u5934\uff0c\u518d\u63d2\u4e0a\uff08\u4e0d\u6309BOOTSEL\u6309\u94ae\uff09\uff0c\u4ee5\u786e\u4fdd\u6ca1\u6709\u4efb\u4f55\u4e1c\u897f\u5728\u8bd5\u56fe\u8bbf\u95ee\u6587\u4ef6\u7cfb\u7edf\u3002\u73b0\u5728\u6211\u4eec\u9700\u8981\u6267\u884c<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"rshell -p \/dev\/ttyACM0 --buffer-size 512cp factfib.mpy \/pyboard\/factfib.mpy\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">rshell<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">p<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">dev<\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">ttyACM0<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">--<\/span><span style=\"color: #D8DEE9\">buffer<\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">size<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">512<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">cp<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">factfib<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9\">mpy<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">pyboard<\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">factfib<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9\">mpy<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u4e3a\u4e86\u6d4b\u8bd5\u5b89\u88c5\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528rshell\u6216Thonny IDE\u6765\u4fdd\u5b58\u4f60\u7684 <em>.py<\/em> \u6587\u4ef6\uff0c\u4f46\u6211\u5c06\u6f14\u793a\u5982\u4f55\u5728minicom\u4e0a\u4f7f\u7528MicroPython\u89e3\u91ca\u5668\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u9996\u5148\u6309&nbsp;<em>Ctrl+c<\/em> \u6765\u79bb\u5f00rshell\uff0c\u7136\u540e\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5b89\u88c5minicom<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"sudo apt install minicom\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">sudo<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">apt<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">install<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">minicom<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u8bbf\u95eePicos REPL\uff08\u8bfb\u53d6-\u8bc4\u4f30-\u6253\u5370\u5faa\u73af\uff09\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"minicom -o -D \/dev\/ttyACM0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #D8DEE9\">minicom<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">o<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9\">D<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">dev<\/span><span style=\"color: #81A1C1\">\/<\/span><span style=\"color: #D8DEE9\">ttyACM0<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u4e09\u4e2a\u7ed3\u5c3e\u7684\u89d2\u62ec\u53f7&gt;&gt;\u8868\u793aMicroPython\u89e3\u91ca\u5668\u6b63\u5728\u8fd0\u884c\u3002\u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u5bfc\u5165\u6211\u4eec\u7684\u6269\u5c55\u5e76\u50cf\u5f80\u5e38\u4e00\u6837\u4f7f\u7528\u5b83\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewbox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"&gt;&gt;&gt; import factfib as ff&gt;&gt;&gt; ff.factorial(5)&gt;&gt;&gt; 120&gt;&gt;&gt; ff.fibonacci(7)&gt;&gt;&gt; 13\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u62f7\u8d1d\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code data-no-translation=\"\"><span class=\"line\"><span style=\"color: #81A1C1\">&gt;&gt;&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">import<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">factfib<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">as<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #8FBCBB\">ff<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">&gt;&gt;&gt; <\/span><span style=\"color: #8FBCBB\">ff<\/span><span style=\"color: #D8DEE9FF\">.<\/span><span style=\"color: #8FBCBB\">factorial<\/span><span style=\"color: #D8DEE9FF\">(5)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">&gt;&gt;&gt; 120<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">&gt;&gt;&gt; <\/span><span style=\"color: #8FBCBB\">ff<\/span><span style=\"color: #D8DEE9FF\">.<\/span><span style=\"color: #8FBCBB\">fibonacci<\/span><span style=\"color: #D8DEE9FF\">(7)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">&gt;&gt;&gt; 13<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u606d\u559c\u4f60\uff01\u4f60\u5df2\u7ecf\u4e3aPico\u521b\u5efa\u4e86\u7b2c\u4e00\u4e2aMicroPython C\u8bed\u8a00\u6269\u5c55\uff01\u4f60\u5df2\u7ecf\u4e3aPico\u521b\u5efa\u4e86\u4f60\u7684\u7b2c\u4e00\u4e2aMicroPython C\u8bed\u8a00\u6269\u5c55!\u4e0b\u4e00\u6b65\u662f\u5b66\u4e60\u5982\u4f55\u7f16\u5199\u548c\u7f16\u8bd1\u66f4\u590d\u6742\u7684\u6a21\u5757\u3002\u4e00\u4e2a\u597d\u7684\u5f00\u59cb\u662f\u6d4b\u8bd5\u5217\u8868\u548c\u6570\u636e\u96c6\u7684\u5de5\u4f5c\u65b9\u5f0f\uff08\u89c1\u4e0a\u9762\u7684 Marshalling \u7f51\u9875\uff09\u3002 <\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u5bf9\u8fd9\u4e2a\u5e16\u5b50\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u6b22\u8fce\u5199\u4e0b\u8bc4\u8bba\u3002<\/p>\n<div class=\"shariff shariff-align-center shariff-widget-align-left shariff-buttonstretch\"><ul class=\"shariff-buttons theme-white orientation-horizontal buttonsize-medium\"><li class=\"shariff-button twitter shariff-nocustomcolor\" style=\"background-color:#595959\"><a href=\"https:\/\/twitter.com\/share?url=https%3A%2F%2Fpicockpit.com%2Fraspberry-pi%2Fzh%2Fc-extension-for-micropython-on-raspberry-pi-pico%2F&text=C%20extension%20for%20MicroPython%20on%20Raspberry%20Pi%20Pico\" title=\"\u5728 X \u4e0a\u5206\u4eab\" aria-label=\"\u5728 X \u4e0a\u5206\u4eab\" role=\"button\" rel=\"noopener nofollow\" class=\"shariff-link\" style=\"; background-color:#000; color:#000\" target=\"_blank\"><span class=\"shariff-icon\" style=\"fill:#000\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 24 24\"><path fill=\"#000\" d=\"M14.258 10.152L23.176 0h-2.113l-7.747 8.813L7.133 0H0l9.352 13.328L0 23.973h2.113l8.176-9.309 6.531 9.309h7.133zm-2.895 3.293l-.949-1.328L2.875 1.56h3.246l6.086 8.523.945 1.328 7.91 11.078h-3.246zm0 0\"\/><\/svg><\/span><span class=\"shariff-text\" style=\"color:#000\">\u5206\u4eab<\/span>&nbsp;<\/a><\/li><li class=\"shariff-button facebook shariff-nocustomcolor\" style=\"background-color:#4273c8\"><a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fpicockpit.com%2Fraspberry-pi%2Fzh%2Fc-extension-for-micropython-on-raspberry-pi-pico%2F\" title=\"\u5728Facebook\u4e0a\u5206\u4eab\" aria-label=\"\u5728Facebook\u4e0a\u5206\u4eab\" role=\"button\" rel=\"nofollow\" class=\"shariff-link\" style=\"; background-color:#3b5998; color:#3b5998\" target=\"_blank\"><span class=\"shariff-icon\" style=\"fill:#3b5998\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 18 32\"><path fill=\"#3b5998\" d=\"M17.1 0.2v4.7h-2.8q-1.5 0-2.1 0.6t-0.5 1.9v3.4h5.2l-0.7 5.3h-4.5v13.6h-5.5v-13.6h-4.5v-5.3h4.5v-3.9q0-3.3 1.9-5.2t5-1.8q2.6 0 4.1 0.2z\"\/><\/svg><\/span><span class=\"shariff-text\" style=\"color:#3b5998\">\u5206\u4eab<\/span>&nbsp;<\/a><\/li><li class=\"shariff-button telegram shariff-nocustomcolor\" style=\"background-color:#4084A6\"><a href=\"https:\/\/telegram.me\/share\/url?url=https%3A%2F%2Fpicockpit.com%2Fraspberry-pi%2Fzh%2Fc-extension-for-micropython-on-raspberry-pi-pico%2F&text=C%20extension%20for%20MicroPython%20on%20Raspberry%20Pi%20Pico\" title=\"\u5728\u7535\u62a5\u4e0a\u5206\u4eab\" aria-label=\"\u5728\u7535\u62a5\u4e0a\u5206\u4eab\" role=\"button\" rel=\"noopener nofollow\" class=\"shariff-link\" style=\"; background-color:#0088cc; color:#0088cc\" target=\"_blank\"><span class=\"shariff-icon\" style=\"fill:#0088cc\"><svg width=\"32px\" height=\"20px\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 32 32\"><path fill=\"#0088cc\" d=\"M30.8 6.5l-4.5 21.4c-.3 1.5-1.2 1.9-2.5 1.2L16.9 24l-3.3 3.2c-.4.4-.7.7-1.4.7l.5-7L25.5 9.2c.6-.5-.1-.8-.9-.3l-15.8 10L2 16.7c-1.5-.5-1.5-1.5.3-2.2L28.9 4.3c1.3-.5 2.3.3 1.9 2.2z\"\/><\/svg><\/span><span class=\"shariff-text\" style=\"color:#0088cc\">\u5206\u4eab<\/span>&nbsp;<\/a><\/li><li class=\"shariff-button reddit shariff-nocustomcolor\" style=\"background-color:#ff5700\"><a href=\"https:\/\/www.reddit.com\/submit?url=https%3A%2F%2Fpicockpit.com%2Fraspberry-pi%2Fzh%2Fc-extension-for-micropython-on-raspberry-pi-pico%2F\" title=\"\u5206\u4eab\u81f3Reddit\" aria-label=\"\u5206\u4eab\u81f3Reddit\" role=\"button\" rel=\"noopener nofollow\" class=\"shariff-link\" style=\"; background-color:#ff4500; color:#ff4500\" target=\"_blank\"><span class=\"shariff-icon\" style=\"fill:#ff4500\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 512 512\"><path fill=\"#ff4500\" d=\"M440.3 203.5c-15 0-28.2 6.2-37.9 15.9-35.7-24.7-83.8-40.6-137.1-42.3L293 52.3l88.2 19.8c0 21.6 17.6 39.2 39.2 39.2 22 0 39.7-18.1 39.7-39.7s-17.6-39.7-39.7-39.7c-15.4 0-28.7 9.3-35.3 22l-97.4-21.6c-4.9-1.3-9.7 2.2-11 7.1L246.3 177c-52.9 2.2-100.5 18.1-136.3 42.8-9.7-10.1-23.4-16.3-38.4-16.3-55.6 0-73.8 74.6-22.9 100.1-1.8 7.9-2.6 16.3-2.6 24.7 0 83.8 94.4 151.7 210.3 151.7 116.4 0 210.8-67.9 210.8-151.7 0-8.4-.9-17.2-3.1-25.1 49.9-25.6 31.5-99.7-23.8-99.7zM129.4 308.9c0-22 17.6-39.7 39.7-39.7 21.6 0 39.2 17.6 39.2 39.7 0 21.6-17.6 39.2-39.2 39.2-22 .1-39.7-17.6-39.7-39.2zm214.3 93.5c-36.4 36.4-139.1 36.4-175.5 0-4-3.5-4-9.7 0-13.7 3.5-3.5 9.7-3.5 13.2 0 27.8 28.5 120 29 149 0 3.5-3.5 9.7-3.5 13.2 0 4.1 4 4.1 10.2.1 13.7zm-.8-54.2c-21.6 0-39.2-17.6-39.2-39.2 0-22 17.6-39.7 39.2-39.7 22 0 39.7 17.6 39.7 39.7-.1 21.5-17.7 39.2-39.7 39.2z\"\/><\/svg><\/span><span class=\"shariff-text\" style=\"color:#ff4500\">\u5206\u4eab<\/span>&nbsp;<\/a><\/li><\/ul><\/div>","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4e00\u4efd\u5173\u4e8e\u5982\u4f55\u5728Raspberry Pi Pico\u4e0a\u7f16\u5199\u548c\u8fd0\u884cMicroPython\u7684\u57fa\u672cC\u8bed\u8a00\u6269\u5c55\u7684\u6307\u5357\u3002\u6211\u5c06\u4ecb\u7ecd\u6269\u5c55MicroPython\u7684\u539f\u56e0\uff0c\u5982\u4f55\u7f16\u5199\u6269\u5c55\u6a21\u5757\uff0c\u5982\u4f55\u7f16\u8bd1\u4ee5\u53ca\u5982\u4f55\u5728Pico\u4e0a\u5b89\u88c5\u5b83\u3002\u5982\u679c\u4f60\u60f3\u9605\u8bfb\u66f4\u591a\u5173\u4e8e\u8fd9\u4e2a\u4e3b\u9898\u7684\u5185\u5bb9\uff0c...<\/p>","protected":false},"author":3,"featured_media":679,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1193,10],"tags":[964,19,756,477,18,963,606,14,11,486,447,476,187,17],"class_list":["post-774","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-raspberry-pi-pico","tag-bash","tag-c","tag-c-c","tag-circuitpython","tag-extension","tag-fibonacci","tag-linux","tag-micropython","tag-pico","tag-project","tag-projects","tag-python","tag-raspberry-pi","tag-raspberrypi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C extension for MicroPython on Raspberry Pi Pico | PiCockpit<\/title>\n<meta name=\"description\" content=\"Guide on how to write and run a C extension for MicroPython on the Raspberry Pi Pico. This guide is suited for beginners and experts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/picockpit.com\/raspberry-pi\/zh\/c-extension-for-micropython-on-raspberry-pi-pico\/\" \/>\n<meta property=\"og:locale\" content=\"zh_HK\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C extension for MicroPython on Raspberry Pi Pico | PiCockpit\" \/>\n<meta property=\"og:description\" content=\"Guide on how to write and run a C extension for MicroPython on the Raspberry Pi Pico. This guide is suited for beginners and experts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/picockpit.com\/raspberry-pi\/zh\/c-extension-for-micropython-on-raspberry-pi-pico\/\" \/>\n<meta property=\"og:site_name\" content=\"PiCockpit\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pi3gshop\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-08T14:26:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-23T02:13:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/01\/PICO-BOARD-TOP-WHITE.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"1143\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nathan Busler\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pi3g\" \/>\n<meta name=\"twitter:site\" content=\"@pi3g\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nathan Busler\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u8a08\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/\"},\"author\":{\"name\":\"Nathan Busler\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#\\\/schema\\\/person\\\/e38fef75134e5e54175b2615a8c3eb47\"},\"headline\":\"C extension for MicroPython on Raspberry Pi Pico\",\"datePublished\":\"2021-04-08T14:26:05+00:00\",\"dateModified\":\"2023-11-23T02:13:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/\"},\"wordCount\":1089,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/PICO-BOARD-TOP-WHITE.jpg\",\"keywords\":[\"bash\",\"C\",\"c\\\/c++\",\"circuitpython\",\"extension\",\"fibonacci\",\"linux\",\"microPython\",\"Pico\",\"project\",\"Projects\",\"python\",\"Raspberry Pi\",\"RaspberryPi\"],\"articleSection\":[\"Python\",\"Raspberry Pi Pico\"],\"inLanguage\":\"zh-HK\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/\",\"url\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/\",\"name\":\"C extension for MicroPython on Raspberry Pi Pico | PiCockpit\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/PICO-BOARD-TOP-WHITE.jpg\",\"datePublished\":\"2021-04-08T14:26:05+00:00\",\"dateModified\":\"2023-11-23T02:13:08+00:00\",\"description\":\"Guide on how to write and run a C extension for MicroPython on the Raspberry Pi Pico. This guide is suited for beginners and experts.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#breadcrumb\"},\"inLanguage\":\"zh-HK\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-HK\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#primaryimage\",\"url\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/PICO-BOARD-TOP-WHITE.jpg\",\"contentUrl\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/PICO-BOARD-TOP-WHITE.jpg\",\"width\":1600,\"height\":1143,\"caption\":\"raspberry pi pico\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/c-extension-for-micropython-on-raspberry-pi-pico\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/category\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"C extension for MicroPython on Raspberry Pi Pico\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#website\",\"url\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/\",\"name\":\"PiCockpit\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-HK\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#organization\",\"name\":\"PiCockpit.com\",\"url\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-HK\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Screenshot-from-2023-07-24-15-01-24.png\",\"contentUrl\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Screenshot-from-2023-07-24-15-01-24.png\",\"width\":1165,\"height\":283,\"caption\":\"PiCockpit.com\"},\"image\":{\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/pi3gshop\",\"https:\\\/\\\/x.com\\\/pi3g\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/#\\\/schema\\\/person\\\/e38fef75134e5e54175b2615a8c3eb47\",\"name\":\"Nathan Busler\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-HK\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93fef66631dac0f47ce2c90f774cd4e4fe44028ea5266602e20fbf246f7d14f9?s=96&d=blank&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93fef66631dac0f47ce2c90f774cd4e4fe44028ea5266602e20fbf246f7d14f9?s=96&d=blank&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93fef66631dac0f47ce2c90f774cd4e4fe44028ea5266602e20fbf246f7d14f9?s=96&d=blank&r=g\",\"caption\":\"Nathan Busler\"},\"sameAs\":[\"https:\\\/\\\/buyzero.de\"],\"url\":\"https:\\\/\\\/picockpit.com\\\/raspberry-pi\\\/zh\\\/author\\\/nathan\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5728 Raspberry Pi Pico | PiCockpit \u4e0a\u4f7f\u7528 MicroPython \u7684 C \u8bed\u8a00\u6269\u5c55","description":"\u5173\u4e8e\u5982\u4f55\u5728Raspberry Pi Pico\u4e0a\u7f16\u5199\u548c\u8fd0\u884cMicroPython\u7684C\u8bed\u8a00\u6269\u5c55\u7684\u6307\u5357\u3002\u672c\u6307\u5357\u9002\u5408\u4e8e\u521d\u5b66\u8005\u548c\u4e13\u5bb6\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/picockpit.com\/raspberry-pi\/zh\/c-extension-for-micropython-on-raspberry-pi-pico\/","og_locale":"zh_HK","og_type":"article","og_title":"C extension for MicroPython on Raspberry Pi Pico | PiCockpit","og_description":"Guide on how to write and run a C extension for MicroPython on the Raspberry Pi Pico. This guide is suited for beginners and experts.","og_url":"https:\/\/picockpit.com\/raspberry-pi\/zh\/c-extension-for-micropython-on-raspberry-pi-pico\/","og_site_name":"PiCockpit","article_publisher":"https:\/\/www.facebook.com\/pi3gshop","article_published_time":"2021-04-08T14:26:05+00:00","article_modified_time":"2023-11-23T02:13:08+00:00","og_image":[{"width":1600,"height":1143,"url":"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/01\/PICO-BOARD-TOP-WHITE.jpg","type":"image\/jpeg"}],"author":"Nathan Busler","twitter_card":"summary_large_image","twitter_creator":"@pi3g","twitter_site":"@pi3g","twitter_misc":{"\u4f5c\u8005":"Nathan Busler","\u9810\u8a08\u95b1\u8b80\u6642\u9593":"5 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#article","isPartOf":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/"},"author":{"name":"Nathan Busler","@id":"https:\/\/picockpit.com\/raspberry-pi\/#\/schema\/person\/e38fef75134e5e54175b2615a8c3eb47"},"headline":"C extension for MicroPython on Raspberry Pi Pico","datePublished":"2021-04-08T14:26:05+00:00","dateModified":"2023-11-23T02:13:08+00:00","mainEntityOfPage":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/"},"wordCount":1089,"commentCount":8,"publisher":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/#organization"},"image":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#primaryimage"},"thumbnailUrl":"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/01\/PICO-BOARD-TOP-WHITE.jpg","keywords":["bash","C","c\/c++","circuitpython","extension","fibonacci","linux","microPython","Pico","project","Projects","python","Raspberry Pi","RaspberryPi"],"articleSection":["Python","Raspberry Pi Pico"],"inLanguage":"zh-HK","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/","url":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/","name":"\u5728 Raspberry Pi Pico | PiCockpit \u4e0a\u4f7f\u7528 MicroPython \u7684 C \u8bed\u8a00\u6269\u5c55","isPartOf":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/#website"},"primaryImageOfPage":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#primaryimage"},"image":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#primaryimage"},"thumbnailUrl":"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/01\/PICO-BOARD-TOP-WHITE.jpg","datePublished":"2021-04-08T14:26:05+00:00","dateModified":"2023-11-23T02:13:08+00:00","description":"\u5173\u4e8e\u5982\u4f55\u5728Raspberry Pi Pico\u4e0a\u7f16\u5199\u548c\u8fd0\u884cMicroPython\u7684C\u8bed\u8a00\u6269\u5c55\u7684\u6307\u5357\u3002\u672c\u6307\u5357\u9002\u5408\u4e8e\u521d\u5b66\u8005\u548c\u4e13\u5bb6\u3002","breadcrumb":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#breadcrumb"},"inLanguage":"zh-HK","potentialAction":[{"@type":"ReadAction","target":["https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/"]}]},{"@type":"ImageObject","inLanguage":"zh-HK","@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#primaryimage","url":"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/01\/PICO-BOARD-TOP-WHITE.jpg","contentUrl":"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2021\/01\/PICO-BOARD-TOP-WHITE.jpg","width":1600,"height":1143,"caption":"raspberry pi pico"},{"@type":"BreadcrumbList","@id":"https:\/\/picockpit.com\/raspberry-pi\/c-extension-for-micropython-on-raspberry-pi-pico\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/picockpit.com\/raspberry-pi\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/picockpit.com\/raspberry-pi\/category\/python\/"},{"@type":"ListItem","position":3,"name":"C extension for MicroPython on Raspberry Pi Pico"}]},{"@type":"WebSite","@id":"https:\/\/picockpit.com\/raspberry-pi\/#website","url":"https:\/\/picockpit.com\/raspberry-pi\/","name":"\u7801\u5934","description":"","publisher":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/picockpit.com\/raspberry-pi\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-HK"},{"@type":"Organization","@id":"https:\/\/picockpit.com\/raspberry-pi\/#organization","name":"PiCockpit.com","url":"https:\/\/picockpit.com\/raspberry-pi\/","logo":{"@type":"ImageObject","inLanguage":"zh-HK","@id":"https:\/\/picockpit.com\/raspberry-pi\/#\/schema\/logo\/image\/","url":"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2023\/07\/Screenshot-from-2023-07-24-15-01-24.png","contentUrl":"https:\/\/picockpit.com\/raspberry-pi\/wp-content\/uploads\/2023\/07\/Screenshot-from-2023-07-24-15-01-24.png","width":1165,"height":283,"caption":"PiCockpit.com"},"image":{"@id":"https:\/\/picockpit.com\/raspberry-pi\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/pi3gshop","https:\/\/x.com\/pi3g"]},{"@type":"Person","@id":"https:\/\/picockpit.com\/raspberry-pi\/#\/schema\/person\/e38fef75134e5e54175b2615a8c3eb47","name":"Nathan Busler","image":{"@type":"ImageObject","inLanguage":"zh-HK","@id":"https:\/\/secure.gravatar.com\/avatar\/93fef66631dac0f47ce2c90f774cd4e4fe44028ea5266602e20fbf246f7d14f9?s=96&d=blank&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/93fef66631dac0f47ce2c90f774cd4e4fe44028ea5266602e20fbf246f7d14f9?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/93fef66631dac0f47ce2c90f774cd4e4fe44028ea5266602e20fbf246f7d14f9?s=96&d=blank&r=g","caption":"Nathan Busler"},"sameAs":["https:\/\/buyzero.de"],"url":"https:\/\/picockpit.com\/raspberry-pi\/zh\/author\/nathan\/"}]}},"_links":{"self":[{"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/posts\/774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/comments?post=774"}],"version-history":[{"count":18,"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/posts\/774\/revisions"}],"predecessor-version":[{"id":6144,"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/posts\/774\/revisions\/6144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/media\/679"}],"wp:attachment":[{"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/media?parent=774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/categories?post=774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/picockpit.com\/raspberry-pi\/zh\/wp-json\/wp\/v2\/tags?post=774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}