/* Copyright (C) 1986 by M. J. Shannon, Jr. ** Permission to distribute for non-commercial uses granted as long as this ** notice is retained. Violators will be prosecuted. */ #include "mpu.h" /* mpu_id(): ** obtains the version & revision numbers of the MPU firmware and formats ** it into a string suitable for printing. The address of the (static) ** string is returned. */ char * mpu_id() { static char vers_string[9]; register int v, r; register char *p = &vers_string[0]; v = mpu_get(GET_VERSION); r = (v >> 4) & 0x0F; if (r > 9) *p++ = '1', r -= 10; *p++ = r + '0'; *p++ = '.'; v &= 0x0F; if (v > 9) *p++ = '1', v -= 10; *p++ = v + '0'; r = mpu_get(GET_REVISION); if (r) { if (r > 0) { if (r > 26) { *p++ = 'r'; v = r / 100; if (v) *p++ = v + '0', r -= v * 100; v = r / 10; if (v) *p++ = v + '0', r -= v * 10; if (r) *p++ = r + '0'; } else *p++ = r + '@'; } } *p = '\0'; return (vers_string); }