⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tid_ripple.c

📁 mpc8xx driver(led), based on tqm8
💻 C
字号:
/*********************************************************************** * * (C) Copyright 2000 * Jean-Jacques Germond, Fr閐閞ic Soulier, Christian Batt; Alcatel * C/O jjg@sxb.bsf.alcatel.fr * * All rights reserved. * * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU *Library* General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This code 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 * *Library* General Public License for more details. * * You should have received a copy of the GNU *Library* General Public * License along with this program (see file COPYING.LIB); if not, * write to the Free Software Foundation, Inc., 675 Mass Ave, * Cambridge, MA 02139, USA. * ***********************************************************************//* This file implements the ripple fonstion for the tid virtual file */#ifndef __KERNEL__/* We are buildind a stand alone ripple test */#  include <stdio.h>#  include <string.h>#  define loff_t int#else   /* Ripple code is include in the tid driver */   /* See AR pg:21  */#  define __NO_VERSION__#  include "tid_def.h"#endifstatic char tid_genericLine[] = "ABCDEF...TUVWXYZ"                                "abcdef...tuvwxyz"                                " <RIPPLE> "                                "0123456789/!@#$%^\n";static int tid_genLen;  char*tid_ripple(loff_t offset){  int index;                              /* The offset in the generic line */  int lineNbr     = (int)offset / tid_genLen;  /* The # of the virtual line */  int indexInLine = (int)offset % tid_genLen;  /* The offset in the virtual line */  if (indexInLine == (tid_genLen - 1)) {    index = tid_genLen -1;   /* The addr of a <newline> */  } else {    /* This is not a <newline> char */    int indexLeft = lineNbr;          /* The rippled first char for the line */    index = indexLeft + indexInLine;  /* The index int ripple */    if (index >= (tid_genLen - 1)) {       index -= (tid_genLen - 1);    }  }  return &tid_genericLine[index];}  inttid_rippleInit(void){  tid_genLen = strlen(tid_genericLine);  return tid_genLen;}#ifndef __KERNEL__main(){  int i;  tid_rippleInit();  for (i = 0; i < 400; i++) {    char carac = *tid_ripple(i);    printf("%c", carac);  }  printf("\nfini\n");}#endif	/* __KERNEL__ */

⌨️ 快捷键说明

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