怎样查看Arduino中的子函数例如pinMode()的源代码?
答案:2 悬赏:10 手机版
解决时间 2021-03-27 09:57
- 提问者网友:难遇难求
- 2021-03-27 02:22
怎样查看Arduino中的子函数例如pinMode()的源代码?
最佳答案
- 五星知识达人网友:duile
- 2021-03-27 03:13
D:Program FilesArduinohardwarearduinocoresarduino的wiring_digital.c文件
或D:Program FilesArduinohardwarearduinocoresobot的wiring_digital.c文件
#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arduino.h"
void pinMode(uint8_t pin, uint8_t mode)
{
uint8_tbit = digitalPinToBitMask(pin);
uint8_tport = digitalPinToPort(pin);
volatileuint8_t *reg, *out;
if(port == NOT_A_PIN) return;
//JWS: can I let the optimizer do this?
reg= portModeRegister(port);
out= portOutputRegister(port);
if(mode == INPUT) {
uint8_toldSREG = SREG;
cli();
*reg&= ~bit;
*out&= ~bit;
SREG= oldSREG;
}else if (mode == INPUT_PULLUP) {
uint8_toldSREG = SREG;
cli();
*reg&= ~bit;
*out|= bit;
SREG= oldSREG;
}else {
uint8_toldSREG = SREG;
cli();
*reg|= bit;
SREG= oldSREG;
}
}
或D:Program FilesArduinohardwarearduinocoresobot的wiring_digital.c文件
#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arduino.h"
void pinMode(uint8_t pin, uint8_t mode)
{
uint8_tbit = digitalPinToBitMask(pin);
uint8_tport = digitalPinToPort(pin);
volatileuint8_t *reg, *out;
if(port == NOT_A_PIN) return;
//JWS: can I let the optimizer do this?
reg= portModeRegister(port);
out= portOutputRegister(port);
if(mode == INPUT) {
uint8_toldSREG = SREG;
cli();
*reg&= ~bit;
*out&= ~bit;
SREG= oldSREG;
}else if (mode == INPUT_PULLUP) {
uint8_toldSREG = SREG;
cli();
*reg&= ~bit;
*out|= bit;
SREG= oldSREG;
}else {
uint8_toldSREG = SREG;
cli();
*reg|= bit;
SREG= oldSREG;
}
}
全部回答
- 1楼网友:轻雾山林
- 2021-03-27 04:24
盘符:\Program Files\Arduino\hardware\arduino\avr\cores\arduino 目前最新版本(1.8.4)的核心底层代码在这里。arduino更新了。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯