@@ -136,7 +136,7 @@ static int read_register_field(lan8670_t *lan, int reg, int start, int end, uint
136136
137137 /* Read the register */
138138 uint32_t data = 0 ;
139- int status = lan -> read (lan -> device_address , reg , & data );
139+ int status = lan -> IO . ReadReg (lan -> DevAddr , reg , & data );
140140 if (status != 0 ) {
141141 debug ("ERROR 1002: read_register_field() failed to read register 0x%X (Status: %d)\n" , reg , status );
142142 return status ;
@@ -187,7 +187,7 @@ static int write_register_field(lan8670_t *lan, int reg, int start, int end, uin
187187
188188 /* Read the current register value */
189189 uint32_t data = 0 ;
190- int status = lan -> read (lan -> device_address , reg , & data );
190+ int status = lan -> IO . ReadReg (lan -> DevAddr , reg , & data );
191191 if (status != 0 ) {
192192 debug ("ERROR 3000: write_register_field() failed to read register 0x%X (Status: %d)\n" , reg , status );
193193 return status ;
@@ -198,7 +198,7 @@ static int write_register_field(lan8670_t *lan, int reg, int start, int end, uin
198198 data = (data & ~mask ) | ((value << start ) & mask );
199199
200200 /* Write back the modified value */
201- status = lan -> write (lan -> device_address , reg , data );
201+ status = lan -> IO . WriteReg (lan -> DevAddr , reg , data );
202202 if (status != 0 ) {
203203 debug ("ERROR 3001: write_register_field() failed to write register 0x%X (Status: %d)\n" , reg , status );
204204 return status ;
@@ -223,29 +223,29 @@ static int mmd_read_register(lan8670_t *lan, uint16_t mmd_addr, uint16_t registe
223223{
224224 /* Tell the MMDCTRL register what MMD device you intend to access */
225225 uint16_t mmd_ctrl = mmd_addr & 0x1F ;
226- int status = lan -> write (lan -> device_address , REG_MMDCTRL , mmd_ctrl );
226+ int status = lan -> IO . WriteReg (lan -> DevAddr , REG_MMDCTRL , mmd_ctrl );
227227 if (status != 0 ) {
228228 debug ("ERROR 4000: mmd_read_register() failed when writing REG_MMDCTRL (Status: %d)\n" , status );
229229 return status ;
230230 }
231231
232232 /* Tell the MMDAD register what specific register you want to access */
233- status = lan -> write (lan -> device_address , REG_MMDAD , register_offset );
233+ status = lan -> IO . WriteReg (lan -> DevAddr , REG_MMDAD , register_offset );
234234 if (status != 0 ) {
235235 debug ("ERROR 4001: mmd_read_register() failed when writing REG_MMDAD (Status: %d)\n" , status );
236236 return status ;
237237 }
238238
239239 /* Set the MMD function to 'Data - No post increment' */
240240 mmd_ctrl = (mmd_addr & 0x1F ) | (1 << 14 );
241- status = lan -> write (lan -> device_address , REG_MMDCTRL , mmd_ctrl );
241+ status = lan -> IO . WriteReg (lan -> DevAddr , REG_MMDCTRL , mmd_ctrl );
242242 if (status != 0 ) {
243243 debug ("ERROR 4002: mmd_read_register() failed when writing REG_MMDCTRL (Status: %d)\n" , status );
244244 return status ;
245245 }
246246
247247 /* Read data from MMDAD */
248- status = lan -> read (lan -> device_address , REG_MMDAD , value );
248+ status = lan -> IO . ReadReg (lan -> DevAddr , REG_MMDAD , value );
249249 if (status != 0 ) {
250250 debug ("ERROR 4003: mmd_read_register() failed when reading REG_MMDAD (Status: %d)\n" , status );
251251 return status ;
@@ -270,29 +270,29 @@ static int mmd_write_register(lan8670_t *lan, uint16_t mmd_addr, uint16_t regist
270270{
271271 /* Tell the MMDCTRL register what MMD device you intend to access */
272272 uint16_t mmd_ctrl = mmd_addr & 0x1F ;
273- int status = lan -> write (lan -> device_address , REG_MMDCTRL , mmd_ctrl );
273+ int status = lan -> IO . WriteReg (lan -> DevAddr , REG_MMDCTRL , mmd_ctrl );
274274 if (status != 0 ) {
275275 debug ("ERROR 5000: mmd_write_register() failed when writing REG_MMDCTRL (Status: %d)\n" , status );
276276 return status ;
277277 }
278278
279279 /* Tell the MMDAD register what specific register you want to access */
280- status = lan -> write (lan -> device_address , REG_MMDAD , register_offset );
280+ status = lan -> IO . WriteReg (lan -> DevAddr , REG_MMDAD , register_offset );
281281 if (status != 0 ) {
282282 debug ("ERROR 5001: mmd_write_register() failed when writing REG_MMDAD (Status: %d)\n" , status );
283283 return status ;
284284 }
285285
286286 /* Set the MMD function to 'Data - No post increment' */
287287 mmd_ctrl = (mmd_addr & 0x1F ) | (1 << 14 );
288- status = lan -> write (lan -> device_address , REG_MMDCTRL , mmd_ctrl );
288+ status = lan -> IO . WriteReg (lan -> DevAddr , REG_MMDCTRL , mmd_ctrl );
289289 if (status != 0 ) {
290290 debug ("ERROR 5002: mmd_write_register() failed when writing REG_MMDCTRL (Status: %d)\n" , status );
291291 return status ;
292292 }
293293
294294 /* Write data to MMDAD */
295- status = lan -> write (lan -> device_address , REG_MMDAD , value );
295+ status = lan -> IO . WriteReg (lan -> DevAddr , REG_MMDAD , value );
296296 if (status != 0 ) {
297297 debug ("ERROR 5003: mmd_write_register() failed when writing REG_MMDAD (Status: %d)\n" , status );
298298 return status ;
@@ -407,19 +407,19 @@ static int mmd_write_register_field(lan8670_t *lan, uint16_t mmd_addr, uint16_t
407407
408408/**** API FUNCTIONS ****/
409409
410- void lan8670_init (lan8670_t * lan , uint32_t device_address , ReadFunction read , WriteFunction write )
410+ void lan8670_init (lan8670_t * lan , uint32_t device_address , lan8670_ReadReg_Func read , lan8670_WriteReg_Func write )
411411{
412- lan -> write = write ;
413- lan -> read = read ;
414- lan -> device_address = device_address ;
412+ lan -> IO . WriteReg = write ;
413+ lan -> IO . ReadReg = read ;
414+ lan -> DevAddr = device_address ;
415415 lan -> debug = false; // Default to no debugging. Set this to true (after calling lan8670_init()) if you want debugging enabled.
416416}
417417
418418int lan8670_reset (lan8670_t * lan )
419419{
420420 // Set bit 15 in the Basic Control Register, and clear all other bits.
421421 // This starts a software reset of the PHY.
422- return lan -> write (lan -> device_address , REG_BASIC_CONTROL , 0x8000 );
422+ return lan -> IO . WriteReg (lan -> DevAddr , REG_BASIC_CONTROL , 0x8000 );
423423}
424424
425425int lan8670_loopback (lan8670_t * lan , bool setting )
0 commit comments