{"id":4316,"date":"2021-10-25T17:31:58","date_gmt":"2021-10-25T09:31:58","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=4316"},"modified":"2021-10-25T18:01:14","modified_gmt":"2021-10-25T10:01:14","slug":"bcm2835","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=4316","title":{"rendered":"[RaspberryPi]bcm2835"},"content":{"rendered":"\n<div class=\"wp-block-file\"><a href=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2021\/10\/bcm2835-1.70.tar.gz\">bcm2835-1.70.tar<\/a><a href=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2021\/10\/bcm2835-1.70.tar.gz\" class=\"wp-block-file__button\" download>\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>wget http:\/\/www.airspayce.com\/mikem\/bcm2835\/bcm2835-1.70.tar.gz\ntar -xf bcm2835-1.70.tar.gz\ncd bcm2835-1.70\/\n.\/configure\nmake\nsudo make check\nsudo make install\n\n\n-------------------------------------------\nvim test.c\n-------------------------------------------\n#include &lt;bcm2835.h>\n#define LEDA_PIN RPI_GPIO_P1_16        \/* LED\u706fA\u4f7f\u7528P1\u4e0a\u768416\u5f15\u811a *\/\n#define LEDB_PIN RPI_GPIO_P1_18        \/* LED\u706fA\u4f7f\u7528P1\u4e0a\u768418\u5f15\u811a *\/\nint main(int argc, char **argv)\n{\n        if (!bcm2835_init())\n                return 1;\n \n        \/* \u521d\u59cb\u5316GPIO\u7aef\u53e3 *\/\n        bcm2835_gpio_fsel(LEDA_PIN, BCM2835_GPIO_FSEL_OUTP);\/\/\u521d\u59cb\u5316LEDA\u4e3a\u8f93\u51fa\u6a21\u5f0f\n        bcm2835_gpio_write(LEDA_PIN, LOW);\/\/\u62c9\u4f4e\n        bcm2835_gpio_fsel(LEDB_PIN, BCM2835_GPIO_FSEL_OUTP);\/\/\u521d\u59cb\u5316LEDB\u4e3a\u8f93\u51fa\u6a21\u5f0f\n        bcm2835_gpio_write(LEDB_PIN, LOW);\/\/\u62c9\u4f4e\n \n        while (1) {\n                bcm2835_gpio_write(LEDA_PIN, HIGH);\/\/LEDA\u70b9\u4eae\n                bcm2835_gpio_write(LEDB_PIN, LOW); \/\/LEDB\u706d\u6389\n \n                bcm2835_delay(250);\/\/\u5ef6\u8fdf\n \n                bcm2835_gpio_write(LEDA_PIN, LOW); \/\/LEDA\u706d\u6389\n                bcm2835_gpio_write(LEDB_PIN, HIGH);\/\/LEDB\u70b9\u4eae\n \n                bcm2835_delay(250);\n        }\n        return 0;\n}\n\ngcc -Wall -o test.out test.c -lbcm2835\n.\/test.out<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4316"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4316"}],"version-history":[{"count":4,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4316\/revisions"}],"predecessor-version":[{"id":4321,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4316\/revisions\/4321"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}