Skip to content

Commit e873437

Browse files
MMore
1 parent 5bc0f5c commit e873437

2 files changed

Lines changed: 67 additions & 58 deletions

File tree

general/include/lan8670.h

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
#include <stdint.h>
1111
#include <stdbool.h>
1212

13+
/* STATUS CODES */
14+
#define LAN8670_STATUS_READ_ERROR ((int32_t)-5)
15+
#define LAN8670_STATUS_WRITE_ERROR ((int32_t)-4)
16+
#define LAN8670_STATUS_ADDRESS_ERROR ((int32_t)-3)
17+
#define LAN8670_STATUS_RESET_TIMEOUT ((int32_t)-2)
18+
#define LAN8670_STATUS_ERROR ((int32_t)-1)
19+
#define LAN8670_STATUS_OK ((int32_t) 0)
20+
#define LAN8670_STATUS_LINK_DOWN ((int32_t) 1)
21+
1322
/* FUNCTION POINTERS */
1423
typedef int32_t (*lan8670_Init_Func) (void);
1524
typedef int32_t (*lan8670_DeInit_Func) (void);
@@ -41,14 +50,14 @@ typedef struct {
4150
* @param device_address The address of the LAN8670.
4251
* @param read Function pointer for reading data from the LAN8670.
4352
* @param write Function pointer for writing data to the LAN8670.
44-
* @return 0 on success, or a non-zero error code.
53+
* @return Status.
4554
*/
4655
int32_t LAN8670_Init(lan8670_t *lan); // Initializes a LAN8670 instance.
4756

4857
/**
4958
* @brief Performs a software reset of the LAN8670 Ethernet PHY.
5059
* @param lan Pointer to the lan8670_t instance.
51-
* @return 0 on success, or a non-zero error code.
60+
* @return Status.
5261
*/
5362
int32_t LAN8670_Reset(lan8670_t *lan); // Performs a software reset of the LAN8670 Ethernet PHY.
5463

@@ -61,7 +70,7 @@ int32_t LAN8670_Reset(lan8670_t *lan); // Performs a software reset of the LAN86
6170
*
6271
* @param lan Pointer to the lan8670_t instance.
6372
* @param setting true to enable loopback mode, false to disable it.
64-
* @return 0 on success, or a non-zero error code.
73+
* @return Status.
6574
*/
6675
int32_t LAN8670_Loopback(lan8670_t *lan, bool setting); // Enables or disables loopback mode on the LAN8670.
6776

@@ -73,15 +82,15 @@ int32_t LAN8670_Loopback(lan8670_t *lan, bool setting); // Enables or disables l
7382
*
7483
* @param lan Pointer to the lan8670_t instance.
7584
* @param setting true to enable low power mode, false to disable it.
76-
* @return 0 on success, or a non-zero error code.
85+
* @return Status.
7786
*/
7887
int32_t LAN8670_Low_Power_Mode(lan8670_t *lan, bool setting); // Enables or disables the LAN8670's low power mode.
7988

8089
/**
8190
* @brief Electrically isolates the LAN8670 from MII/RMII.
8291
* @param lan Pointer to the lan8670_t instance.
8392
* @param setting true to isolate the device, false for normal operation.
84-
* @return 0 on success, or a non-zero error code.
93+
* @return Status.
8594
*/
8695
int32_t LAN8670_Isolate(lan8670_t *lan, bool setting); // Electrically isolates the LAN8670 from MII/RMII.
8796

@@ -94,23 +103,23 @@ int32_t LAN8670_Isolate(lan8670_t *lan, bool setting); // Electrically isolates
94103
*
95104
* @param lan Pointer to the lan8670_t instance.
96105
* @param setting true to enable collision test mode, false to disable it.
97-
* @return 0 on success, or a non-zero error code.
106+
* @return Status.
98107
*/
99108
int32_t LAN8670_Collision_Test(lan8670_t *lan, bool setting); // Enables or disables the LAN8670's collision test mode.
100109

101110
/**
102111
* @brief Detects jabber condition on the LAN8670.
103112
* @param lan Pointer to the lan8670_t instance.
104113
* @param jabber_status Pointer to a boolean variable to store the jabber status.
105-
* @return 0 on success, or a non-zero error code.
114+
* @return Status.
106115
*/
107116
int32_t LAN8670_Detect_Jabber(lan8670_t *lan, bool *jabber_status); // Detects jabber condition on the LAN8670.
108117

109118
/**
110119
* @brief Enables or disables collision detection on the LAN8670.
111120
* @param lan Pointer to the lan8670_t instance.
112121
* @param setting true to enable collision detection, false to disable it.
113-
* @return 0 on success, or a non-zero error code.
122+
* @return Status.
114123
*/
115124
int32_t LAN8670_Collision_Detection(lan8670_t *lan, bool setting);
116125

@@ -123,15 +132,15 @@ int32_t LAN8670_Collision_Detection(lan8670_t *lan, bool setting);
123132
*
124133
* @param lan Pointer to the lan8670_t instance.
125134
* @param setting true to enable PLCA, false to disable it.
126-
* @return 0 on success, or a non-zero error code.
135+
* @return Status.
127136
*/
128137
int32_t LAN8670_PLCA_On(lan8670_t *lan, bool setting);
129138

130139
/**
131140
* @brief Resets the PLCA reconciliation sublayer.
132141
*
133142
* @param lan Pointer to the lan8670_t instance.
134-
* @return 0 on success, or a non-zero error code.
143+
* @return Status.
135144
*/
136145
int32_t LAN8670_PLCA_Reset(lan8670_t *lan);
137146

@@ -143,7 +152,7 @@ int32_t LAN8670_PLCA_Reset(lan8670_t *lan);
143152
*
144153
* @param lan Pointer to the lan8670_t instance.
145154
* @param node_count The number of nodes on the network.
146-
* @return 0 on success, or a non-zero error code.
155+
* @return Status.
147156
*/
148157
int32_t LAN8670_PLCA_Set_Node_Count(lan8670_t *lan, uint8_t node_count);
149158

@@ -155,17 +164,17 @@ int32_t LAN8670_PLCA_Set_Node_Count(lan8670_t *lan, uint8_t node_count);
155164
*
156165
* @param lan Pointer to the lan8670_t instance.
157166
* @param id The ID of the PLCA node (0-31).
158-
* @return 0 on success, or a non-zero error code.
167+
* @return Status.
159168
*/
160169
int32_t LAN8670_PLCA_Set_Node_Id(lan8670_t *lan, uint8_t id);
161170

162171
/**
163172
* @brief Gets the current link state of the LAN8670.
164173
* @param lan Pointer to the lan8670_t instance.
165174
* @param link_up Pointer to a boolean variable to store the link state (true if link is up, false if down).
166-
* @return 0 on success, or a non-zero error code.
175+
* @return Status.
167176
* @note For the LAN8670, this ALWAYS reads '1'. This function was mainly implemented for consistency with the STM32 HAL ethernet stuff.
168177
*/
169-
int32_t LAN8670_Get_Link_State(lan8670_t *lan, bool *link_up);
178+
int32_t LAN8670_GetLinkState(lan8670_t *lan, bool *link_up);
170179

171180
// clang-format on

0 commit comments

Comments
 (0)