util.c

来自「这是一个基于8255扩展端口的keil c51固件」· C语言 代码 · 共 41 行

C
41
字号
/*
  Copyright (C) 2003 Bart Bilos <boombox666@yahoo.com>.

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program 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 General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation, 
  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

// Small delay subroutine
void delay(unsigned int delay) {
  unsigned int i,j;
  for(i = 0; i < delay ;i++)
  	for(j = 0; j < 255 ;j++);
}

long int long_big_endian(long int value) {
long int temp=0;
temp = temp | ((value >> 24) & 0x000000FF);
temp = temp | ((value >> 8) & 0x0000FF00);
temp = temp | ((value << 8) & 0x00FF0000);
temp = temp | ((value << 24) & 0xFF000000);
return temp;
}

int int_big_endian(int value) {
int temp;
temp = (value >> 8) & 0x00FF;
temp = temp | ((value << 8) & 0xFF00);
return temp;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?