45 #ifdef oC_ETH_LLD_AVAILABLE 52 #define _________________________________________DRIVER_DEFINITIONS_SECTION_________________________________________________________________ 57 #define DRIVER_NAME ETH 58 #define DRIVER_FILE_NAME "eth" 59 #define DRIVER_TYPE NETWORK_DRIVER 60 #define DRIVER_VERSION oC_Driver_MakeVersion(1,0,0) 61 #define REQUIRED_DRIVERS &GPIO 62 #define REQUIRED_BOOT_LEVEL oC_Boot_Level_RequireMemoryManager | oC_Boot_Level_RequireDriversManager | oC_Boot_Level_RequireNetwork 65 #define DRIVER_CONFIGURE oC_ETH_Configure 66 #define DRIVER_UNCONFIGURE oC_ETH_Unconfigure 67 #define DRIVER_TURN_ON oC_ETH_TurnOn 68 #define DRIVER_TURN_OFF oC_ETH_TurnOff 69 #define IS_TURNED_ON oC_ETH_IsTurnedOn 70 #define SEND_FRAME oC_ETH_SendFrame 71 #define RECEIVE_FRAME oC_ETH_ReceiveFrame 72 #define SET_WAKE_ON_LAN_EVENT oC_ETH_SetWakeOnLanEvent 73 #define FLUSH oC_ETH_Flush 74 #define SET_LOOPBACK oC_ETH_SetLoopback 75 #define PERFORM_DIAGNOSTIC oC_ETH_PerformDiagnostics 76 #define READ_NET_INFO oC_ETH_ReadNetInfo 78 #undef _________________________________________DRIVER_DEFINITIONS_SECTION_________________________________________________________________ 88 #define _________________________________________TYPES_SECTION______________________________________________________________________________ 115 #undef _________________________________________TYPES_SECTION______________________________________________________________________________ 122 #define _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________ 138 #undef _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________ 145 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________ 176 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________ 184 #define _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________ 202 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
207 errorCode = oC_ETH_LLD_TurnOnDriver();
209 if(errorCode == oC_ErrorCode_ModuleIsTurnedOn)
211 errorCode = oC_ErrorCode_None;
214 if(!oC_ErrorOccur(errorCode))
216 DataReadyToRead = oC_Event_New(oC_Event_State_Inactive, &Allocator, AllocationFlags_ZeroFill);
217 ModuleReadyToSend = oC_Event_New(oC_Event_State_Active, &Allocator, AllocationFlags_ZeroFill);
221 && ErrorCondition ( DataReadyToRead !=
NULL, oC_ErrorCode_AllocationError )
222 && ErrorCondition ( ModuleReadyToSend !=
NULL, oC_ErrorCode_AllocationError )
227 errorCode = oC_ErrorCode_None;
231 oC_SaveIfFalse(
"ETH:TurnOn - Cannot delete event DataReadyToRead" , oC_Event_Delete(&DataReadyToRead, AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
232 oC_SaveIfFalse(
"ETH:TurnOn - Cannot delete event ModuleReadyToSend", oC_Event_Delete(&ModuleReadyToSend, AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
252 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
259 errorCode = oC_ETH_LLD_TurnOffDriver();
262 errorCode == oC_ErrorCode_ModuleNotStartedYet)
265 errorCode = oC_ErrorCode_None;
268 oC_SaveIfFalse(
"ETH:TurnOn - Cannot delete event DataReadyToRead" , oC_Event_Delete(&DataReadyToRead, AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
269 oC_SaveIfFalse(
"ETH:TurnOn - Cannot delete event ModuleReadyToSend", oC_Event_Delete(&ModuleReadyToSend, AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
311 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
318 ErrorCondition( isaddresscorrect(Config) , oC_ErrorCode_WrongConfigAddress )
319 && ErrorCondition( isaddresscorrect(Config->
PhyChipInfo) , oC_ErrorCode_ChipNotDefined )
320 && ErrorCondition( isram(outContext) , oC_ErrorCode_OutputAddressNotInRAM )
330 && ErrorCode( oC_ETH_LLD_SetMacAddress ( &context->
Result , 0 , Config->
MacAddress ))
331 && ErrorCode( oC_ETH_LLD_Start ( &Config->
LLD ))
334 *outContext = context;
335 errorCode = oC_ErrorCode_None;
339 oC_SaveIfErrorOccur(
"ETH: Cannot release PHY - ",
ReleasePhy( Config , context ));
340 oC_SaveIfErrorOccur(
"ETH: Cannot release MAC - ", oC_ETH_LLD_ReleaseMac( &Config->
LLD , &Config->
PhyChipInfo->
LLD , &context->
Result ));
341 oC_SaveIfErrorOccur(
"ETH: Cannot delete context - ",
DeleteContext( &context ));
363 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
368 ErrorCondition( isaddresscorrect(Config) , oC_ErrorCode_WrongConfigAddress )
369 && ErrorCondition( isram(outContext) , oC_ErrorCode_OutputAddressNotInRAM )
370 && ErrorCondition(
IsContextCorrect(*outContext) , oC_ErrorCode_ContextNotCorrect )
371 && ErrorCode (
ReleasePhy(Config,*outContext) )
372 && ErrorCode ( oC_ETH_LLD_ReleaseMac(&Config->
LLD, &Config->
PhyChipInfo->
LLD, &(*outContext)->Result) )
377 errorCode = oC_ErrorCode_None;
410 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
415 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect )
416 && ErrorCondition( isaddresscorrect(Frame) , oC_ErrorCode_WrongAddress )
417 && ErrorCondition( isaddresscorrect(Frame->
Packet) , oC_ErrorCode_WrongAddress )
418 && ErrorCondition( Frame->
Size > 0 , oC_ErrorCode_SizeNotCorrect )
419 && ErrorCondition( Timeout >= 0 , oC_ErrorCode_TimeNotCorrect )
420 && ErrorCondition( Frame->
FrameType > 0 , oC_ErrorCode_FrameTypeNotSupported )
423 uint8_t * data = (uint8_t*)Frame->
Packet;
424 uint16_t size = oC_MIN(Frame->
Size , IEEE_802_3_ETHERNET_MTU);
425 uint16_t sentBytes = 0;
426 uint16_t bytesToSend = Frame->
Size;
427 oC_ETH_LLD_FrameSegment_t frameSegment = Frame->
Size > IEEE_802_3_ETHERNET_MTU ? oC_ETH_LLD_FrameSegment_First : oC_ETH_LLD_FrameSegment_Single;
428 oC_Timestamp_t startTimestamp = oC_KTime_GetCurrentTick();
429 oC_Timestamp_t endTimestamp = startTimestamp + Timeout;
431 errorCode = oC_ErrorCode_None;
436 && ErrorCondition( endTimestamp > oC_KTime_GetTimestamp() , oC_ErrorCode_Timeout )
440 size = oC_MIN(bytesToSend , IEEE_802_3_ETHERNET_MTU);
441 bytesToSend = (bytesToSend > sentBytes) ? bytesToSend - sentBytes : 0;
442 frameSegment = bytesToSend < IEEE_802_3_ETHERNET_MTU ? oC_ETH_LLD_FrameSegment_Last : oC_ETH_LLD_FrameSegment_Middle;
444 Timeout = endTimestamp - oC_KTime_GetCurrentTick();
484 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
489 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect )
490 && ErrorCondition( isram(outFrame) , oC_ErrorCode_OutputAddressNotInRAM )
491 && ErrorCondition( Timeout >= 0 , oC_ErrorCode_TimeNotCorrect )
492 && ErrorCondition( isram(outFrame->
Packet) , oC_ErrorCode_OutputAddressNotInRAM )
493 && ErrorCondition( outFrame->
Size > 0 , oC_ErrorCode_SizeNotCorrect )
496 if(ErrorCondition( oC_Mutex_Take(Context->
ContextBusyMutex,Timeout) , oC_ErrorCode_Timeout ))
498 uint8_t * buffer = (uint8_t*)outFrame->
Packet;
499 uint16_t receivedBytes = 0;
500 oC_Time_t startTimestamp = oC_KTime_GetTimestamp();
501 oC_Time_t endTimestamp = startTimestamp + Timeout;
502 uint16_t leftBufferSize = outFrame->
Size;
503 oC_ETH_LLD_FrameSegment_t frameSegment = oC_ETH_LLD_FrameSegment_NumberOfFrameSegments;
504 bool frameStarted =
false;
508 ErrorCondition( receivedBytes < outFrame->Size , oC_ErrorCode_OutputBufferTooSmall )
509 && ErrorCondition( oC_KTime_GetTimestamp() <= endTimestamp , oC_ErrorCode_Timeout )
516 if((frameSegment & oC_ETH_LLD_FrameSegment_First) || frameStarted)
518 if(frameSegment & oC_ETH_LLD_FrameSegment_First)
525 receivedBytes += leftBufferSize;
527 if(frameSegment & oC_ETH_LLD_FrameSegment_Last)
529 errorCode = oC_ErrorCode_None;
533 leftBufferSize = outFrame->
Size - receivedBytes;
534 kdebuglog( oC_LogType_Info,
"ETH: skipping not started frame from 0x%X\n", outFrame->
Packet->
IPv4.
Header.
SourceIp );
537 Timeout = endTimestamp - oC_KTime_GetTimestamp();
552 return oC_ErrorCode_NotImplemented;
559 return oC_ErrorCode_NotImplemented;
585 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
590 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect )
602 errorCode = oC_ErrorCode_None;
608 ErrorCode( oC_ETH_LLD_SetMacLoopback(Enabled) )
612 errorCode = oC_ErrorCode_None;
646 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
651 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect )
652 && ErrorCondition( isram(NumberOfDiags) , oC_ErrorCode_OutputAddressNotInRAM )
653 && ErrorCondition( Diags ==
NULL || isram(Diags) , oC_ErrorCode_OutputAddressNotInRAM )
659 uint32_t diagsSize = *NumberOfDiags;
661 if( ErrorCondition( oC_Mutex_Take(Context->
ContextBusyMutex,
s(1)) , oC_ErrorCode_Timeout ) )
663 if(ErrorCode( oC_ETH_LLD_PerformDiagnostics( &Context->
Result, Diags, NumberOfDiags ) ))
665 errorCode = oC_Diag_PerformDiagnostics( SupportedDiagsArray, &Diags[*NumberOfDiags], diagsSize - (*NumberOfDiags), Context->
ChipName, Context );
666 *NumberOfDiags += oC_Diag_GetNumberOfSupportedDiagnostics(SupportedDiagsArray);
676 if( ErrorCode( oC_ETH_LLD_PerformDiagnostics( &Context->
Result,
NULL, NumberOfDiags) ) )
678 *NumberOfDiags += oC_Diag_GetNumberOfSupportedDiagnostics(SupportedDiagsArray);
679 errorCode = oC_ErrorCode_None;
711 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
716 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect )
717 && ErrorCondition( isram(outInfo) , oC_ErrorCode_OutputAddressNotInRAM )
744 errorCode = oC_ErrorCode_None;
770 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________ 777 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 796 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
800 ErrorCondition( context !=
NULL , oC_ErrorCode_AllocationError )
801 && ErrorCondition( strlen(Config->
PhyChipInfo->
Name) > 0 , oC_ErrorCode_ChipNameNotDefined )
807 context->
ContextBusyMutex = oC_Mutex_New(oC_Mutex_Type_Normal,&Allocator,AllocationFlags_CanWait1Second);
815 *outContext = context;
820 oC_SaveIfFalse(
"ETH::CreateContext - Cannot release context memory - ", kfree(context,AllocationFlags_CanWait1Second), oC_ErrorCode_ReleaseError);
834 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
840 ErrorCondition( oC_Mutex_Delete(&context->
ContextBusyMutex, AllocationFlags_CanWait1Second) , oC_ErrorCode_ReleaseError )
841 && ErrorCondition( kfree(context, AllocationFlags_CanWait1Second) , oC_ErrorCode_ReleaseError )
845 errorCode = oC_ErrorCode_None;
858 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
865 errorCode = oC_ErrorCode_None;
878 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
906 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
909 ErrorCondition( Context->
Result.RxData.Alignment > 0 , oC_ErrorCode_AlignmentNotCorrect )
910 && ErrorCondition( Context->
Result.TxData.Alignment > 0 , oC_ErrorCode_AlignmentNotCorrect )
911 && ErrorCondition( Context->
Result.RxData.DescriptorSize > 0 , oC_ErrorCode_SizeNotCorrect )
912 && ErrorCondition( Context->
Result.TxData.DescriptorSize > 0 , oC_ErrorCode_SizeNotCorrect )
913 && ErrorCondition( Context->
Result.RxData.RingSize > 0 , oC_ErrorCode_SizeNotCorrect )
914 && ErrorCondition( Context->
Result.TxData.RingSize > 0 , oC_ErrorCode_SizeNotCorrect )
917 AllocationFlags_t allocationFlags = AllocationFlags_ZeroFill
918 | AllocationFlags_UseInternalRam
919 | AllocationFlags_UseDmaRam
920 | AllocationFlags_DmaRamFirst;
923 &Allocator, allocationFlags, Context->
Result.RxData.Alignment);
925 &Allocator, allocationFlags, Context->
Result.TxData.Alignment);
931 errorCode = oC_ErrorCode_None;
950 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
953 ErrorCondition( kafree(Context->
RxDescriptorRing, AllocationFlags_CanWait1Second ) , oC_ErrorCode_ReleaseError )
954 && ErrorCondition( kafree(Context->
TxDescriptorRing, AllocationFlags_CanWait1Second ) , oC_ErrorCode_ReleaseError )
957 errorCode = oC_ErrorCode_None;
970 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
974 oC_IntMan_EnterCriticalSection();
975 if(oC_ETH_LLD_IsTransmitQueueFull(&Context->
Result))
977 oC_Event_SetState(ModuleReadyToSend,oC_Event_State_Inactive);
981 oC_Event_SetState(ModuleReadyToSend,oC_Event_State_Active);
983 oC_IntMan_ExitCriticalSection();
985 oC_Procedure_ExitIfFalse(
oC_Event_WaitForState(ModuleReadyToSend, oC_Event_State_Active, oC_Event_StateMask_Full, Timeout), oC_ErrorCode_Timeout );
988 oC_Procedure_ExitIfError( oC_ETH_LLD_SendFrame( &Context->
Result, Source, Destination, Data, Size, FrameSegment , FrameType) );
990 errorCode = oC_ErrorCode_None;
1004 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1008 oC_IntMan_EnterCriticalSection();
1009 if(oC_ETH_LLD_IsDataReadyToReceive(&Context->
Result) ==
false)
1011 oC_Event_SetState(DataReadyToRead,oC_Event_State_Inactive);
1015 oC_Event_SetState(DataReadyToRead,oC_Event_State_Active);
1017 oC_IntMan_ExitCriticalSection();
1019 oC_Procedure_ExitIfFalse(
oC_Event_WaitForState(DataReadyToRead, oC_Event_State_Active, oC_Event_StateMask_Full, Timeout), oC_ErrorCode_Timeout );
1021 oC_Procedure_ExitIfError( oC_ETH_LLD_ReceiveFrame( &Context->
Result, outSource, outDestination, Data, Size, outFrameSegment , outFrameType) );
1024 errorCode = oC_ErrorCode_None;
1038 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1041 if(ErrorCondition(
IsContextCorrect(context), oC_ErrorCode_ContextNotCorrect))
1053 Diag->ResultDescription =
"Cannot read BCR register";
1061 Diag->ResultDescription =
"Cannot write BCR register";
1069 Diag->ResultDescription =
"Cannot read BCR register after write";
1075 Diag->ResultDescription =
"Value of the BCR register after write `BCR.Loopback = 1` is not correct!";
1076 errorCode = oC_ErrorCode_CannotAccessRegister;
1084 Diag->ResultDescription =
"Cannot write BCR register";
1092 Diag->ResultDescription =
"Value of the BCR register after write `BCR.Loopback = 0` is not correct!";
1093 errorCode = oC_ErrorCode_CannotAccessRegister;
1099 Diag->ResultDescription =
"Cannot read BSR register";
1106 Diag->ResultDescription =
"BSR value is 0! We expect anything else...";
1107 errorCode = oC_ErrorCode_CannotAccessRegister;
1111 errorCode = oC_ErrorCode_None;
1126 if(Source & oC_ETH_LLD_InterruptSource_DataReceived)
1128 oC_Event_SetState(DataReadyToRead,oC_Event_State_Active);
1130 if(Source & oC_ETH_LLD_InterruptSource_TransmissionSlotsAvailable)
1132 oC_Event_SetState(ModuleReadyToSend,oC_Event_State_Active);
1134 if(Source & oC_ETH_LLD_InterruptSource_ReceiveError)
1136 oC_SaveError(
"ETH - Transmission failure - ", oC_ErrorCode_ReceiveError);
1140 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ oC_Net_InterfaceName_t InterfaceName
Name of the interface.
oC_Net_Ipv4_t SourceIp
Source IP address.
oC_ETH_PhyAddress_t PhyAddress
Address of the external PHY.
oC_ETH_LLD_Result_t Result
Result of LLD configuration.
The data link layer or layer 2 is the second layer of the seven-layer OSI model of computer networkin...
bool oC_Event_WaitForState(oC_Event_t Event, oC_Event_State_t State, oC_Event_StateMask_t StateMask, oC_Time_t Timeout)
oC_Net_InterfaceIndex_t InterfaceIndex
Index of the interface in the driver.
#define s(time)
Number of s.
oC_ErrorCode_t oC_ETH_PerformDiagnostics(oC_ETH_Context_t Context, oC_Diag_t *Diags, uint32_t *NumberOfDiags)
performs diagnostics
static oC_Event_t DataReadyToRead
static int oC_Net_MacAddressFromString(const char *MacAddressString, oC_Net_MacAddress_t outMacAddress)
reads MAC address from the string
ETH driver configuration structure.
oC_ErrorCode_t oC_ETH_SetPhyLoopback(oC_ETH_PhyAddress_t PhyAddress, bool Enabled)
enables/disables PHY loopback mode
oC_ErrorCode_t oC_ETH_SendFrame(oC_ETH_Context_t Context, const oC_Net_Frame_t *Frame, oC_Time_t Timeout)
sends frame via ETH
oC_MemorySize_t TransmittedBytes
Number of transmitted bytes.
static oC_Event_t ModuleReadyToSend
oC_ErrorCode_t oC_ETH_PhyReset(oC_ETH_PhyAddress_t PhyAddress)
resets PHY
oC_ErrorCode_t oC_ETH_TurnOn(void)
turns on the module
The file with interface for the GPIO driver.
static uint16_t oC_Net_ConvertUint16FromNetworkEndianess(uint16_t v)
converts uint16_t from network byte order
oC_Net_Ipv4PacketHeader_t Header
Header of the IPv4 packet.
identifier for allocations
oC_ErrorCode_t oC_ETH_SetLoopback(oC_ETH_Context_t Context, oC_Net_Layer_t Layer, bool Enabled)
enables or disables loopback-mode at the given layer
The file with LLD interface for the ETH driver.
stores value of the BSR register
stores network interface informations
oC_Net_MacAddress_t MacAddress
MAC address.
oC_ETH_PhyRegister_BasicStatusRegister
oC_ETH_ChipName_t ChipName
Name of the used chip.
uint32_t HardwareAddressLength
Number of bytes in the HW address.
uint32_t Value
Stores value of the register.
The file contains definitions for the compiler, that helps to manage errors, etc. ...
oC_ETH_LLD_Descriptor_t RxDescriptorRing
Pointer to the RX Descriptor ring (List of DMA descriptors required for receiving packets) ...
static oC_ErrorCode_t InitializePhy(const oC_ETH_Config_t *Config, oC_ETH_Context_t Context)
initializes PHY to work
oC_Net_LinkStatus_t LinkStatus
Network interface link status (UP/DOWN)
static oC_ErrorCode_t CreateContext(const oC_ETH_Config_t *Config, oC_ETH_Context_t *outContext)
creates context of the driver
oC_ErrorCode_t oC_ETH_Configure(const oC_ETH_Config_t *Config, oC_ETH_Context_t *outContext)
configures ETH pins to work
bool Filled
True if the address is filled.
const char * DriverName
Name of the driver that handles the network interface.
Header with definitions for PHY handling.
char oC_Net_InterfaceName_t[IFNAMSIZ]
stores name of the network interface
#define ms(time)
Number of ms.
static const oC_Diag_SupportedDiagData_t SupportedDiagsArray[]
oC_ETH_LLD_Config_t LLD
Configuration from the LLD layer (More you can find in the #oC_ETH_LLD_Config_t type description) ...
oC_Net_HardwareAddress_t Destination
Hardware Destination Address.
uint8_t oC_Net_MacAddress_t[MAC_ADDRESS_LENGTH]
stores MAC address
char oC_ETH_ChipName_t[oC_ETH_CHIP_NAME_MAX_LENGTH]
stores name of the chip
oC_MemorySize_t ReceivedBytes
Number of received bytes.
void(* PrintFunction)(struct oC_Diag_t *Diag)
prints state of the diagnostic
static uint16_t oC_Net_ConvertUint16ToNetworkEndianess(uint16_t v)
converts uint16_t to network byte order
oC_Net_MacAddress_t MacAddress
MAC address of the interface.
oC_Net_HardwareAddress_t HardwareAddress
Hardware address.
The file with interface for driver creating.
oC_Mutex_t ContextBusyMutex
Pointer to the Mutex available when the Ethernet context is busy.
oC_Net_InterfaceName_t InterfaceName
Name of the interface.
oC_ETH_LLD_PHY_ChipInfo_t LLD
Informations about the chip required by the LLD layer.
The file with interface for the module library.
const oC_ETH_PhyChipInfo_t * PhyChipInfo
Pointer to the PHY chip definition (you can find it in the oc_eth_chips.h file)
oC_Net_MacAddress_t MacAddress
MAC address of the interface.
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
oC_ErrorCode_t oC_ETH_TurnOff(void)
Turns off the ETH driver.
oC_BaudRate_t BaudRate
Baud rate of the interface.
uint32_t oC_ObjectControl_t
stores object control value
oC_ETH_PhyRegister_BasicControlRegister
static oC_ErrorCode_t SendFrame(oC_ETH_Context_t Context, const oC_Net_MacAddress_t Source, const oC_Net_MacAddress_t Destination, const void *Data, uint16_t Size, oC_ETH_LLD_FrameSegment_t FrameSegment, oC_Net_FrameType_t FrameType, oC_Time_t Timeout)
sends frame
In the seven-layer OSI model of computer networking, the physical layer or layer 1 is the first and l...
uint16_t Size
Size Data in frame.
oC_ETH_ChipName_t Name
Name of the PHY chip.
The file with interface for interrupt manager.
oC_Net_HardwareType_t HardwareType
Type of the hardware device.
stores informations about the frame to send
oC_ErrorCode_t oC_ETH_SetAutoNegotiation(oC_ETH_PhyAddress_t PhyAddress, bool Enabled, oC_Time_t Timeout)
enables/disables AutoNegotiation
oC_ErrorCode_t oC_ETH_ReadNetInfo(oC_ETH_Context_t Context, oC_Net_Info_t *outInfo)
returns informations about the interface
oC_ErrorCode_t oC_ETH_Unconfigure(const oC_ETH_Config_t *Config, oC_ETH_Context_t *outContext)
Unconfigures the driver.
uint32_t oC_Net_InterfaceIndex_t
stores index of the interface
static oC_ObjectControl_t oC_CountObjectControl(void *ObjectPointer, oC_ObjectId_t ObjectId)
counts object control for object
static bool oC_CheckObjectControl(void *ObjectPointer, oC_ObjectId_t ObjectId, oC_ObjectControl_t ObjectControl)
checks if object control is correct
oC_MemorySize_t ReceivedBytes
Number of received bytes.
The file with interface for mutex managing.
oC_Net_HardwareAddress_t Source
Hardware Source Address.
oC_ETH_LLD_Descriptor_t TxDescriptorRing
Pointer to the TX Descriptor ring (List of DMA descriptors required for sending packets) ...
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
static oC_ErrorCode_t ReleasePhy(const oC_ETH_Config_t *Config, oC_ETH_Context_t Context)
releases PHY when it is not needed anymore
oC_ObjectControl_t ObjectControl
uint32_t Value
Stores value of the register.
oC_Net_Ipv4Packet_t IPv4
Packet in format IPv4.
oC_Net_Packet_t * Packet
Pointer to the packet to send.
oC_Net_FrameType_t FrameType
Type of the frame.
static oC_ErrorCode_t AllocateDescriptors(oC_ETH_Context_t Context)
allocates Rx/Tx descriptors
oC_BaudRate_t BaudRate
Baud Rate of the interface.
static int oC_Net_PrepareInterfaceName(oC_Net_InterfaceName_t *outName, const char *Prefix, oC_Net_InterfaceIndex_t Index)
prepares interface name string
static bool IsContextCorrect(oC_ETH_Context_t Context)
Checks if the context of the ETH driver is correct.
Network interface is DOWN (cable is not connected)
static bool oC_Net_IsMainLayer(oC_Net_Layer_t Layer, oC_Net_Layer_t MainLayer)
returns true if Layer is part of the MainLayer
The file with interface for string library.
oC_ErrorCode_t oC_ETH_ReadPhyRegister(oC_ETH_PhyAddress_t PhyAddress, oC_ETH_PhyRegister_t Register, uint32_t *outValue)
writes PHY register
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
Definition of the null pointer.
static const oC_Allocator_t Allocator
stores value of the BCR register
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
oC_ErrorCode_t oC_ETH_ReceiveFrame(oC_ETH_Context_t Context, oC_Net_Frame_t *outFrame, oC_Time_t Timeout)
receives frame via ETH
oC_ETH_PhyAddress_t PhyAddress
Address of the external PHY.
static oC_Net_LinkStatus_t GetLinkStatus(oC_ETH_Context_t Context)
returns current link status
static void InterruptHandler(oC_ETH_LLD_InterruptSource_t Source)
handler for interrupts
static oC_ErrorCode_t ReceiveFrame(oC_ETH_Context_t Context, oC_Net_MacAddress_t outSource, oC_Net_MacAddress_t outDestination, void *Data, uint16_t *Size, oC_ETH_LLD_FrameSegment_t *outFrameSegment, oC_Net_FrameType_t *outFrameType, oC_Time_t Timeout)
receives frame
Network interface is UP (cable is connected)
oC_Net_HardwareAddress_t HardwareBroadcastAddress
Hardware address that should be used for broadcast.
static oC_ErrorCode_t DeleteContext(oC_ETH_Context_t *outContext)
deletes context of the driver
oC_Net_LinkStatus_t
stores network interface link status
oC_MemorySize_t TransmittedBytes
Number of transmitted bytes.
oC_ETH_LLD_PHY_Address_t oC_ETH_PhyAddress_t
stores address of a PHY
bool oC_ETH_IsContextCorrect(oC_ETH_Context_t Context)
checks if the context is correct for ETH driver
oC_ErrorCode_t oC_ETH_ReadLinkStatus(oC_ETH_PhyAddress_t PhyAddress, oC_Net_LinkStatus_t *outLinkStatus)
reads link status from the PHY
static oC_ErrorCode_t ReleaseDescriptors(oC_ETH_Context_t Context)
releases Rx/Tx descriptors
uint32_t Loopback
Loopback mode: 0 = Normal operation, 1 = loopback mode.
oC_Net_FrameType_t
stores type of the frame
The file with interface for ETH driver.
bool oC_ETH_IsTurnedOn(void)
checks if the driver is turned on
oC_ErrorCode_t oC_ETH_WritePhyRegister(oC_ETH_PhyAddress_t PhyAddress, oC_ETH_PhyRegister_t Register, uint32_t Value)
writes PHY register
static oC_ErrorCode_t PerformPhyRegisterAccessTest(oC_Diag_t *Diag, void *Context)
performs PHY registers access test
oC_Net_Layer_t LoopbackLayer
Layer of enabled loopback or 0 if not enabled.
The file with interface of kernel time module.
The file with standard input/output operations.
#define NULL
pointer to a zero
oC_Net_Layer_t
stores layer of the OSI model
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off