Added SFR_NIC_DATA_U16LE and SFR_NIC_RING_U16LE.

Let's use sfr16 for NIC data and ring.
SFR define can so reordered to it does the BE to LE swap for us.
This commit is contained in:
René van Dorst
2025-09-01 09:20:36 +02:00
committed by René van Dorst
parent af0135bcce
commit 9dafeab490
2 changed files with 12 additions and 12 deletions
+2
View File
@@ -90,7 +90,9 @@ __sfr __at(0xa9) SFR_FLASH_ADDR0;
* CAREFUL: This is now Little Endian * CAREFUL: This is now Little Endian
*/ */
__sfr __at(0xb7) SFR_NIC_CTRL; __sfr __at(0xb7) SFR_NIC_CTRL;
__sfr16 __at(0xb4b3) SFR_NIC_DATA_U16LE;
__sfr __at(0xb3) SFR_NIC_DATA_L; __sfr __at(0xb3) SFR_NIC_DATA_L;
__sfr __at(0xb4) SFR_NIC_DATA_H; __sfr __at(0xb4) SFR_NIC_DATA_H;
__sfr16 __at(0xb6b5) SFR_NIC_RING_U16LE;
__sfr __at(0xb5) SFR_NIC_RING_L; __sfr __at(0xb5) SFR_NIC_RING_L;
__sfr __at(0xb6) SFR_NIC_RING_H; __sfr __at(0xb6) SFR_NIC_RING_H;
+10 -12
View File
@@ -393,10 +393,9 @@ void sfr_mask_data(uint8_t n, uint8_t mask, uint8_t set)
void nic_rx_header(uint16_t ring_ptr) void nic_rx_header(uint16_t ring_ptr)
{ {
uint16_t buffer = (uint16_t) &rx_headers[0]; uint16_t buffer = (uint16_t) &rx_headers[0];
SFR_NIC_DATA_H = buffer >> 8; SFR_NIC_DATA_U16LE = buffer;
SFR_NIC_DATA_L = buffer; SFR_NIC_RING_U16LE = ring_ptr;
SFR_NIC_RING_L = ring_ptr;
SFR_NIC_RING_H = ring_ptr >> 8;
SFR_NIC_CTRL = 1; SFR_NIC_CTRL = 1;
do { } while (SFR_NIC_CTRL != 0); do { } while (SFR_NIC_CTRL != 0);
} }
@@ -410,10 +409,9 @@ void nic_rx_header(uint16_t ring_ptr)
*/ */
void nic_rx_packet(register uint16_t buffer, register uint16_t ring_ptr) void nic_rx_packet(register uint16_t buffer, register uint16_t ring_ptr)
{ {
SFR_NIC_DATA_H = buffer >> 8; SFR_NIC_DATA_U16LE = buffer;
SFR_NIC_DATA_L = buffer; SFR_NIC_RING_U16LE = ring_ptr;
SFR_NIC_RING_L = ring_ptr;
SFR_NIC_RING_H = ring_ptr >> 8;
uint16_t len = (((uint16_t)rx_headers[5]) << 8) | rx_headers[4]; uint16_t len = (((uint16_t)rx_headers[5]) << 8) | rx_headers[4];
len += 7; len += 7;
len >>= 3; len >>= 3;
@@ -433,12 +431,12 @@ void nic_tx_packet(uint16_t ring_ptr)
{ {
// uint16_t buffer = (uint16_t) tx_buf; // uint16_t buffer = (uint16_t) tx_buf;
uint16_t buffer = (uint16_t) uip_buf + VLAN_TAG_SIZE; uint16_t buffer = (uint16_t) uip_buf + VLAN_TAG_SIZE;
SFR_NIC_DATA_H = buffer >> 8; SFR_NIC_DATA_U16LE = buffer;
SFR_NIC_DATA_L = buffer;
ring_ptr <<= 3; ring_ptr <<= 3;
ring_ptr |= 0x8000; ring_ptr |= 0x8000;
SFR_NIC_RING_L = ring_ptr; SFR_NIC_RING_U16LE = ring_ptr;
SFR_NIC_RING_H = ring_ptr >> 8;
uint16_t len = (((uint16_t)uip_buf[VLAN_TAG_SIZE + 5]) << 8) | uip_buf[VLAN_TAG_SIZE + 4]; uint16_t len = (((uint16_t)uip_buf[VLAN_TAG_SIZE + 5]) << 8) | uip_buf[VLAN_TAG_SIZE + 4];
len += 0xf; len += 0xf;
len >>= 3; len >>= 3;