delay.c
来自「用M16和MCP2515组成的CAN通讯节点。 有原理图和代码」· C语言 代码 · 共 36 行
C
36 行
/*
Precise Delay Functions
V 0.51, Martin Thomas, 9/2004 & 1/2005
See also delay.h.
Inspired by the avr-libc's loop-code
*/
#include <avr/io.h>
#include <avr/io.h>
#include <inttypes.h>
#include "delay.h"
void delayloop32(uint32_t loops)
{
__asm__ volatile ( "cp %A0,__zero_reg__ \n\t" \
"cpc %B0,__zero_reg__ \n\t" \
"cpc %C0,__zero_reg__ \n\t" \
"cpc %D0,__zero_reg__ \n\t" \
"breq L_Exit_%= \n\t" \
"L_LOOP_%=: \n\t" \
"subi %A0,1 \n\t" \
"sbci %B0,0 \n\t" \
"sbci %C0,0 \n\t" \
"sbci %D0,0 \n\t" \
"brne L_LOOP_%= \n\t" \
"L_Exit_%=: \n\t" \
: "=w" (loops) \
: "0" (loops) \
); \
return;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?