adin1111_driver.c
Go to the documentation of this file.
1 /**
2  * @file adin1111_driver.c
3  * @brief ADIN1111 10Base-T1L Ethernet controller
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.6
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/net.h"
37 #include "debug.h"
38 
39 
40 /**
41  * @brief ADIN1111 driver
42  **/
43 
45 {
47  ETH_MTU,
55  NULL,
56  NULL,
57  NULL,
58  FALSE,
59  TRUE,
60  TRUE,
61  FALSE
62 };
63 
64 
65 /**
66  * @brief ADIN1111 controller initialization
67  * @param[in] interface Underlying network interface
68  * @return Error code
69  **/
70 
72 {
73  uint32_t value;
74 
75  //Debug message
76  TRACE_INFO("Initializing ADIN1111 Ethernet controller...\r\n");
77 
78  //Initialize SPI interface
79  interface->spiDriver->init();
80 
81  //Initialize external interrupt line driver
82  if(interface->extIntDriver != NULL)
83  {
84  interface->extIntDriver->init();
85  }
86 
87  //A full chip software reset can be initiated by writing 1 to the SWRESET
88  //field of the RESET register
90 
91  //Wait for the MAC to exit reset
92  do
93  {
94  //To confirm that the MAC has exited reset, read the PHY identification
95  //register
96  value = adin1111ReadReg(interface, ADIN1111_PHYID);
97 
98  //If the reset value of the register can be read, the device has exited
99  //reset and is ready for configuration
102 
103  //Next, the host must read the STATUS0 register and confirm that the RESETC
104  //field is 1
105  do
106  {
107  //Read the status register 0
108  value = adin1111ReadReg(interface, ADIN1111_STATUS0);
109 
110  //Check the value of the RESETC bit
111  } while((value & ADIN1111_STATUS0_RESETC) == 0);
112 
113  //Write 1 to the RESETC field in the STATUS0 register to clear this field
115 
116  //The system ready bit can also be read to verify that the start-up sequence
117  //is complete and the system is ready for normal operation
118  do
119  {
120  //Read the CRSM status register
122 
123  //Check the value of the CRSM_SYS_RDY bit
124  } while((value & ADIN1111_CRSM_STAT_CRSM_SYS_RDY) == 0);
125 
126  //Dump SPI registers for debugging purpose
127  adin1111DumpReg(interface);
128  //Dump PHY registers for debugging purpose
129  adin1111DumpPhyReg(interface);
130 
131  //Configure MAC address filtering
132  adin1111UpdateMacAddrFilter(interface);
133 
134 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
135  //Configure the SPI protocol engine
139 #else
140  //Enable store and forward mode
141  value = adin1111ReadReg(interface, ADIN1111_CONFIG0);
144 #endif
145 
146  //Enable CRC append in the MAC TX path
147  value = adin1111ReadReg(interface, ADIN1111_CONFIG2);
150 
151  //Clear IMASK0 register
152  adin1111WriteReg(interface, ADIN1111_IMASK0, 0xFFFFFFFF);
153 
154 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
155  //Disable generic SPI protocol interrupts
156  adin1111WriteReg(interface, ADIN1111_IMASK1, 0xFFFFFFFF);
157 #else
158  //Write the IMASK1 register to enable interrupts as required
161 #endif
162 
163  //When the MAC is configured, write 1 to the SYNC field in the CONFIG0
164  //register to indicate that the MAC configuration is complete
165  value = adin1111ReadReg(interface, ADIN1111_CONFIG0);
168 
169  //Enable LED1 output
174 
175  //Configure LED0 and LED1 function
181 
182  //Set LED0 and LED1 polarity
186 
187  //Perform custom configuration
188  adin1111InitHook(interface);
189 
190  //Clear the CRSM_SFT_PD bit to exit software power-down mode. At this point,
191  //the MAC-PHY starts autonegotiation and attempts to bring up a link after
192  //autonegotiation completes
196 
197  //Accept any packets from the upper layer
198  osSetEvent(&interface->nicTxEvent);
199 
200  //Force the TCP/IP stack to poll the link state at startup
201  interface->nicEvent = TRUE;
202  //Notify the TCP/IP stack of the event
203  osSetEvent(&interface->netContext->event);
204 
205  //Successful initialization
206  return NO_ERROR;
207 }
208 
209 
210 /**
211  * @brief ADIN1111 custom configuration
212  * @param[in] interface Underlying network interface
213  **/
214 
215 __weak_func void adin1111InitHook(NetInterface *interface)
216 {
217 }
218 
219 
220 /**
221  * @brief ADIN1111 timer handler
222  * @param[in] interface Underlying network interface
223  **/
224 
225 void adin1111Tick(NetInterface *interface)
226 {
227 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
228  uint32_t value;
229  bool_t linkState;
230 
231  //Read PHY status register
232  value = adin1111ReadReg(interface, ADIN1111_STATUS1);
233  //Retrieve current link state
234  linkState = (value & ADIN1111_STATUS1_P1_LINK_STATUS) ? TRUE : FALSE;
235 
236  //Link up event?
237  if(linkState && !interface->linkState)
238  {
239  //The PHY is only able to operate in 10 Mbps mode
240  interface->linkSpeed = NIC_LINK_SPEED_10MBPS;
241  interface->duplexMode = NIC_FULL_DUPLEX_MODE;
242 
243  //Update link state
244  interface->linkState = TRUE;
245 
246  //Process link state change event
247  nicNotifyLinkChange(interface);
248  }
249  //Link down event?
250  else if(!linkState && interface->linkState)
251  {
252  //Update link state
253  interface->linkState = FALSE;
254 
255  //Process link state change event
256  nicNotifyLinkChange(interface);
257  }
258 #endif
259 }
260 
261 
262 /**
263  * @brief Enable interrupts
264  * @param[in] interface Underlying network interface
265  **/
266 
268 {
269  //Enable interrupts
270  if(interface->extIntDriver != NULL)
271  {
272  interface->extIntDriver->enableIrq();
273  }
274 }
275 
276 
277 /**
278  * @brief Disable interrupts
279  * @param[in] interface Underlying network interface
280  **/
281 
283 {
284  //Disable interrupts
285  if(interface->extIntDriver != NULL)
286  {
287  interface->extIntDriver->disableIrq();
288  }
289 }
290 
291 
292 /**
293  * @brief ADIN1111 interrupt service routine
294  * @param[in] interface Underlying network interface
295  * @return TRUE if a higher priority task must be woken. Else FALSE is returned
296  **/
297 
299 {
300 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
301  //When the SPI host detects an asserted IRQn from the MACPHY, it should
302  //initiate a data chunk transfer to obtain the current data footer
303  interface->nicEvent = TRUE;
304 
305  //Notify the TCP/IP stack of the event
306  return osSetEventFromIsr(&interface->netContext->event);
307 #else
308  bool_t flag;
309  size_t n;
310  uint32_t mask;
311  uint32_t status;
312 
313  //This flag will be set if a higher priority task must be woken
314  flag = FALSE;
315 
316  //Save interrupt mask register value
317  mask = adin1111ReadReg(interface, ADIN1111_IMASK1);
318  //Disable interrupts to release the interrupt line
319  adin1111WriteReg(interface, ADIN1111_IMASK1, 0xFFFFFFFF);
320 
321  //Read interrupt status register
322  status = adin1111ReadReg(interface, ADIN1111_STATUS1);
323 
324  //Link status changed interrupt?
325  if((status & ADIN1111_STATUS1_LINK_CHANGE) != 0)
326  {
327  //Disable link status changed interrupt
329 
330  //Set event flag
331  interface->nicEvent = TRUE;
332  //Notify the TCP/IP stack of the event
333  flag |= osSetEventFromIsr(&interface->netContext->event);
334  }
335 
336  //Packet transmission complete?
337  if((status & ADIN1111_STATUS1_TX_RDY) != 0)
338  {
339  //Clear interrupt flag
341 
342  //The TX_SPACE register indicates the remaining space in the TX FIFO, in
343  //half words
344  n = adin1111ReadReg(interface, ADIN1111_TX_SPACE) &
346 
347  //Verify that there is space for a new frame
349  {
350  //Notify the TCP/IP stack that the transmitter is ready to send
351  flag |= osSetEventFromIsr(&interface->nicTxEvent);
352  }
353  }
354 
355  //Packet received?
356  if((status & ADIN1111_STATUS1_P1_RX_RDY) != 0)
357  {
358  //Disable P1_RX_RDY interrupt
360 
361  //Set event flag
362  interface->nicEvent = TRUE;
363  //Notify the TCP/IP stack of the event
364  flag |= osSetEventFromIsr(&interface->netContext->event);
365  }
366 
367  //Re-enable interrupts once the interrupt has been serviced
369 
370  //A higher priority task must be woken?
371  return flag;
372 #endif
373 }
374 
375 
376 /**
377  * @brief ADIN1111 event handler
378  * @param[in] interface Underlying network interface
379  **/
380 
382 {
383 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
384  uint32_t status;
385 
386  //Read buffer status register
387  status = adin1111ReadReg(interface, ADIN1111_BUFSTS);
388 
389  //Process all the data chunks currently available
390  while((status & ADIN1111_BUFSTS_RCA) != 0)
391  {
392  //Read incoming packet
393  adin1111ReceivePacket(interface);
394 
395  //Read buffer status register
396  status = adin1111ReadReg(interface, ADIN1111_BUFSTS);
397  }
398 #else
399  uint32_t status;
400 
401  //When an interrupt occurs, the system can poll the MAC status registers
402  //(STATUS0 and STATUS1) to determine the origin of the interrupt
403  status = adin1111ReadReg(interface, ADIN1111_STATUS1);
404 
405  //Link status changed interrupt?
406  if((status & ADIN1111_STATUS1_LINK_CHANGE) != 0)
407  {
408  //Clear interrupt flag
411 
412  //Check link state
413  if((status & ADIN1111_STATUS1_P1_LINK_STATUS) != 0)
414  {
415  //The PHY is only able to operate in 10 Mbps mode
416  interface->linkSpeed = NIC_LINK_SPEED_10MBPS;
417  interface->duplexMode = NIC_FULL_DUPLEX_MODE;
418 
419  //Link is up
420  interface->linkState = TRUE;
421  }
422  else
423  {
424  //Link is down
425  interface->linkState = FALSE;
426  }
427 
428  //Process link state change event
429  nicNotifyLinkChange(interface);
430  }
431 
432  //Packet received?
433  if((status & ADIN1111_STATUS1_P1_RX_RDY) != 0)
434  {
435  //Process all pending packets
436  do
437  {
438  //Read incoming packet
439  adin1111ReceivePacket(interface);
440 
441  //Read STATUS1 again
442  status = adin1111ReadReg(interface, ADIN1111_STATUS1);
443 
444  //If the P1_RX_RDY bit is set, another frame is available to read
445  } while((status & ADIN1111_STATUS1_P1_RX_RDY) != 0);
446  }
447 
448  //Re-enable interrupts
451 #endif
452 }
453 
454 
455 /**
456  * @brief Send a packet
457  * @param[in] interface Underlying network interface
458  * @param[in] buffer Multi-part buffer containing the data to send
459  * @param[in] offset Offset to the first data byte
460  * @param[in] ancillary Additional options passed to the stack along with
461  * the packet
462  * @return Error code
463  **/
464 
466  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
467 {
468 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
469  size_t i;
470  size_t j;
471  size_t n;
472  size_t length;
473  uint32_t status;
474  uint32_t header;
475  uint32_t footer;
476  uint8_t chunk[ADIN1111_CHUNK_SIZE];
477 
478  //Retrieve the length of the packet
479  length = netBufferGetLength(buffer) - offset;
480 
481  //Read buffer status register
482  status = adin1111ReadReg(interface, ADIN1111_BUFSTS);
483  //Get the number of data chunks available in the transmit buffer
484  n = (status & ADIN1111_BUFSTS_TXC) >> 8;
485 
486  //Check the number of transmit credits available
488  {
489  //A data transaction consists of multiple chunks
490  for(i = 0; i < length; i += n)
491  {
492  //The default size of the data chunk payload is 64 bytes
494 
495  //Set up a data transfer
498 
499  //Start of packet?
500  if(i == 0)
501  {
502  //The SPI host shall set the SV bit when the beginning of an
503  //Ethernet frame is present in the current transmit data chunk
504  //payload
505  header |= ADIN1111_TX_HEADER_SV;
506  }
507 
508  //End of packet?
509  if((i + n) == length)
510  {
511  //The SPI host shall set the EV bit when the end of an Ethernet
512  //frame is present in the current transmit data chunk payload
513  header |= ADIN1111_TX_HEADER_EV;
514 
515  //When EV is 1, the EBO field shall contain the byte offset into
516  //the transmit data chunk payload that points to the last byte of
517  //the Ethernet frame to transmit
518  header |= ((n - 1) << 8) & ADIN1111_TX_HEADER_EBO;
519  }
520 
521  //The parity bit is calculated over the transmit data header
522  if(adin1111CalcParity(header) != 0)
523  {
524  header |= ADIN1111_CTRL_HEADER_P;
525  }
526 
527  //A chunk is composed of 4 bytes of overhead plus the configured
528  //payload size
529  STORE32BE(header, chunk);
530 
531  //Copy data chunk payload
533  offset + i, n);
534 
535  //Pad frames shorter than the data chunk payload
537  {
540  }
541 
542  //Pull the CS pin low
543  interface->spiDriver->assertCs();
544 
545  //Perform data transaction
546  for(j = 0; j < ADIN1111_CHUNK_SIZE; j++)
547  {
548  chunk[j] = interface->spiDriver->transfer(chunk[j]);
549  }
550 
551  //Terminate the operation by raising the CS pin
552  interface->spiDriver->deassertCs();
553 
554  //Receive data chunks consist of the receive data chunk payload followed
555  //by a 4-byte footer
556  footer = LOAD32BE(chunk + ADIN1111_CHUNK_PAYLOAD_SIZE);
557 
558  //The RCA field indicates the number of receive data chunks available
559  if((footer & ADIN1111_RX_FOOTER_RCA) != 0)
560  {
561  //Some data chunks are available for reading
562  interface->nicEvent = TRUE;
563  //Notify the TCP/IP stack of the event
564  osSetEvent(&interface->netContext->event);
565  }
566  }
567  }
568  else
569  {
570  //No sufficient credits available
571  }
572 
573  //The transmitter can accept another packet
574  osSetEvent(&interface->nicTxEvent);
575 
576  //Successful processing
577  return NO_ERROR;
578 #else
579  static uint8_t temp[ADIN1111_ETH_TX_BUFFER_SIZE];
580  size_t n;
581  size_t length;
582 
583  //Retrieve the length of the packet
584  length = netBufferGetLength(buffer) - offset;
585 
586  //Check the frame length
588  {
589  //The transmitter can accept another packet
590  osSetEvent(&interface->nicTxEvent);
591  //Report an error
592  return ERROR_INVALID_LENGTH;
593  }
594 
595  //The TX_SPACE register indicates the remaining space in the TX FIFO, in
596  //half words
597  n = adin1111ReadReg(interface, ADIN1111_TX_SPACE) &
599 
600  //Ensure that there is sufficient space for the Ethernet frame plus 2-byte
601  //header plus 2-byte size field
602  if((n * 2) < (length + ADIN1111_TX_FIFO_OVERHEAD))
603  {
604  return ERROR_FAILURE;
605  }
606 
607  //Copy user data
608  netBufferRead(temp, buffer, offset, length);
609 
610  //TX_FSIZE is written with the original frame size + 2 bytes for the frame
611  //header
614 
615  //Write TX FIFO
616  adin1111WriteFifo(interface, 0, temp, length);
617 
618  //The TX_SPACE register indicates the remaining space in the TX FIFO, in
619  //half words
620  n = adin1111ReadReg(interface, ADIN1111_TX_SPACE) &
622 
623  //Verify that there is space for a new frame
625  {
626  //The transmitter can accept another packet
627  osSetEvent(&interface->nicTxEvent);
628  }
629 
630  //Successful processing
631  return NO_ERROR;
632 #endif
633 }
634 
635 
636 /**
637  * @brief Receive a packet
638  * @param[in] interface Underlying network interface
639  * @return Error code
640  **/
641 
643 {
644 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
645  static uint8_t buffer[ADIN1111_ETH_RX_BUFFER_SIZE];
646  error_t error;
647  size_t i;
648  size_t n;
649  size_t length;
650  uint32_t header;
651  uint32_t footer;
652  uint8_t chunk[ADIN1111_CHUNK_SIZE];
653 
654  //Initialize variable
655  length = 0;
656 
657  //A data transaction consists of multiple chunks
658  while(1)
659  {
660  //Check the length of the received packet
662  {
663  error = ERROR_BUFFER_OVERFLOW;
664  break;
665  }
666 
667  //The SPI host sets NORX to 0 to indicate that it accepts and process
668  //any receive frame data within the current chunk
669  header = ADIN1111_TX_HEADER_DNC;
670 
671  //The parity bit is calculated over the transmit data header
672  if(adin1111CalcParity(header) != 0)
673  {
674  header |= ADIN1111_CTRL_HEADER_P;
675  }
676 
677  //Transmit data chunks consist of a 4-byte header followed by the
678  //transmit data chunk payload,
679  STORE32BE(header, chunk);
680 
681  //Clear data chunk payload
684 
685  //Pull the CS pin low
686  interface->spiDriver->assertCs();
687 
688  //Perform data transaction
689  for(i = 0; i < ADIN1111_CHUNK_SIZE; i++)
690  {
691  chunk[i] = interface->spiDriver->transfer(chunk[i]);
692  }
693 
694  //Terminate the operation by raising the CS pin
695  interface->spiDriver->deassertCs();
696 
697  //Receive data chunks consist of the receive data chunk payload followed
698  //by a 4-byte footer
699  footer = LOAD32BE(chunk + ADIN1111_CHUNK_PAYLOAD_SIZE);
700 
701  //When the DV bit is 0, the SPI host ignores the chunk payload
702  if((footer & ADIN1111_RX_FOOTER_DV) == 0)
703  {
704  error = ERROR_BUFFER_EMPTY;
705  break;
706  }
707 
708  //When the SV bit is 1, the beginning of an Ethernet frame is present in
709  //the current transmit data chunk payload
710  if(length == 0)
711  {
712  if((footer & ADIN1111_RX_FOOTER_SV) == 0)
713  {
714  error = ERROR_INVALID_PACKET;
715  break;
716  }
717  }
718  else
719  {
720  if((footer & ADIN1111_RX_FOOTER_SV) != 0)
721  {
722  error = ERROR_INVALID_PACKET;
723  break;
724  }
725  }
726 
727  //When EV is 1, the EBO field contains the byte offset into the
728  //receive data chunk payload that points to the last byte of the
729  //received Ethernet frame
730  if((footer & ADIN1111_RX_FOOTER_EV) != 0)
731  {
732  n = ((footer & ADIN1111_RX_FOOTER_EBO) >> 8) + 1;
733  }
734  else
735  {
737  }
738 
739  //Copy data chunk payload
740  osMemcpy(buffer + length, chunk, n);
741  //Adjust the length of the packet
742  length += n;
743 
744  //When the EV bit is 1, the end of an Ethernet frame is present in the
745  //current receive data chunk payload
746  if((footer & ADIN1111_RX_FOOTER_EV) != 0)
747  {
748  NetRxAncillary ancillary;
749 
750  //Additional options can be passed to the stack along with the packet
751  ancillary = NET_DEFAULT_RX_ANCILLARY;
752  //Pass the packet to the upper layer
753  nicProcessPacket(interface, buffer, length, &ancillary);
754 
755  //Successful processing
756  error = NO_ERROR;
757  break;
758  }
759  }
760 
761  //Return status code
762  return error;
763 #else
764  static uint8_t temp[ADIN1111_ETH_RX_BUFFER_SIZE];
765  error_t error;
766  size_t length;
767  uint16_t header;
768 
769  //Get the size of the frame at the head of the RX FIFO in bytes
772 
773  //Any packet pending in the receive buffer?
775  {
776  NetRxAncillary ancillary;
777 
778  //The size of the frame includes the appended header
780  //Read RX FIFO
781  adin1111ReadFifo(interface, &header, temp, length);
782 
783  //Limit the length of the payload
785  //Additional options can be passed to the stack along with the packet
786  ancillary = NET_DEFAULT_RX_ANCILLARY;
787 
788  //Pass the packet to the upper layer
789  nicProcessPacket(interface, temp, length, &ancillary);
790 
791  //Successful processing
792  error = NO_ERROR;
793  }
794  else
795  {
796  //The RX FIFO is empty
797  error = ERROR_BUFFER_EMPTY;
798  }
799 
800  //Return status code
801  return error;
802 #endif
803 }
804 
805 
806 /**
807  * @brief Configure MAC address filtering
808  * @param[in] interface Underlying network interface
809  * @return Error code
810  **/
811 
813 {
814  uint_t i;
815  uint_t j;
816  MacFilterEntry *entry;
817 
818  //Debug message
819  TRACE_DEBUG("Updating MAC filter...\r\n");
820 
821  //Set the upper 16 bits of the broadcast MAC address
825 
826  //Set the lower 32 bits of the broadcast MAC address
829 
830  //Set the upper 16 bits of the station MAC address
833  (interface->macAddr.b[0] << 8) | interface->macAddr.b[1]);
834 
835  //Set the lower 32 bits of the station MAC address
837  (interface->macAddr.b[2] << 24) | (interface->macAddr.b[3] << 16) |
838  (interface->macAddr.b[4] << 8) | interface->macAddr.b[5]);
839 
840  //The MAC address filter contains the list of MAC addresses to accept
841  //when receiving an Ethernet frame
842  for(i = 0, j = 2; i < MAC_ADDR_FILTER_SIZE &&
843  j < ADIN1111_ADDR_TABLE_SIZE; i++)
844  {
845  //Point to the current entry
846  entry = &interface->macAddrFilter[i];
847 
848  //Valid entry?
849  if(entry->refCount > 0)
850  {
851  //Set the upper 16 bits of the current MAC address
854  (entry->addr.b[0] << 8) | entry->addr.b[1]);
855 
856  //Set the lower 32 bits of the current MAC address
858  (entry->addr.b[2] << 24) | (entry->addr.b[3] << 16) |
859  (entry->addr.b[4] << 8) | entry->addr.b[5]);
860 
861  //Increment index
862  j++;
863  }
864  }
865 
866  //Clear unused table entries
867  for(; j < ADIN1111_ADDR_TABLE_SIZE; j++)
868  {
869  //Clear current MAC address
870  adin1111WriteReg(interface, ADIN1111_ADDR_FILT_UPRn(j), 0);
871  adin1111WriteReg(interface, ADIN1111_ADDR_FILT_LWRn(j), 0);
872  }
873 
874  //Successful processing
875  return NO_ERROR;
876 }
877 
878 
879 /**
880  * @brief Write SPI register
881  * @param[in] interface Underlying network interface
882  * @param[in] address Register address
883  * @param[in] data System register value
884  **/
885 
886 void adin1111WriteReg(NetInterface *interface, uint16_t address,
887  uint32_t data)
888 {
889 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
890  uint32_t header;
891 
892  //Set up a register write operation
894 
895  //The MMS field selects the specific register memory map to access
896  if(address < 0x30)
897  {
898  header |= (ADIN1111_MMS_STD << 24) & ADIN1111_CTRL_HEADER_MMS;
899  }
900  else
901  {
902  header |= (ADIN1111_MMS_MAC << 24) & ADIN1111_CTRL_HEADER_MMS;
903  }
904 
905  //Address of the first register to access
906  header |= (address << 8) & ADIN1111_CTRL_HEADER_ADDR;
907  //Specifies the number of registers to write
908  header |= (0 << 1) & ADIN1111_CTRL_HEADER_LEN;
909 
910  //The parity bit is calculated over the control command header
911  if(adin1111CalcParity(header) != 0)
912  {
913  header |= ADIN1111_CTRL_HEADER_P;
914  }
915 
916  //Pull the CS pin low
917  interface->spiDriver->assertCs();
918 
919  //Write control command header
920  interface->spiDriver->transfer((header >> 24) & 0xFF);
921  interface->spiDriver->transfer((header >> 16) & 0xFF);
922  interface->spiDriver->transfer((header >> 8) & 0xFF);
923  interface->spiDriver->transfer(header & 0xFF);
924 
925  //Write data
926  interface->spiDriver->transfer((data >> 24) & 0xFF);
927  interface->spiDriver->transfer((data >> 16) & 0xFF);
928  interface->spiDriver->transfer((data >> 8) & 0xFF);
929  interface->spiDriver->transfer(data & 0xFF);
930 
931 #if (ADIN1111_PROTECTION_SUPPORT == ENABLED)
932  //Protection is accomplished by duplication of each 32-bit word containing
933  //register data with its ones' complement
934  data = ~data;
935 
936  //Write complement
937  interface->spiDriver->transfer((data >> 24) & 0xFF);
938  interface->spiDriver->transfer((data >> 16) & 0xFF);
939  interface->spiDriver->transfer((data >> 8) & 0xFF);
940  interface->spiDriver->transfer(data & 0xFF);
941 #endif
942 
943  //Send 32 bits of dummy data at the end of the control write command
944  interface->spiDriver->transfer(0x00);
945  interface->spiDriver->transfer(0x00);
946  interface->spiDriver->transfer(0x00);
947  interface->spiDriver->transfer(0x00);
948 
949  //Terminate the operation by raising the CS pin
950  interface->spiDriver->deassertCs();
951 #else
952  //Pull the CS pin low
953  interface->spiDriver->assertCs();
954 
955  //Write command
956  interface->spiDriver->transfer(ADIN1111_SPI_CMD_WRITE | (address >> 8));
957  interface->spiDriver->transfer(address & 0xFF);
958 
959  //Write data
960  interface->spiDriver->transfer((data >> 24) & 0xFF);
961  interface->spiDriver->transfer((data >> 16) & 0xFF);
962  interface->spiDriver->transfer((data >> 8) & 0xFF);
963  interface->spiDriver->transfer(data & 0xFF);
964 
965  //Terminate the operation by raising the CS pin
966  interface->spiDriver->deassertCs();
967 #endif
968 }
969 
970 
971 /**
972  * @brief Read SPI register
973  * @param[in] interface Underlying network interface
974  * @param[in] address System register address
975  * @return Register value
976  **/
977 
978 uint32_t adin1111ReadReg(NetInterface *interface, uint16_t address)
979 {
980 #if (ADIN1111_OA_SPI_SUPPORT == ENABLED)
981  uint32_t data;
982  uint32_t header;
983 
984  //Set up a register read operation
985  header = ADIN1111_CTRL_HEADER_AID;
986 
987  //The MMS field selects the specific register memory map to access
988  if(address < 0x30)
989  {
990  header |= (ADIN1111_MMS_STD << 24) & ADIN1111_CTRL_HEADER_MMS;
991  }
992  else
993  {
994  header |= (ADIN1111_MMS_MAC << 24) & ADIN1111_CTRL_HEADER_MMS;
995  }
996 
997  //Address of the first register to access
998  header |= (address << 8) & ADIN1111_CTRL_HEADER_ADDR;
999  //Specifies the number of registers to read
1000  header |= (0 << 1) & ADIN1111_CTRL_HEADER_LEN;
1001 
1002  //The parity bit is calculated over the control command header
1003  if(adin1111CalcParity(header) != 0)
1004  {
1005  header |= ADIN1111_CTRL_HEADER_P;
1006  }
1007 
1008  //Pull the CS pin low
1009  interface->spiDriver->assertCs();
1010 
1011  //Write control command header
1012  interface->spiDriver->transfer((header >> 24) & 0xFF);
1013  interface->spiDriver->transfer((header >> 16) & 0xFF);
1014  interface->spiDriver->transfer((header >> 8) & 0xFF);
1015  interface->spiDriver->transfer(header & 0xFF);
1016 
1017  //Discard the echoed control header
1018  interface->spiDriver->transfer(0x00);
1019  interface->spiDriver->transfer(0x00);
1020  interface->spiDriver->transfer(0x00);
1021  interface->spiDriver->transfer(0x00);
1022 
1023  //Read data
1024  data = interface->spiDriver->transfer(0x00) << 24;
1025  data |= interface->spiDriver->transfer(0x00) << 16;
1026  data |= interface->spiDriver->transfer(0x00) << 8;
1027  data |= interface->spiDriver->transfer(0x00);
1028 
1029 #if (ADIN1111_PROTECTION_SUPPORT == ENABLED)
1030  //Protection is accomplished by duplication of each 32-bit word containing
1031  //register data with its ones' complement
1032  interface->spiDriver->transfer(0x00);
1033  interface->spiDriver->transfer(0x00);
1034  interface->spiDriver->transfer(0x00);
1035  interface->spiDriver->transfer(0x00);
1036 #endif
1037 
1038  //Terminate the operation by raising the CS pin
1039  interface->spiDriver->deassertCs();
1040 
1041  //Return register value
1042  return data;
1043 #else
1044  uint32_t data;
1045 
1046  //Pull the CS pin low
1047  interface->spiDriver->assertCs();
1048 
1049  //Write command
1050  interface->spiDriver->transfer(ADIN1111_SPI_CMD_READ | (address >> 8));
1051  interface->spiDriver->transfer(address & 0xFF);
1052 
1053  //Turn around
1054  interface->spiDriver->transfer(0x00);
1055 
1056  //Read data
1057  data = interface->spiDriver->transfer(0x00) << 24;
1058  data |= interface->spiDriver->transfer(0x00) << 16;
1059  data |= interface->spiDriver->transfer(0x00) << 8;
1060  data |= interface->spiDriver->transfer(0x00);
1061 
1062  //Terminate the operation by raising the CS pin
1063  interface->spiDriver->deassertCs();
1064 
1065  //Return register value
1066  return data;
1067 #endif
1068 }
1069 
1070 
1071 /**
1072  * @brief Dump SPI registers for debugging purpose
1073  * @param[in] interface Underlying network interface
1074  **/
1075 
1077 {
1078  uint16_t i;
1079 
1080  //Loop through system registers
1081  for(i = 0; i < 256; i++)
1082  {
1083  //Display current SPI register
1084  TRACE_DEBUG("0x%02" PRIX16 ": 0x%08" PRIX32 "\r\n", i,
1085  adin1111ReadReg(interface, i));
1086  }
1087 
1088  //Terminate with a line feed
1089  TRACE_DEBUG("\r\n");
1090 }
1091 
1092 
1093 /**
1094  * @brief Write PHY register
1095  * @param[in] interface Underlying network interface
1096  * @param[in] address PHY register address
1097  * @param[in] data Register value
1098  **/
1099 
1100 void adin1111WritePhyReg(NetInterface *interface, uint8_t address,
1101  uint16_t data)
1102 {
1103  uint32_t value;
1104 
1105  //Perform a Clause 22 write operation
1107  //Set PHY address
1109  //Set register address
1111  //Set register value
1113 
1114  //Write MDIOACC0 register
1116 
1117  //Poll MDIOACC0.TRDONE to determine that the write operation has completed
1118  do
1119  {
1120  //Read MDIOACC0 register
1121  value = adin1111ReadReg(interface, ADIN1111_MDIOACC0);
1122 
1123  //When the MDIO transaction completes, the TRDONE bit is set to 1
1124  } while((value & ADIN1111_MDIOACC_MDIO_TRDONE) == 0);
1125 }
1126 
1127 
1128 /**
1129  * @brief Read PHY register
1130  * @param[in] interface Underlying network interface
1131  * @param[in] address PHY register address
1132  * @return Register value
1133  **/
1134 
1135 uint16_t adin1111ReadPhyReg(NetInterface *interface, uint8_t address)
1136 {
1137  uint32_t value;
1138 
1139  //Perform a Clause 22 read operation
1141  //Set PHY address
1143  //Set register address
1145 
1146  //Write MDIOACC0 register
1148 
1149  //Poll MDIOACC0.TRDONE to determine that the read operation has completed
1150  do
1151  {
1152  //Read MDIOACC0 register
1153  value = adin1111ReadReg(interface, ADIN1111_MDIOACC0);
1154 
1155  //When the MDIO transaction completes, the TRDONE bit is set to 1
1156  } while((value & ADIN1111_MDIOACC_MDIO_TRDONE) == 0);
1157 
1158  //MDIOACC0.MDIO_DATA reflects the content of register
1160 }
1161 
1162 
1163 /**
1164  * @brief Dump PHY registers for debugging purpose
1165  * @param[in] interface Underlying network interface
1166  **/
1167 
1169 {
1170  uint8_t i;
1171 
1172  //Loop through PHY registers
1173  for(i = 0; i < 32; i++)
1174  {
1175  //Display current PHY register
1176  TRACE_DEBUG("%02" PRIu8 ": 0x%04" PRIX16 "\r\n", i,
1177  adin1111ReadPhyReg(interface, i));
1178  }
1179 
1180  //Terminate with a line feed
1181  TRACE_DEBUG("\r\n");
1182 }
1183 
1184 
1185 /**
1186  * @brief Write MMD register
1187  * @param[in] interface Underlying network interface
1188  * @param[in] devAddr Device address
1189  * @param[in] regAddr Register address
1190  * @param[in] data MMD register value
1191  **/
1192 
1193 void adin1111WriteMmdReg(NetInterface *interface, uint8_t devAddr,
1194  uint16_t regAddr, uint16_t data)
1195 {
1196  uint32_t value;
1197 
1198  //Perform a Clause 45 address write operation
1200  //MDIO_PRTAD is always written to 1
1202  //Set device address
1203  value |= (devAddr << 16) & ADIN1111_MDIOACC_MDIO_DEVAD;
1204  //Set register address
1206 
1207  //Write MDIOACC0 register
1209 
1210  //Perform a Clause 45 write operation
1212  //MDIO_PRTAD is always written to 1
1214  //Set device address
1215  value |= (devAddr << 16) & ADIN1111_MDIOACC_MDIO_DEVAD;
1216  //Set register value
1218 
1219  //Write MDIOACC1 register
1221 
1222  //Poll MDIOACC1.TRDONE to determine that the write operation has completed
1223  do
1224  {
1225  //Read MDIOACC1 register
1226  value = adin1111ReadReg(interface, ADIN1111_MDIOACC1);
1227 
1228  //When the MDIO transaction completes, the TRDONE bit is set to 1
1229  } while((value & ADIN1111_MDIOACC_MDIO_TRDONE) == 0);
1230 }
1231 
1232 
1233 /**
1234  * @brief Read MMD register
1235  * @param[in] interface Underlying network interface
1236  * @param[in] devAddr Device address
1237  * @param[in] regAddr Register address
1238  * @return MMD register value
1239  **/
1240 
1241 uint16_t adin1111ReadMmdReg(NetInterface *interface, uint8_t devAddr,
1242  uint16_t regAddr)
1243 {
1244  uint32_t value;
1245 
1246  //Perform a Clause 45 address write operation
1248  //MDIO_PRTAD is always written to 1
1250  //Set device address
1251  value |= (devAddr << 16) & ADIN1111_MDIOACC_MDIO_DEVAD;
1252  //Set register address
1254 
1255  //Write MDIOACC0 register
1257 
1258  //Perform a Clause 45 read operation
1260  //MDIO_PRTAD is always written to 1
1262  //Set device address
1263  value |= (devAddr << 16) & ADIN1111_MDIOACC_MDIO_DEVAD;
1264 
1265  //Write MDIOACC1 register
1267 
1268  //Poll MDIOACC1.TRDONE to determine that the read operation has completed
1269  do
1270  {
1271  //Read MDIOACC1 register
1272  value = adin1111ReadReg(interface, ADIN1111_MDIOACC1);
1273 
1274  //When the MDIO transaction completes, the TRDONE bit is set to 1
1275  } while((value & ADIN1111_MDIOACC_MDIO_TRDONE) == 0);
1276 
1277  //MDIOACC1.MDIO_DATA reflects the content of register
1279 }
1280 
1281 
1282 /**
1283  * @brief Write TX FIFO
1284  * @param[in] interface Underlying network interface
1285  * @param[in] header Frame header
1286  * @param[in] data Pointer to the data being written
1287  * @param[in] length Number of data to write
1288  **/
1289 
1290 void adin1111WriteFifo(NetInterface *interface, uint16_t header,
1291  const uint8_t *data, size_t length)
1292 {
1293 #if (ADIN1111_OA_SPI_SUPPORT == DISABLED)
1294  size_t i;
1295 
1296  //Pull the CS pin low
1297  interface->spiDriver->assertCs();
1298 
1299  //Write command
1300  interface->spiDriver->transfer(ADIN1111_SPI_CMD_WRITE | (ADIN1111_TX >> 8));
1301  interface->spiDriver->transfer(ADIN1111_TX & 0xFF);
1302 
1303  //The 2-byte frame header is appended to all transmitted frames. This always
1304  //precedes the frame data
1305  interface->spiDriver->transfer((header >> 8) & 0xFF);
1306  interface->spiDriver->transfer(header & 0xFF);
1307 
1308  //Write frame data
1309  for(i = 0; i < length; i++)
1310  {
1311  interface->spiDriver->transfer(data[i]);
1312  }
1313 
1314  //The burst write data must always be in multiples of 4 bytes
1315  for(; ((i + ADIN1111_FRAME_HEADER_SIZE) % 4) != 0; i++)
1316  {
1317  interface->spiDriver->transfer(0x00);
1318  }
1319 
1320  //Terminate the operation by raising the CS pin
1321  interface->spiDriver->deassertCs();
1322 #endif
1323 }
1324 
1325 
1326 /**
1327  * @brief Read RX FIFO
1328  * @param[in] interface Underlying network interface
1329  * @param[out] header Frame header
1330  * @param[out] data Buffer where to store the incoming data
1331  * @param[in] length Number of data to read
1332  **/
1333 
1334 void adin1111ReadFifo(NetInterface *interface, uint16_t *header,
1335  uint8_t *data, size_t length)
1336 {
1337 #if (ADIN1111_OA_SPI_SUPPORT == DISABLED)
1338  size_t i;
1339 
1340  //Pull the CS pin low
1341  interface->spiDriver->assertCs();
1342 
1343  //Write command
1344  interface->spiDriver->transfer(ADIN1111_SPI_CMD_READ | (ADIN1111_P1_RX >> 8));
1345  interface->spiDriver->transfer(ADIN1111_P1_RX & 0xFF);
1346 
1347  //Turn around
1348  interface->spiDriver->transfer(0x00);
1349 
1350  //The 2-byte frame header is appended to all received frames. This always
1351  //precedes the frame data
1352  *header = interface->spiDriver->transfer(0x00) << 16;
1353  *header |= interface->spiDriver->transfer(0x00);
1354 
1355  //Read frame data
1356  for(i = 0; i < length && i < ADIN1111_ETH_RX_BUFFER_SIZE; i++)
1357  {
1358  data[i] = interface->spiDriver->transfer(0x00);
1359  }
1360 
1361  //Discard extra bytes
1362  for(; i < length; i++)
1363  {
1364  interface->spiDriver->transfer(0x00);
1365  }
1366 
1367  //The burst read data must always be in multiples of 4 bytes
1368  for(; ((i + ADIN1111_FRAME_HEADER_SIZE) % 4) != 0; i++)
1369  {
1370  interface->spiDriver->transfer(0x00);
1371  }
1372 
1373  //Terminate the operation by raising the CS pin
1374  interface->spiDriver->deassertCs();
1375 #endif
1376 }
1377 
1378 
1379 /**
1380  * @brief Calculate parity bit over a 32-bit data
1381  * @param[in] data 32-bit bit stream
1382  * @return Odd parity bit computed over the supplied data
1383  **/
1384 
1385 uint32_t adin1111CalcParity(uint32_t data)
1386 {
1387  //Calculate the odd parity bit computed over the supplied bit stream
1388  data ^= data >> 1;
1389  data ^= data >> 2;
1390  data ^= data >> 4;
1391  data ^= data >> 8;
1392  data ^= data >> 16;
1393 
1394  //Return '1' when the number of bits set to one in the supplied bit
1395  //stream is even (resulting in an odd number of ones when the parity is
1396  //included), otherwise return '0'
1397  return ~data & 0x01;
1398 }
1399 
1400 
1401 /**
1402  * @brief CRC calculation
1403  * @param[in] data Pointer to the data over which to calculate the CRC
1404  * @param[in] length Number of bytes to process
1405  * @return Resulting CRC value
1406  **/
1407 
1408 uint8_t adin1111CalcCrc(const uint8_t *data, size_t length)
1409 {
1410  size_t i;
1411  uint_t j;
1412  uint8_t crc;
1413 
1414  //CRC preset value
1415  crc = 0x00;
1416 
1417  //Loop through data
1418  for(i = 0; i < length; i++)
1419  {
1420  //Update CRC value
1421  crc ^= data[i];
1422 
1423  //The message is processed bit by bit
1424  for(j = 0; j < 8; j++)
1425  {
1426  if((crc & 0x80) != 0)
1427  {
1428  crc = (crc << 1) ^ 0x07;
1429  }
1430  else
1431  {
1432  crc <<= 1;
1433  }
1434  }
1435  }
1436 
1437  //Return CRC value
1438  return crc;
1439 }
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void nicNotifyLinkChange(NetInterface *interface)
Process link state change notification.
Definition: nic.c:601
#define ADIN1111_ADDR_FILT_LWR_MAC_ADDR_31_0
#define ADIN1111_IMASK1_LINK_CHANGE_MASK
uint16_t adin1111ReadMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr)
Read MMD register.
#define ADIN1111_TX_SPACE_TX_SPACE
#define ADIN1111_MMS_MAC
#define ADIN1111_CTRL_HEADER_LEN
#define ADIN1111_PHYID_OUI_DEFAULT
int bool_t
Definition: compiler_port.h:63
#define ADIN1111_CONFIG0_RXCTE
#define ADIN1111_LED_POLARITY
#define ADIN1111_ADDR_FILT_UPRn(index)
@ NIC_FULL_DUPLEX_MODE
Definition: nic.h:125
#define ADIN1111_RX_FOOTER_SV
#define LOAD32BE(p)
Definition: cpu_endian.h:210
@ ERROR_BUFFER_OVERFLOW
Definition: error.h:143
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Definition: net_mem.c:690
#define ADIN1111_MDIOACC_MDIO_OP_READ
void adin1111ReadFifo(NetInterface *interface, uint16_t *header, uint8_t *data, size_t length)
Read RX FIFO.
void adin1111EventHandler(NetInterface *interface)
ADIN1111 event handler.
#define ADIN1111_CTRL_HEADER_P
#define ADIN1111_P1_RX_FSIZE_P1_RX_FRM_SIZE
#define ADIN1111_P1_RX_FSIZE
#define ADIN1111_TX_FIFO_OVERHEAD
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
#define ADIN1111_CTRL_HEADER_AID
#define ADIN1111_LED_POLARITY_LED1_POLARITY_AUTOSENSE
#define MAC_ADDR_FILTER_SIZE
Definition: ethernet.h:95
#define TRUE
Definition: os_port.h:50
void adin1111WriteMmdReg(NetInterface *interface, uint8_t devAddr, uint16_t regAddr, uint16_t data)
Write MMD register.
#define ADIN1111_RX_FOOTER_RCA
uint8_t data[]
Definition: ethernet.h:224
#define ADIN1111_MDIOACC_MDIO_PRTAD_DEFAULT
#define ADIN1111_MDIOACC_MDIO_DATA
error_t adin1111ReceivePacket(NetInterface *interface)
Receive a packet.
uint_t refCount
Reference count for the current entry.
Definition: ethernet.h:266
#define ADIN1111_CRSM_STAT
#define ADIN1111_CRSM_SFT_PD_CNTRL
#define ADIN1111_TX_HEADER_DNC
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:418
#define ADIN1111_RX_FOOTER_EBO
#define ADIN1111_ADDR_FILT_UPR_TO_HOST
#define ADIN1111_IMASK0
#define ADIN1111_RESET_SWRESET
#define ADIN1111_LED_CNTRL_LED0_EN
#define ADIN1111_LED_CNTRL_LED1_FUNCTION_MASTER
#define ADIN1111_LED_CNTRL_LED0_FUNCTION_LINKUP_TXRX_ACTIVITY
#define FALSE
Definition: os_port.h:46
#define ADIN1111_TX_FSIZE
#define ADIN1111_TX_HEADER_DV
#define ADIN1111_CRSM_SFT_PD_CNTRL_CRSM_SFT_PD
#define osMemcpy(dest, src, length)
Definition: os_port.h:147
uint32_t adin1111CalcParity(uint32_t data)
Calculate parity bit over a 32-bit data.
error_t adin1111Init(NetInterface *interface)
ADIN1111 controller initialization.
#define ADIN1111_PHYID_MODEL_DEFAULT
error_t
Error codes.
Definition: error.h:43
void adin1111WriteFifo(NetInterface *interface, uint16_t header, const uint8_t *data, size_t length)
Write TX FIFO.
void adin1111WriteReg(NetInterface *interface, uint16_t address, uint32_t data)
Write SPI register.
#define ADIN1111_TX_SPACE
#define ADIN1111_STATUS1_P1_LINK_STATUS
#define ADIN1111_CONFIG2_CRC_APPEND
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:103
#define ADIN1111_MDIOACC_MDIO_ST_CLAUSE_22
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define ADIN1111_MDIOACC_MDIO_TRDONE
#define NetRxAncillary
Definition: net_misc.h:40
#define ADIN1111_CTRL_HEADER_MMS
@ ERROR_INVALID_PACKET
Definition: error.h:141
#define NetInterface
Definition: net.h:40
void adin1111EnableIrq(NetInterface *interface)
Enable interrupts.
MacAddr addr
MAC address.
Definition: ethernet.h:265
@ NIC_LINK_SPEED_10MBPS
Definition: nic.h:111
@ ERROR_INVALID_LENGTH
Definition: error.h:111
@ ERROR_BUFFER_EMPTY
Definition: error.h:142
#define ADIN1111_CHUNK_PAYLOAD_SIZE
void adin1111DisableIrq(NetInterface *interface)
Disable interrupts.
#define ADIN1111_CONFIG0_TXCTHRESH_16_CREDITS
#define NetTxAncillary
Definition: net_misc.h:36
uint8_t mask
Definition: web_socket.h:319
#define ADIN1111_IMASK1
#define ADIN1111_CTRL_HEADER_WNR
#define ADIN1111_LED_CNTRL
#define ADIN1111_BUFSTS_TXC
#define ADIN1111_STATUS1_P1_RX_RDY
#define ADIN1111_CONFIG0
#define ADIN1111_CTRL_HEADER_ADDR
#define TRACE_INFO(...)
Definition: debug.h:105
__weak_func void adin1111InitHook(NetInterface *interface)
ADIN1111 custom configuration.
#define ADIN1111_CHUNK_HEADER_SIZE
uint8_t length
Definition: tcp.h:375
error_t adin1111UpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
ADIN1111 10Base-T1L Ethernet controller.
#define ADIN1111_ETH_TX_BUFFER_SIZE
#define MIN(a, b)
Definition: os_port.h:63
#define ADIN1111_LED_CNTRL_LED1_EN
uint32_t adin1111ReadReg(NetInterface *interface, uint16_t address)
Read SPI register.
#define ADIN1111_CONFIG2
#define ADIN1111_IMASK1_P1_RX_RDY_MASK
#define ADIN1111_STATUS1
#define ADIN1111_LED_POLARITY_LED0_POLARITY_AUTOSENSE
#define ADIN1111_MDIOACC1
#define ADIN1111_PHYID_REVISION_DEFAULT
#define TRACE_DEBUG(...)
Definition: debug.h:119
#define ADIN1111_MMS_STD
#define ADIN1111_CONFIG0_CSARFE
#define ADIN1111_ADDR_FILT_UPR_APPLY2PORT1
#define ADIN1111_DIGIO_PINMUX_DIGIO_LED1_PINMUX
#define ADIN1111_RESET
uint16_t regAddr
uint8_t adin1111CalcCrc(const uint8_t *data, size_t length)
CRC calculation.
#define ADIN1111_IMASK1_TX_RDY_MASK
#define ADIN1111_DIGIO_PINMUX_DIGIO_LED1_PINMUX_LED_1
#define ETH_MTU
Definition: ethernet.h:116
uint8_t n
#define ADIN1111_RX_FOOTER_EV
MAC filter table entry.
Definition: ethernet.h:264
Ipv6Addr address[]
Definition: ipv6.h:347
#define ADIN1111_MDIOACC_MDIO_DEVAD
#define ADIN1111_RX_FOOTER_DV
#define ADIN1111_STATUS0_RESETC
#define ADIN1111_CONFIG0_TXCTE
#define ADIN1111_TX_HEADER_EV
#define ADIN1111_CONFIG0_ZARFE
#define ADIN1111_PHYID
uint8_t value[]
Definition: tcp.h:376
#define ADIN1111_ADDR_FILT_UPR_MAC_ADDR_47_32
#define ADIN1111_CRSM_STAT_CRSM_SYS_RDY
#define ADIN1111_BUFSTS
const NicDriver adin1111Driver
ADIN1111 driver.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define ADIN1111_ADDR_FILT_LWRn(index)
#define ADIN1111_STATUS1_TX_RDY
#define ADIN1111_ADDR_TABLE_SIZE
#define ADIN1111_DIGIO_PINMUX
#define ADIN1111_MDIOACC_MDIO_ST_CLAUSE_45
#define ADIN1111_STATUS0
#define ADIN1111_STATUS1_LINK_CHANGE
uint16_t adin1111ReadPhyReg(NetInterface *interface, uint8_t address)
Read PHY register.
void adin1111DumpPhyReg(NetInterface *interface)
Dump PHY registers for debugging purpose.
#define ADIN1111_SPI_CMD_READ
#define ADIN1111_MDIOACC_MDIO_OP_ADDR
void adin1111Tick(NetInterface *interface)
ADIN1111 timer handler.
#define ADIN1111_P1_RX
unsigned int uint_t
Definition: compiler_port.h:57
#define osMemset(p, value, length)
Definition: os_port.h:141
TCP/IP stack core.
void adin1111DumpReg(NetInterface *interface)
Dump SPI registers for debugging purpose.
NIC driver.
Definition: nic.h:286
#define ADIN1111_CONFIG0_SYNC
#define ADIN1111_BUFSTS_RCA
#define ADIN1111_MDIOACC0
#define ADIN1111_TX
#define ADIN1111_TX_HEADER_EBO
bool_t adin1111IrqHandler(NetInterface *interface)
ADIN1111 interrupt service routine.
#define STORE32BE(a, p)
Definition: cpu_endian.h:286
#define ADIN1111_ETH_RX_BUFFER_SIZE
#define ADIN1111_CONFIG0_CPS_64B
void adin1111WritePhyReg(NetInterface *interface, uint8_t address, uint16_t data)
Write PHY register.
#define ADIN1111_TX_HEADER_SV
#define ADIN1111_CHUNK_SIZE
#define ADIN1111_FRAME_HEADER_SIZE
@ NO_ERROR
Success.
Definition: error.h:44
error_t adin1111SendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
Debugging facilities.
#define ADIN1111_TX_HEADER_NORX
#define ADIN1111_SPI_CMD_WRITE
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83
#define ADIN1111_MDIOACC_MDIO_OP_WRITE