Arduino学习——Arduino main 函数
在Arduino IDE的安装目录下可以找到main.cpp这个代码模板文件,main函数就位于此。
文件位置:{Arduino安装目录}\hardware\arduino\avr\cores\arduino\main.cpp,内容如下:
/*
main.cpp - Main loop for Arduino sketches
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <Arduino.h>
// Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (* /*func*/ )()) { return 0; }
// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }
void setupUSB() __attribute__((weak));
void setupUSB() { }
int main(void)
{
init(); //硬件初始化
initVariant(); //特有硬件初始化。因为不同的开发板有自己独特的初始化逻辑。
#if defined(USBCON)
USBDevice.attach();
#endif
setup();
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
return 0;
}
Arduino学习——Arduino main 函数的更多相关文章
- [Go语言]从Docker源码学习Go——main函数
Go程序从main包下的main函数开始执行,当main执行结束后,程序退出. Docker的main函数在 docker/docker/docker.go package main //Import ...
- Arduino学习笔记① 初识Arduino
1.前言 近段时间,博主陆续更新了ESP8266学习笔记,主要开发平台是Arduino.但是,对于很多无基础的初学者来说,甚至不了解Arduino是什么.因此,博主决定加入一个Arduino学 ...
- Arduino学习经验(一)之解决舵机库和pwm输出冲突
一.前言 最近在公司学习Arduino uno ,用它实现小车超声波避障功能.实现的功能很简单,就是在小车前方挂一个超声波模块,当碰到障碍物时,会通过舵机进行摆头,判断两边的距离,进行左右转弯.但是碰 ...
- Arduino 学习
Arduino 背景可以参考官方网站www.arduino.cc 先看一个最简单的示例程序: 打开 Arduino IDE , 选择菜单:文件 -> 示例 -> 01.Basics -&g ...
- Arduino学习笔记1---开发环境搭建
主要内容:(一). Arduino IDE的下载及安装 (二). Arduino IDE的应用 (三). Arduino的程序结构 (四). Arduino程序的编译及下载 (一). Arduino ...
- arduino上使用sprintf()函数输出float值出错
如果尝试使用sprintf()函数在arduino上进行对float指转换为一个字符串的话,你会发现,it doesn't work.弄了很久,还以为是没学c++的原因.其实在arduino上,这个函 ...
- Hadoop源码学习笔记(2) ——进入main函数打印包信息
Hadoop源码学习笔记(2) ——进入main函数打印包信息 找到了main函数,也建立了快速启动的方法,然后我们就进去看一看. 进入NameNode和DataNode的主函数后,发现形式差不多: ...
- Hadoop源码学习笔记(1) ——第二季开始——找到Main函数及读一读Configure类
Hadoop源码学习笔记(1) ——找到Main函数及读一读Configure类 前面在第一季中,我们简单地研究了下Hadoop是什么,怎么用.在这开源的大牛作品的诱惑下,接下来我们要研究一下它是如何 ...
- 大数据学习之Scala中main函数的分析以及基本规则(2)
一.main函数的分析 首先来看我们在上一节最后看到的这个程序,我们先来简单的分析一下.有助于后面的学习 object HelloScala { def main(args: Array[String ...
随机推荐
- VUE - mapState 辅助函数(简化)
1,第一种 <template> <div id="app"> <p> {{count}} </p> <p ...
- 一个小证明(题解 P5425 Part1)
所以这道题为什么可以这样做 嗯,我也不知道,不过我是来填坑的. \(Q\):为什么要把牛分成\(1\),\(1\)......\(N-K+1\)这样的\(K\)组呢? \(A\):我们设第\(i\)组 ...
- [U53204] 树上背包的优化
题目链接 本文旨在介绍树上背包的优化. 可见例题,例题中N,M∈[1,100000]N,M \in [1,100000]N,M∈[1,100000]的数据量让O(nm2)O(nm^2)O(nm2)的朴 ...
- uboot配置和编译过程详解
根据朱有鹏老师讲解整理 一.uboot主Makefile分析 1.uboot version确定(Makefile的24-29行) include/version_autogenerated.h文件是 ...
- 017.Oracle数据库,取今年第一天,取今年最后一天
/*取今年第一天,取今年最后一天*/ SELECT trunc(sysdate, 'yyyy') AS 今年第一天 , add_months(trunc(sysdate, ) AS 今年最后一天 FR ...
- Centos7安装mysql5.7.21
1.卸载系统自带的 MariaDB [root@CentOS ~]# rpm -qa | grep mariadb mariadb-libs--.el7.x86_64 [root@CentOS ~]# ...
- idea安装Maven Helper
1. File -> Settings... 2. 选择 Plunins, 查询 Maven Helper,如果没有,点击 Search in repositories 3. 选择 Maven ...
- 20190108PLC学习心得
应该是数据类型不对 F1查看了帮助文件以后 ,看到 LD应该是用指针类型的数据 改正以后 LD0下的红线消失了 . 绿色 代表没有给 符号 定义 地址 假设 我现在给 符号 字节数 ...
- css画布
绘制基本图形 绘制直线 <style> .canvas{ } </style> <canvas id="myCanvas1" style=" ...
- maven详解之仓库
在Maven中,任何一个依赖.插件或者项目构建的输出,都可以称之为构件. Maven在某个统一的位置存储所有项目的共享的构件,这个统一的位置,我们就称之为仓库.(仓库就是存放依赖和插件的地方) 任何的 ...