怎样查看arduino自带的函数源代码
发布网友
发布时间:2022-05-18 23:56
我来回答
共1个回答
热心网友
时间:2023-11-23 08:13
D:\Program Files\Arino\hardware\arino\cores\arino的wiring_digital.c文件或D:\Program Files\Arino\hardware\arino\cores\robot的wiring_digital.c文件
<pre t="code" l="cpp">#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arino.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;
}
}
热心网友
时间:2023-12-15 09:10
D:\Program Files\Arino\hardware\arino\cores\arino的wiring_digital.c文件或D:\Program Files\Arino\hardware\arino\cores\robot的wiring_digital.c文件
<pre t="code" l="cpp">#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arino.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;
}
}