00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <errno.h>
00026 #include <sys/ioctl.h>
00027
00028 #include "adjust.h"
00029 #include "mostns1.h"
00030 #include "mostnetsdll.h"
00031 #include "par_cp.h"
00032 #include "global.h"
00033 #include "most-netservice.h"
00034
00035
00036 void ParWrite(tMostMap map, byte value)
00037 {
00038 struct single_transfer_arg arg;
00039 int ret;
00040
00041 CHECK_FILEDESCRIPTOR_RET();
00042
00043 arg.address = map;
00044 arg.value = value;
00045
00046 ret = ioctl(g_control_fd, MOST_NETS_WRITEREG, &arg);
00047 if (ret < 0) {
00048 PERR_DEBUG("Writing a register value failed");
00049 }
00050
00051 PRINT_TRACE("Writing register 0x%x, value 0x%x", map, value);
00052 }
00053
00054
00055 byte ParRead(tMostMap map)
00056 {
00057 struct single_transfer_arg arg;
00058 int ret;
00059
00060 CHECK_FILEDESCRIPTOR_RET_VAL(-1);
00061
00062 arg.address = map;
00063
00064 ret = ioctl(g_control_fd, MOST_NETS_READREG, &arg);
00065 if (ret < 0) {
00066 PERR_DEBUG("Reading a register value failed");
00067 }
00068
00069 PRINT_TRACE("Reading register 0x%x, value 0x%x", map, arg.value);
00070
00071 return arg.value;
00072 }
00073
00074
00075
00076 void ParWriteBlock(tMostMap map, byte num, byte *data)
00077 {
00078 struct block_transfer_arg arg;
00079 int ret;
00080
00081 CHECK_FILEDESCRIPTOR_RET();
00082
00083 arg.address = map;
00084 arg.count = num;
00085 arg.data = data;
00086
00087 ret = ioctl(g_control_fd, MOST_NETS_WRITEREG_BLOCK, &arg);
00088 if (ret < 0) {
00089 PERR_DEBUG("Writing a block of register value failed");
00090 }
00091
00092 PRINT_TRACE("Writing block of registers 0x%x, number = %d", map, num);
00093 }
00094
00095
00096 void ParReadBlock(tMostMap map, byte num, byte *data)
00097 {
00098 struct block_transfer_arg arg;
00099 int ret;
00100
00101 CHECK_FILEDESCRIPTOR_RET();
00102
00103 arg.address = map;
00104 arg.count = num;
00105 arg.data = data;
00106
00107 ret = ioctl(g_control_fd, MOST_NETS_READREG_BLOCK, &arg);
00108 if (ret < 0) {
00109 PERR_DEBUG("Reading a block of register value failed");
00110 }
00111
00112 PRINT_TRACE("Reading block of registers 0x%x, number = %d", map, num);
00113 }
00114
00115
00116 void Most_Reset(void)
00117 {
00118 int ret;
00119
00120 PRINT_TRACE();
00121
00122 printf("-- Reset --\n");
00123
00124 CHECK_FILEDESCRIPTOR_RET();
00125
00126 ret = ioctl(g_control_fd, MOST_NETS_RESET);
00127 if (ret < 0) {
00128 PERR_DEBUG("MOST_NETS_RESET failed");
00129 }
00130 }
00131
00132