{"id":806,"date":"2021-03-22T12:30:59","date_gmt":"2021-03-22T03:30:59","guid":{"rendered":"http:\/\/it-style.jp\/?p=806"},"modified":"2021-03-22T12:30:59","modified_gmt":"2021-03-22T03:30:59","slug":"arduino-leonardo%e3%81%af%e3%83%a6%e3%83%bc%e3%82%b6%e3%82%b9%e3%82%b1%e3%83%83%e3%83%81%e3%81%a7%e3%82%82usb%e5%89%b2%e3%82%8a%e8%be%bc%e3%81%bf%e3%81%8c%e8%b5%b0%e3%81%a3%e3%81%a6%e3%81%84%e3%82%8b","status":"publish","type":"post","link":"https:\/\/it-style.jp\/?p=806","title":{"rendered":"Arduino Leonardo\u306f\u30e6\u30fc\u30b6\u30b9\u30b1\u30c3\u30c1\u3067\u3082USB\u5272\u308a\u8fbc\u307f\u304c\u8d70\u3063\u3066\u3044\u308b"},"content":{"rendered":"<p><strong>Arduino Leonardo\u306f\u30e6\u30fc\u30b6\u30b9\u30b1\u30c3\u30c1\u3067\u3082USB\u5272\u308a\u8fbc\u307f\u304c\u8d70\u3063\u3066\u3044\u308b<\/strong><\/p>\n<p>\u3053\u308c\u7d50\u69cb\u9762\u5012\u304f\u3055\u3044\u554f\u984c\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/store-cdn.arduino.cc\/usa\/catalog\/product\/cache\/1\/image\/520x330\/604a3538c15e081937dbfbd20aa60aad\/A\/0\/A000057_featured_2.jpg\" alt=\"Arduino Leonardo with Headers\" \/><\/p>\n<p>Arduino Uno \u3068\u304b nano \u3068\u304b\u4e00\u822c\u7684\u306aArduino\u306f\u3001PC\u3068\u30b7\u30ea\u30a2\u30eb\u3001UART\u3067\u3064\u306a\u304c\u3063\u3066\u307e\u3059\u304c\u3001PC\u5074\u306b\u306fFT232\u306e\u3088\u3046\u306aUSB\u30fcUART\u5909\u63dbIC\u304c\u3061\u3083\u3093\u3068\u5b58\u5728\u3057\u3066\u3066\u3044\u308d\u3044\u308d\u9762\u5012\u306a\u51e6\u7406\u3092\u3057\u305f\u5f8c\u306e\u30c7\u30fc\u30bf\u304cAVR\u30de\u30a4\u30b3\u30f3\u306b\u3084\u3063\u3066\u304f\u308b\u308f\u3051\u3067\u3001\u3042\u308b\u610f\u5473\u5206\u304b\u308a\u6613\u3044\u3057\u3001\u6709\u308a\u96e3\u3044\u8a2d\u8a08\u3067\u3059\u306d\u3002<\/p>\n<p>\u3068\u3053\u308d\u304c\u3001Leonardo\u306f\u3001\u5e78\u304b\u4e0d\u5e78\u304b\u3001USBPhy\u30c1\u30c3\u30d7\u3092\u5185\u8535\u3057\u3066\u308b\u306e\u3067\u3001\u5916\u3065\u3051\u5909\u63db\uff29\uff23\u304c\u5fc5\u8981\u7121\u3044\u5206\u3001\u30bd\u30d5\u30c8\u304c\u3084\u3084\u3053\u3057\u3044\u4e8b\u306b\u30fb\u30fb\u30fb<\/p>\n<p>main()\u3067\u3053\u305d\u3063\u3068\u3002<\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">int main(void)<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">{<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 init();<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 initVariant();<\/span><\/p>\n<p><span style=\"color: #ff0000; font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 #if defined(USBCON)<\/span><br \/>\n<span style=\"color: #ff0000; font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 USBDevice.attach();<\/span><br \/>\n<span style=\"color: #ff0000; font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 #endif<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 setup();<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 for (;;) {<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 loop();<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 if (serialEventRun) serialEventRun();<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 }<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 return 0;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">}<\/span><\/p>\n<p>\u3063\u3066\u3001\u898b\u9003\u3057\u304c\u3061\u3067\u3059\u304c\u3001\u3057\u3063\u304b\u308aUSB blabla attach \u3063\u3066\u3001\u3055\u308c\u3066\u307e\u3059\u3002<\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">void USBDevice_::attach()<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">{<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">\u00a0 \u00a0 _usbConfiguration = 0;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">\u00a0 \u00a0 _usbCurrentStatus = 0;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">\u00a0 \u00a0 _usbSuspendState = 0;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">\u00a0 \u00a0 USB_ClockEnable();<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">\u00a0 \u00a0 UDINT &amp;= ~((1&lt;&lt;WAKEUPI) | (1&lt;&lt;SUSPI)); \/\/ clear already pending WAKEUP \/ SUSPEND requests<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">\u00a0 \u00a0 <span style=\"color: #ff0000;\">UDIEN = (1&lt;&lt;EORSTE) | (1&lt;&lt;SOFE) | (1&lt;&lt;SUSPE); \/\/ Enable interrupts for EOR (End of Reset), SOF (start of frame) and SUSPEND<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>\u3053\u308c\u8003\u3048\u3066\u307f\u308c\u3070\u5f53\u305f\u308a\u524d\u3067\u3059\u304c\u3001Leonardo\u306e\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u306e\u5834\u5408\u3001\u30e6\u30fc\u30b6\u30b9\u30b1\u30c3\u30c1\u3092\u30ed\u30fc\u30c9\u3057\u3066\u5236\u5fa1\u3092\u30e6\u30fc\u30b6\u5074\u306b\u79fb\u3057\u305f\u3042\u3068\u3001USB\u304b\u3089\u306e\u901a\u4fe1\u304c\u306a\u304f\u306a\u308b\u3068ArduinoIDE\u3068\u4e8c\u5ea6\u3068\u3064\u306a\u304c\u3089\u306a\u304f\u306a\u308a\u307e\u3059\u306d\u3002\u307e\u305f\u30b7\u30ea\u30a2\u30eb\u30e2\u30cb\u30bf\u3082\u52d5\u4f5c\u3057\u307e\u305b\u3093\u3057\u306d\u3002<\/p>\n<p>\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u3067\u30ea\u30bb\u30c3\u30c8\u5f8c\u306e\u4f55\u79d2\u304b\u306f\u5f85\u3064\u3001\u307f\u305f\u3044\u306a\u4ed5\u69d8\u306e\u3082\u306e\u3082\u3042\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u3044\u3065\u308c\u306b\u3057\u3066\u3082\u6271\u3044\u306b\u304f\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>USB\u3092\u3057\u3083\u3076\u308a\u3064\u304f\u3059\u30ec\u30d9\u30eb\u3067\u77e5\u8b58\u3092\u6301\u3063\u3066\u306a\u3044\u3068\u3001\u3053\u308c\u3092\u597d\u304d\u306b\u6271\u3046\u306e\u306f\u3061\u3087\u3063\u3068\u56f0\u96e3\u3067\u3059\u306d\u3002\u6628\u4eca\u306f\u3053\u306e\u624b\u306e\u30dc\u30fc\u30c9\u3092\u4f55\u304b\u306b\u7d44\u307f\u8fbc\u3080\u3068\u304d\u306b\u30b3\u30b9\u30c8\u3092\u8003\u3048\u308b\u5fc5\u8981\u306f\u306a\u304f\u306a\u3063\u3066\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u7d20\u76f4\u306b\u60c5\u5831\u306e\u591a\u3044UNO\u3068\u304b\u3092\u4f7f\u3046\u306e\u304c\u4e00\u756a\u7121\u96e3\u3060\u3068\u3044\u3046\u7d50\u8ad6\u3067\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Arduino Leonardo\u306f\u30e6\u30fc\u30b6\u30b9\u30b1\u30c3\u30c1\u3067\u3082USB\u5272\u308a\u8fbc\u307f\u304c\u8d70\u3063\u3066\u3044\u308b \u3053\u308c\u7d50\u69cb\u9762\u5012\u304f\u3055\u3044\u554f\u984c\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u3002 Arduino Uno \u3068\u304b nano \u3068\u304b\u4e00\u822c\u7684\u306aArduino\u306f\u3001PC\u3068\u30b7\u30ea\u30a2\u30eb\u3001UART\u3067\u3064\u306a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":809,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"vkexunit_cta_each_option":"","footnotes":""},"categories":[14],"tags":[],"class_list":["post-806","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-embedded"],"_links":{"self":[{"href":"https:\/\/it-style.jp\/index.php?rest_route=\/wp\/v2\/posts\/806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it-style.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it-style.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it-style.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it-style.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=806"}],"version-history":[{"count":3,"href":"https:\/\/it-style.jp\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions"}],"predecessor-version":[{"id":810,"href":"https:\/\/it-style.jp\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions\/810"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it-style.jp\/index.php?rest_route=\/wp\/v2\/media\/809"}],"wp:attachment":[{"href":"https:\/\/it-style.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it-style.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it-style.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}