00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "sr_lpc10.h"
00025
00026 INT dactab[128] =
00027 {
00028 16, 0, 0, 3, 0, 5, 14, 7, 0, 9, 14, 11,
00029 14, 13, 30, 14, 0, 9, 2, 7, 4, 7, 7, 23, 9,
00030 25, 10, 9, 12, 9, 14, 7, 0, 5, 2, 11, 5, 21,
00031 6, 5, 8, 11, 11, 27, 12, 5, 14, 11, 2, 1, 18,
00032 2, 12, 5, 2, 7, 12, 9, 2, 11, 28, 12, 12, 15,
00033 0, 3, 3, 19, 4, 13, 6, 3, 8, 13, 10, 3, 13, 29,
00034 14, 13, 4, 1, 10, 3, 20, 4, 4, 7, 10, 9, 26,
00035 10, 4, 13, 10, 15, 8, 1, 6, 3, 6, 5, 22, 6, 24,
00036 8, 8, 11, 8, 13, 6, 15, 1, 17, 2, 1, 4, 1, 6,
00037 15, 8, 1, 10, 15, 12, 15, 15, 31
00038 };
00039 void ham84 (INT input, INT * output, INT * errcnt)
00040 {
00041 INT i, j, parity;
00042 INT oerr;
00043
00044
00045 oerr = *errcnt;
00046
00047
00048 parity = input & 255;
00049 parity = parity ^ parity / 16;
00050 parity = parity ^ parity / 4;
00051 parity = parity ^ parity / 2;
00052 parity = parity & 1;
00053
00054 i = dactab[input & 127];
00055 *output = i & 15;
00056 j = i & 16;
00057
00058 if (j != 0)
00059 {
00060
00061 if (parity != 0)
00062 (*errcnt)++;
00063 }
00064 else
00065 {
00066
00067 (*errcnt)++;
00068 if (parity == 0)
00069 {
00070
00071 (*errcnt)++;
00072 *output = -1;
00073 }
00074 }
00075
00076 *errcnt = oerr;
00077
00078 }