Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "dp83848.h"
Private define
#define DP83848_SW_RESET_TO
#define DP83848_INIT_TO
#define DP83848_MAX_DEV_ADDR
DP83848_RegisterBusIO(dp83848_Object_t *, dp83848_IOCtx_t *)
DP83848_Init(dp83848_Object_t *)
DP83848_DeInit(dp83848_Object_t *)
DP83848_DisablePowerDownMode(dp83848_Object_t *)
DP83848_EnablePowerDownMode(dp83848_Object_t *)
DP83848_StartAutoNego(dp83848_Object_t *)
DP83848_GetLinkState(dp83848_Object_t *)
DP83848_SetLinkState(dp83848_Object_t *, uint32_t)
DP83848_EnableLoopbackMode(dp83848_Object_t *)
DP83848_DisableLoopbackMode(dp83848_Object_t *)
DP83848_EnableIT(dp83848_Object_t *, uint32_t)
DP83848_DisableIT(dp83848_Object_t *, uint32_t)
DP83848_ClearIT(dp83848_Object_t *, uint32_t)
DP83848_GetITStatus(dp83848_Object_t *, uint32_t)
Files
loading...
SourceVuSTM32 Libraries and Samplesdp83848dp83848.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file dp83848.c * @author MCD Application Team * @brief This file provides a set of functions needed to manage the DP83848 * PHY devices. ****************************************************************************** * @attention * * Copyright (c) 2021 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "dp83848.h" /** @addtogroup BSP * @{ *//* ... */ /** @addtogroup Component * @{ *//* ... */ /** @defgroup DP83848 DP83848 * @{ *//* ... */ Includes /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /** @defgroup DP83848_Private_Defines DP83848 Private Defines * @{ *//* ... */ #define DP83848_SW_RESET_TO ((uint32_t)500U) #define DP83848_INIT_TO ((uint32_t)2000U) #define DP83848_MAX_DEV_ADDR ((uint32_t)31U) /** * @} *//* ... */ Private define /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup DP83848_Private_Functions DP83848 Private Functions * @{ *//* ... */ /** * @brief Register IO functions to component object * @param pObj: device object of DP83848_Object_t. * @param ioctx: holds device IO functions. * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_ERROR if missing mandatory function *//* ... */ int32_t DP83848_RegisterBusIO(dp83848_Object_t *pObj, dp83848_IOCtx_t *ioctx) { if(!pObj || !ioctx->ReadReg || !ioctx->WriteReg || !ioctx->GetTick) { return DP83848_STATUS_ERROR; }if (!pObj || !ioctx->ReadReg || !ioctx->WriteReg || !ioctx->GetTick) { ... } pObj->IO.Init = ioctx->Init; pObj->IO.DeInit = ioctx->DeInit; pObj->IO.ReadReg = ioctx->ReadReg; pObj->IO.WriteReg = ioctx->WriteReg; pObj->IO.GetTick = ioctx->GetTick; return DP83848_STATUS_OK; }{ ... } /** * @brief Initialize the DP83848 and configure the needed hardware resources * @param pObj: device object DP83848_Object_t. * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_ADDRESS_ERROR if cannot find device address * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register * DP83848_STATUS_RESET_TIMEOUT if cannot perform a software reset *//* ... */ int32_t DP83848_Init(dp83848_Object_t *pObj) { uint32_t tickstart = 0, regvalue = 0, addr = 0; int32_t status = DP83848_STATUS_OK; if(pObj->Is_Initialized == 0) { if(pObj->IO.Init != 0) { /* GPIO and Clocks initialization */ pObj->IO.Init(); }if (pObj->IO.Init != 0) { ... } /* for later check */ pObj->DevAddr = DP83848_MAX_DEV_ADDR + 1; /* Get the device address from special mode register */ for(addr = 0; addr <= DP83848_MAX_DEV_ADDR; addr ++) { if(pObj->IO.ReadReg(addr, DP83848_SMR, &regvalue) < 0) { status = DP83848_STATUS_READ_ERROR; /* Can't read from this device address continue with next address *//* ... */ continue; }if (pObj->IO.ReadReg(addr, DP83848_SMR, ®value) < 0) { ... } if((regvalue & DP83848_SMR_PHY_ADDR) == addr) { pObj->DevAddr = addr; status = DP83848_STATUS_OK; break; }if ((regvalue & DP83848_SMR_PHY_ADDR) == addr) { ... } }for (addr = 0; addr <= DP83848_MAX_DEV_ADDR; addr ++) { ... } if(pObj->DevAddr > DP83848_MAX_DEV_ADDR) { status = DP83848_STATUS_ADDRESS_ERROR; }if (pObj->DevAddr > DP83848_MAX_DEV_ADDR) { ... } /* if device address is matched */ if(status == DP83848_STATUS_OK) { /* set a software reset */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, DP83848_BCR_SOFT_RESET) >= 0) { /* get software reset status */ if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &regvalue) >= 0) { tickstart = pObj->IO.GetTick(); /* wait until software reset is done or timeout occured */ while(regvalue & DP83848_BCR_SOFT_RESET) { if((pObj->IO.GetTick() - tickstart) <= DP83848_SW_RESET_TO) { if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &regvalue) < 0) { status = DP83848_STATUS_READ_ERROR; break; }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, ®value) < 0) { ... } }if ((pObj->IO.GetTick() - tickstart) <= DP83848_SW_RESET_TO) { ... } else { status = DP83848_STATUS_RESET_TIMEOUT; break; }else { ... } }while (regvalue & DP83848_BCR_SOFT_RESET) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, ®value) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, DP83848_BCR_SOFT_RESET) >= 0) { ... } else { status = DP83848_STATUS_WRITE_ERROR; }else { ... } }if (status == DP83848_STATUS_OK) { ... } }if (pObj->Is_Initialized == 0) { ... } if(status == DP83848_STATUS_OK) { tickstart = pObj->IO.GetTick(); /* Wait for 2s to perform initialization */ while((pObj->IO.GetTick() - tickstart) <= DP83848_INIT_TO) { }while ((pObj->IO.GetTick() - tickstart) <= DP83848_INIT_TO) { ... } pObj->Is_Initialized = 1; }if (status == DP83848_STATUS_OK) { ... } return status; }{ ... } /** * @brief De-Initialize the dp83848 and it's hardware resources * @param pObj: device object DP83848_Object_t. * @retval None *//* ... */ int32_t DP83848_DeInit(dp83848_Object_t *pObj) { if(pObj->Is_Initialized) { if(pObj->IO.DeInit != 0) { if(pObj->IO.DeInit() < 0) { return DP83848_STATUS_ERROR; }if (pObj->IO.DeInit() < 0) { ... } }if (pObj->IO.DeInit != 0) { ... } pObj->Is_Initialized = 0; }if (pObj->Is_Initialized) { ... } return DP83848_STATUS_OK; }{ ... } /** * @brief Disable the DP83848 power down mode. * @param pObj: device object DP83848_Object_t. * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_DisablePowerDownMode(dp83848_Object_t *pObj) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { readval &= ~DP83848_BCR_POWER_DOWN; /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @brief Enable the DP83848 power down mode. * @param pObj: device object DP83848_Object_t. * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_EnablePowerDownMode(dp83848_Object_t *pObj) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { readval |= DP83848_BCR_POWER_DOWN; /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @brief Start the auto negotiation process. * @param pObj: device object DP83848_Object_t. * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_StartAutoNego(dp83848_Object_t *pObj) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { readval |= DP83848_BCR_AUTONEGO_EN; /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @brief Get the link state of DP83848 device. * @param pObj: Pointer to device object. * @param pLinkState: Pointer to link state * @retval DP83848_STATUS_LINK_DOWN if link is down * DP83848_STATUS_AUTONEGO_NOTDONE if Auto nego not completed * DP83848_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD * DP83848_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD * DP83848_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD * DP83848_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_GetLinkState(dp83848_Object_t *pObj) { uint32_t readval = 0; /* Read Status register */ if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BSR, &readval) < 0) { return DP83848_STATUS_READ_ERROR; }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BSR, &readval) < 0) { ... } /* Read Status register again */ if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BSR, &readval) < 0) { return DP83848_STATUS_READ_ERROR; }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BSR, &readval) < 0) { ... } if((readval & DP83848_BSR_LINK_STATUS) == 0) { /* Return Link Down status */ return DP83848_STATUS_LINK_DOWN; }if ((readval & DP83848_BSR_LINK_STATUS) == 0) { ... } /* Check Auto negotiaition */ if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) < 0) { return DP83848_STATUS_READ_ERROR; }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) < 0) { ... } if((readval & DP83848_BCR_AUTONEGO_EN) != DP83848_BCR_AUTONEGO_EN) { if(((readval & DP83848_BCR_SPEED_SELECT) == DP83848_BCR_SPEED_SELECT) && ((readval & DP83848_BCR_DUPLEX_MODE) == DP83848_BCR_DUPLEX_MODE)) { return DP83848_STATUS_100MBITS_FULLDUPLEX; }if (((readval & DP83848_BCR_SPEED_SELECT) == DP83848_BCR_SPEED_SELECT) && ((readval & DP83848_BCR_DUPLEX_MODE) == DP83848_BCR_DUPLEX_MODE)) { ... } else if ((readval & DP83848_BCR_SPEED_SELECT) == DP83848_BCR_SPEED_SELECT) { return DP83848_STATUS_100MBITS_HALFDUPLEX; }else if ((readval & DP83848_BCR_SPEED_SELECT) == DP83848_BCR_SPEED_SELECT) { ... } else if ((readval & DP83848_BCR_DUPLEX_MODE) == DP83848_BCR_DUPLEX_MODE) { return DP83848_STATUS_10MBITS_FULLDUPLEX; }else if ((readval & DP83848_BCR_DUPLEX_MODE) == DP83848_BCR_DUPLEX_MODE) { ... } else { return DP83848_STATUS_10MBITS_HALFDUPLEX; }else { ... } }if ((readval & DP83848_BCR_AUTONEGO_EN) != DP83848_BCR_AUTONEGO_EN) { ... } else /* Auto Nego enabled */ { if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_PHYSCSR, &readval) < 0) { return DP83848_STATUS_READ_ERROR; }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_PHYSCSR, &readval) < 0) { ... } /* Check if auto nego not done */ if((readval & DP83848_PHYSCSR_AUTONEGO_DONE) == 0) { return DP83848_STATUS_AUTONEGO_NOTDONE; }if ((readval & DP83848_PHYSCSR_AUTONEGO_DONE) == 0) { ... } if((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_100BTX_FD) { return DP83848_STATUS_100MBITS_FULLDUPLEX; }if ((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_100BTX_FD) { ... } else if ((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_100BTX_HD) { return DP83848_STATUS_100MBITS_HALFDUPLEX; }else if ((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_100BTX_HD) { ... } else if ((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_10BT_FD) { return DP83848_STATUS_10MBITS_FULLDUPLEX; }else if ((readval & DP83848_PHYSCSR_HCDSPEEDMASK) == DP83848_PHYSCSR_10BT_FD) { ... } else { return DP83848_STATUS_10MBITS_HALFDUPLEX; }else { ... } }else { ... } }{ ... } /** * @brief Set the link state of DP83848 device. * @param pObj: Pointer to device object. * @param pLinkState: link state can be one of the following * DP83848_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD * DP83848_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD * DP83848_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD * DP83848_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_ERROR if parameter error * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_SetLinkState(dp83848_Object_t *pObj, uint32_t LinkState) { uint32_t bcrvalue = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &bcrvalue) >= 0) { /* Disable link config (Auto nego, speed and duplex) */ bcrvalue &= ~(DP83848_BCR_AUTONEGO_EN | DP83848_BCR_SPEED_SELECT | DP83848_BCR_DUPLEX_MODE); if(LinkState == DP83848_STATUS_100MBITS_FULLDUPLEX) { bcrvalue |= (DP83848_BCR_SPEED_SELECT | DP83848_BCR_DUPLEX_MODE); }if (LinkState == DP83848_STATUS_100MBITS_FULLDUPLEX) { ... } else if (LinkState == DP83848_STATUS_100MBITS_HALFDUPLEX) { bcrvalue |= DP83848_BCR_SPEED_SELECT; }else if (LinkState == DP83848_STATUS_100MBITS_HALFDUPLEX) { ... } else if (LinkState == DP83848_STATUS_10MBITS_FULLDUPLEX) { bcrvalue |= DP83848_BCR_DUPLEX_MODE; }else if (LinkState == DP83848_STATUS_10MBITS_FULLDUPLEX) { ... } else { /* Wrong link status parameter */ status = DP83848_STATUS_ERROR; }else { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &bcrvalue) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } if(status == DP83848_STATUS_OK) { /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, bcrvalue) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, bcrvalue) < 0) { ... } }if (status == DP83848_STATUS_OK) { ... } return status; }{ ... } /** * @brief Enable loopback mode. * @param pObj: Pointer to device object. * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_EnableLoopbackMode(dp83848_Object_t *pObj) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { readval |= DP83848_BCR_LOOPBACK; /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @brief Disable loopback mode. * @param pObj: Pointer to device object. * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_DisableLoopbackMode(dp83848_Object_t *pObj) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { readval &= ~DP83848_BCR_LOOPBACK; /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_BCR, readval) < 0) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_BCR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @brief Enable IT source. * @param pObj: Pointer to device object. * @param Interrupt: IT source to be enabled * should be a value or a combination of the following: * DP83848_WOL_IT * DP83848_ENERGYON_IT * DP83848_AUTONEGO_COMPLETE_IT * DP83848_REMOTE_FAULT_IT * DP83848_LINK_DOWN_IT * DP83848_AUTONEGO_LP_ACK_IT * DP83848_PARALLEL_DETECTION_FAULT_IT * DP83848_AUTONEGO_PAGE_RECEIVED_IT * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_EnableIT(dp83848_Object_t *pObj, uint32_t Interrupt) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_IMR, &readval) >= 0) { readval |= Interrupt; /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_IMR, readval) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_IMR, readval) < 0) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_IMR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @brief Disable IT source. * @param pObj: Pointer to device object. * @param Interrupt: IT source to be disabled * should be a value or a combination of the following: * DP83848_WOL_IT * DP83848_ENERGYON_IT * DP83848_AUTONEGO_COMPLETE_IT * DP83848_REMOTE_FAULT_IT * DP83848_LINK_DOWN_IT * DP83848_AUTONEGO_LP_ACK_IT * DP83848_PARALLEL_DETECTION_FAULT_IT * DP83848_AUTONEGO_PAGE_RECEIVED_IT * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register * DP83848_STATUS_WRITE_ERROR if connot write to register *//* ... */ int32_t DP83848_DisableIT(dp83848_Object_t *pObj, uint32_t Interrupt) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_IMR, &readval) >= 0) { readval &= ~Interrupt; /* Apply configuration */ if(pObj->IO.WriteReg(pObj->DevAddr, DP83848_IMR, readval) < 0) { status = DP83848_STATUS_WRITE_ERROR; }if (pObj->IO.WriteReg(pObj->DevAddr, DP83848_IMR, readval) < 0) { ... } }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_IMR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @brief Clear IT flag. * @param pObj: Pointer to device object. * @param Interrupt: IT flag to be cleared * should be a value or a combination of the following: * DP83848_WOL_IT * DP83848_ENERGYON_IT * DP83848_AUTONEGO_COMPLETE_IT * DP83848_REMOTE_FAULT_IT * DP83848_LINK_DOWN_IT * DP83848_AUTONEGO_LP_ACK_IT * DP83848_PARALLEL_DETECTION_FAULT_IT * DP83848_AUTONEGO_PAGE_RECEIVED_IT * @retval DP83848_STATUS_OK if OK * DP83848_STATUS_READ_ERROR if connot read register *//* ... */ int32_t DP83848_ClearIT(dp83848_Object_t *pObj, uint32_t Interrupt) { uint32_t readval = 0; int32_t status = DP83848_STATUS_OK; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_ISFR, &readval) < 0) { status = DP83848_STATUS_READ_ERROR; }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_ISFR, &readval) < 0) { ... } return status; }{ ... } /** * @brief Get IT Flag status. * @param pObj: Pointer to device object. * @param Interrupt: IT Flag to be checked, * should be a value or a combination of the following: * DP83848_WOL_IT * DP83848_ENERGYON_IT * DP83848_AUTONEGO_COMPLETE_IT * DP83848_REMOTE_FAULT_IT * DP83848_LINK_DOWN_IT * DP83848_AUTONEGO_LP_ACK_IT * DP83848_PARALLEL_DETECTION_FAULT_IT * DP83848_AUTONEGO_PAGE_RECEIVED_IT * @retval 1 IT flag is SET * 0 IT flag is RESET * DP83848_STATUS_READ_ERROR if connot read register *//* ... */ int32_t DP83848_GetITStatus(dp83848_Object_t *pObj, uint32_t Interrupt) { uint32_t readval = 0; int32_t status = 0; if(pObj->IO.ReadReg(pObj->DevAddr, DP83848_ISFR, &readval) >= 0) { status = ((readval & Interrupt) == Interrupt); }if (pObj->IO.ReadReg(pObj->DevAddr, DP83848_ISFR, &readval) >= 0) { ... } else { status = DP83848_STATUS_READ_ERROR; }else { ... } return status; }{ ... } /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.