21 #include "modules/wltune.h"
23 const char cmd_sfp_help[] =
"SFP utils sfp [tune up|tune down]";
25 int smartParse(
const char * value)
29 int len = strlen(value);
30 if (strlen(value) > 3 && value[1] ==
'x') {
39 return strtol(value, value+len, base);
46 bool cmd_sfp_exec(
int argc,
const char *args[])
51 if (strcmp(args[0],
"tune") == 0) {
54 if (wlTuneInfo.tuneword == 65535) {
55 puts(
"Tune word error");
59 if (strcmp(args[1],
"up") == 0) {
60 wltune_set_word(wlTuneInfo.tuneword + 1);
62 else if (strcmp(args[1],
"down") == 0)
64 wltune_set_word(wlTuneInfo.tuneword - 1);
66 else if (strcmp(args[1],
"set") == 0)
69 int32_t v = atoi(args[2]);
73 else if (strcmp(args[1],
"ack") == 0)
79 }
else if (strcmp(args[0],
"i2c") == 0) {
86 if (strcmp(args[1],
"rd") == 0)
91 addr = smartParse(args[2]);
92 reg = smartParse(args[3]);
93 len = smartParse(args[4]);
98 printf(
"i2c rd addr=%02x reg=%02x (%u):", addr, reg, reg, len);
99 for (
int i = 0; i < len; ++i)
101 printf(
" %02x", buf[i]);
110 else if (strcmp(args[1],
"wr") == 0)
114 addr = smartParse(args[2]);
115 reg = smartParse(args[3]);
117 for (
int i = 4; i < argc; ++i)
119 buf[len++] = args[i];
124 puts(
"i2c write succesful");
135 "sfp <cmd> [<options/subcommand>]\n"
136 " when <cmd> is 'tune', subcommand::\n"
137 " up - single dac value up\n"
138 " down - single dac value down\n"
139 " set [#] - set specific dac value (use with care!)\n"
140 " ack - acknowledge dac value [otherwise will be set back]\n"
141 " when <cmd> is 'i2c'\n"
142 " rd <addr> <reg> <len> - Read len bytes (max 4)\n"
143 " wr <addr> <reg> <byte> [<byte>...] - Write bytes (max 4)\n"
bool wrxModI2cWrite(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
Write SFP I2C bus (raw)
bool wrxModI2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
Read SFP I2C bus (raw)
WhiteRabbit exchange exchanges information between the 2nd LM32 and WhiteRabbit though a small client...