Skip to content

Commit bc309ab

Browse files
Fixed warnings
1 parent e873437 commit bc309ab

2 files changed

Lines changed: 24 additions & 38 deletions

File tree

general/include/lan8670.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ int32_t LAN8670_Isolate(lan8670_t *lan, bool setting); // Electrically isolates
107107
*/
108108
int32_t LAN8670_Collision_Test(lan8670_t *lan, bool setting); // Enables or disables the LAN8670's collision test mode.
109109

110-
/**
111-
* @brief Detects jabber condition on the LAN8670.
112-
* @param lan Pointer to the lan8670_t instance.
113-
* @param jabber_status Pointer to a boolean variable to store the jabber status.
114-
* @return Status.
115-
*/
116-
int32_t LAN8670_Detect_Jabber(lan8670_t *lan, bool *jabber_status); // Detects jabber condition on the LAN8670.
117-
118110
/**
119111
* @brief Enables or disables collision detection on the LAN8670.
120112
* @param lan Pointer to the lan8670_t instance.

general/src/lan8670.c

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,19 @@ static int read_register_field(lan8670_t *lan, int reg, int start, int end, uint
126126
{
127127
/* Validate bit range (If the first bit is greater than the last bit, the field is invalid.) */
128128
if (start > end) {
129-
debug("ERROR 1000: read_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
129+
debug(lan, "ERROR 1000: read_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
130130
return LAN8670_STATUS_ERROR;
131131
}
132132
if (start < 0 || end > 31) {
133-
debug("ERROR 1001: read_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
133+
debug(lan, "ERROR 1001: read_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
134134
return LAN8670_STATUS_ERROR;
135135
}
136136

137137
/* Read the register */
138138
uint32_t data = 0;
139139
int status = lan->IO.ReadReg(lan->DevAddr, reg, &data);
140140
if (status != 0) {
141-
debug("ERROR 1002: read_register_field() failed to read register 0x%X (Status: %d)\n", reg, status);
141+
debug(lan, "ERROR 1002: read_register_field() failed to read register 0x%X (Status: %d)\n", reg, status);
142142
return LAN8670_STATUS_READ_ERROR;
143143
}
144144

@@ -168,19 +168,19 @@ static int write_register_field(lan8670_t *lan, int reg, int start, int end, uin
168168
{
169169
/* Validate bit range (If the first bit is greater than the last bit, the field is invalid.) */
170170
if (start > end) {
171-
debug("ERROR 2000: write_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
171+
debug(lan, "ERROR 2000: write_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
172172
return LAN8670_STATUS_ERROR;
173173
}
174174
if (start < 0 || end > 31) {
175-
debug("ERROR 2001: write_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
175+
debug(lan, "ERROR 2001: write_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
176176
return LAN8670_STATUS_ERROR;
177177
}
178178

179179
/* Calculate field width and validate value */
180180
int field_width = end - start + 1;
181181
uint32_t max_value = (1U << field_width) - 1;
182182
if (value > max_value) {
183-
debug("ERROR 2002: write_register_field() value 0x%X exceeds maximum 0x%X for %d-bit field\n",
183+
debug(lan, "ERROR 2002: write_register_field() value 0x%X exceeds maximum 0x%X for %d-bit field\n",
184184
value, max_value, field_width);
185185
return LAN8670_STATUS_ERROR;
186186
}
@@ -189,7 +189,7 @@ static int write_register_field(lan8670_t *lan, int reg, int start, int end, uin
189189
uint32_t data = 0;
190190
int status = lan->IO.ReadReg(lan->DevAddr, reg, &data);
191191
if (status != 0) {
192-
debug("ERROR 3000: write_register_field() failed to read register 0x%X (Status: %d)\n", reg, status);
192+
debug(lan, "ERROR 3000: write_register_field() failed to read register 0x%X (Status: %d)\n", reg, status);
193193
return LAN8670_STATUS_READ_ERROR;
194194
}
195195

@@ -200,7 +200,7 @@ static int write_register_field(lan8670_t *lan, int reg, int start, int end, uin
200200
/* Write back the modified value */
201201
status = lan->IO.WriteReg(lan->DevAddr, reg, data);
202202
if (status != 0) {
203-
debug("ERROR 3001: write_register_field() failed to write register 0x%X (Status: %d)\n", reg, status);
203+
debug(lan, "ERROR 3001: write_register_field() failed to write register 0x%X (Status: %d)\n", reg, status);
204204
return LAN8670_STATUS_WRITE_ERROR;
205205
}
206206

@@ -225,29 +225,29 @@ static int mmd_read_register(lan8670_t *lan, uint16_t mmd_addr, uint16_t registe
225225
uint16_t mmd_ctrl = mmd_addr & 0x1F;
226226
int status = lan->IO.WriteReg(lan->DevAddr, REG_MMDCTRL, mmd_ctrl);
227227
if (status != 0) {
228-
debug("ERROR 4000: mmd_read_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
228+
debug(lan, "ERROR 4000: mmd_read_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
229229
return LAN8670_STATUS_WRITE_ERROR;
230230
}
231231

232232
/* Tell the MMDAD register what specific register you want to access */
233233
status = lan->IO.WriteReg(lan->DevAddr, REG_MMDAD, register_offset);
234234
if (status != 0) {
235-
debug("ERROR 4001: mmd_read_register() failed when writing REG_MMDAD (Status: %d)\n", status);
235+
debug(lan, "ERROR 4001: mmd_read_register() failed when writing REG_MMDAD (Status: %d)\n", status);
236236
return LAN8670_STATUS_WRITE_ERROR;
237237
}
238238

239239
/* Set the MMD function to 'Data - No post increment' */
240240
mmd_ctrl = (mmd_addr & 0x1F) | (1 << 14);
241241
status = lan->IO.WriteReg(lan->DevAddr, REG_MMDCTRL, mmd_ctrl);
242242
if (status != 0) {
243-
debug("ERROR 4002: mmd_read_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
243+
debug(lan, "ERROR 4002: mmd_read_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
244244
return LAN8670_STATUS_WRITE_ERROR;
245245
}
246246

247247
/* Read data from MMDAD */
248248
status = lan->IO.ReadReg(lan->DevAddr, REG_MMDAD, value);
249249
if (status != 0) {
250-
debug("ERROR 4003: mmd_read_register() failed when reading REG_MMDAD (Status: %d)\n", status);
250+
debug(lan, "ERROR 4003: mmd_read_register() failed when reading REG_MMDAD (Status: %d)\n", status);
251251
return LAN8670_STATUS_READ_ERROR;
252252
}
253253

@@ -272,29 +272,29 @@ static int mmd_write_register(lan8670_t *lan, uint16_t mmd_addr, uint16_t regist
272272
uint16_t mmd_ctrl = mmd_addr & 0x1F;
273273
int status = lan->IO.WriteReg(lan->DevAddr, REG_MMDCTRL, mmd_ctrl);
274274
if (status != 0) {
275-
debug("ERROR 5000: mmd_write_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
275+
debug(lan, "ERROR 5000: mmd_write_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
276276
return LAN8670_STATUS_WRITE_ERROR;
277277
}
278278

279279
/* Tell the MMDAD register what specific register you want to access */
280280
status = lan->IO.WriteReg(lan->DevAddr, REG_MMDAD, register_offset);
281281
if (status != 0) {
282-
debug("ERROR 5001: mmd_write_register() failed when writing REG_MMDAD (Status: %d)\n", status);
282+
debug(lan, "ERROR 5001: mmd_write_register() failed when writing REG_MMDAD (Status: %d)\n", status);
283283
return LAN8670_STATUS_WRITE_ERROR;
284284
}
285285

286286
/* Set the MMD function to 'Data - No post increment' */
287287
mmd_ctrl = (mmd_addr & 0x1F) | (1 << 14);
288288
status = lan->IO.WriteReg(lan->DevAddr, REG_MMDCTRL, mmd_ctrl);
289289
if (status != 0) {
290-
debug("ERROR 5002: mmd_write_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
290+
debug(lan, "ERROR 5002: mmd_write_register() failed when writing REG_MMDCTRL (Status: %d)\n", status);
291291
return LAN8670_STATUS_WRITE_ERROR;
292292
}
293293

294294
/* Write data to MMDAD */
295295
status = lan->IO.WriteReg(lan->DevAddr, REG_MMDAD, value);
296296
if (status != 0) {
297-
debug("ERROR 5003: mmd_write_register() failed when writing REG_MMDAD (Status: %d)\n", status);
297+
debug(lan, "ERROR 5003: mmd_write_register() failed when writing REG_MMDAD (Status: %d)\n", status);
298298
return LAN8670_STATUS_WRITE_ERROR;
299299
}
300300

@@ -319,19 +319,19 @@ static int mmd_read_register_field(lan8670_t *lan, uint16_t mmd_addr, uint16_t r
319319
{
320320
/* Validate bit range */
321321
if (start > end) {
322-
debug("ERROR 6000: mmd_read_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
322+
debug(lan, "ERROR 6000: mmd_read_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
323323
return LAN8670_STATUS_ERROR;
324324
}
325325
if (start < 0 || end > 15) {
326-
debug("ERROR 6001: mmd_read_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
326+
debug(lan, "ERROR 6001: mmd_read_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
327327
return LAN8670_STATUS_ERROR;
328328
}
329329

330330
/* Read the full register */
331331
uint16_t data = 0;
332332
int status = mmd_read_register(lan, mmd_addr, register_offset, &data);
333333
if (status != 0) {
334-
debug("ERROR 6002: mmd_read_register_field() failed to read register (Status: %d)\n", status);
334+
debug(lan, "ERROR 6002: mmd_read_register_field() failed to read register (Status: %d)\n", status);
335335
return LAN8670_STATUS_READ_ERROR;
336336
}
337337

@@ -362,19 +362,19 @@ static int mmd_write_register_field(lan8670_t *lan, uint16_t mmd_addr, uint16_t
362362
{
363363
/* Validate bit range */
364364
if (start > end) {
365-
debug("ERROR 7000: mmd_write_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
365+
debug(lan, "ERROR 7000: mmd_write_register_field() invalid bit range: start (%d) > end (%d)\n", start, end);
366366
return LAN8670_STATUS_ERROR;
367367
}
368368
if (start < 0 || end > 15) {
369-
debug("ERROR 7001: mmd_write_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
369+
debug(lan, "ERROR 7001: mmd_write_register_field() bit range out of bounds: start=%d, end=%d\n", start, end);
370370
return LAN8670_STATUS_ERROR;
371371
}
372372

373373
/* Calculate field width and validate value */
374374
int field_width = end - start + 1;
375375
uint16_t max_value = (1U << field_width) - 1;
376376
if (value > max_value) {
377-
debug("ERROR 7002: mmd_write_register_field() value 0x%X exceeds maximum 0x%X for %d-bit field\n",
377+
debug(lan, "ERROR 7002: mmd_write_register_field() value 0x%X exceeds maximum 0x%X for %d-bit field\n",
378378
value, max_value, field_width);
379379
return LAN8670_STATUS_ERROR;
380380
}
@@ -383,7 +383,7 @@ static int mmd_write_register_field(lan8670_t *lan, uint16_t mmd_addr, uint16_t
383383
uint16_t data = 0;
384384
int status = mmd_read_register(lan, mmd_addr, register_offset, &data);
385385
if (status != 0) {
386-
debug("ERROR 7003: mmd_write_register_field() failed to read register (Status: %d)\n", status);
386+
debug(lan, "ERROR 7003: mmd_write_register_field() failed to read register (Status: %d)\n", status);
387387
return LAN8670_STATUS_READ_ERROR;
388388
}
389389

@@ -394,7 +394,7 @@ static int mmd_write_register_field(lan8670_t *lan, uint16_t mmd_addr, uint16_t
394394
/* Write back the modified value */
395395
status = mmd_write_register(lan, mmd_addr, register_offset, data);
396396
if (status != 0) {
397-
debug("ERROR 7004: mmd_write_register_field() failed to write register (Status: %d)\n", status);
397+
debug(lan, "ERROR 7004: mmd_write_register_field() failed to write register (Status: %d)\n", status);
398398
return LAN8670_STATUS_WRITE_ERROR;
399399
}
400400

@@ -469,12 +469,6 @@ int32_t LAN8670_Collision_Test(lan8670_t *lan, bool setting)
469469
return write_register_field(lan, REG_BASIC_CONTROL, 7, 7, setting);
470470
}
471471

472-
int32_t LAN8670_Detect_Jabber(lan8670_t *lan, bool *jabber_status)
473-
{
474-
// Read bit 1 of the Basic Status Register to 'jabber_status'.
475-
return read_register_field(lan, REG_BASIC_STATUS, 1, 1, jabber_status);
476-
}
477-
478472
int32_t LAN8670_Collision_Detection(lan8670_t *lan, bool setting) {
479473
// Modify bit 15 of the Collision Detector Control 0 Register to whatever 'setting' is.
480474
return mmd_write_register_field(lan, MMD_MISC, MISC_CDCTL0, 15, 15, setting);

0 commit comments

Comments
 (0)