moccos mizuki / EthernetXpresso

Dependents:   XNetServicesMin

Revision:
1:95a4c234aaf6
Parent:
0:b4bf563e9741
Child:
3:7ba8ebe32420
--- a/LPC1769Emac.h	Sun May 06 10:11:53 2012 +0000
+++ b/LPC1769Emac.h	Sun May 06 10:52:06 2012 +0000
@@ -3,8 +3,13 @@
 #include <stdint.h>
 #include "Frame.h"
 
+/**
+ * LPCXpresso LPC1769 ethernet library.
+ * @author @moccos
+ */
 class LPC1769Emac {
 public:
+    // same as mbed
     enum LinkMode {
         AutoNegotiate,
         HalfDuplex10,
@@ -14,28 +19,116 @@
     };
 
 public:
+    /**
+     * Enable LPC1769 ethernet block.
+     */
     LPC1769Emac();
+    
+    /**
+     * Disable LPC1769 ethernet block.
+     */
     ~LPC1769Emac();
+    
+    /**
+     * Write 16-bit value to PHY register.
+     * @param reg register index. See LAN8710AReg.h.
+     * @param value
+     */
     bool PhyWrite(uint8_t reg, uint16_t value);
-    uint16_t PhyRead(uint16_t reg);
+    
+    /**
+     * Read 16-bit value from PHY register.
+     * @param reg register index. See LAN8710AReg.h.
+     */
+    uint16_t PhyRead(uint8_t reg);
+    
+    /**
+     * Set ethernet address before initialization for debug.
+     */
     static void SetAddress(uint8_t a5, uint8_t a4, uint8_t a3, uint8_t a2, uint8_t a1, uint8_t a0);
+
+    /**
+     * Update ethernet address.
+     */
+    void UpdateAddress(uint8_t a5, uint8_t a4, uint8_t a3, uint8_t a2, uint8_t a1, uint8_t a0);
+    
+    /**
+     * Enable RX flags.
+     */
     void StartRx();
+
+    /**
+     * Enable TX flags.
+     */
     void StartTx();
+
+    /**
+     * Disable RX flags.
+     */
     void StopRx();
+
+    /**
+     * Disable TX flags.
+     */
     void StopTx();
+
+    /**
+     * Check link status.
+     * @return true if the link is up
+     */
     bool Link();
-    uint16_t Recv(void *buf, uint16_t max_size);
+    
+    /**
+     * Read data from received packet.
+     * @param buf destination buffer
+     * @param max_size
+     */
+    uint16_t Read(void *buf, uint16_t max_size);
+    
+    /**
+     * Check received packet.
+     * @return The size of readabe data
+     */
     uint16_t ReadyToReceive();
+    
+    /**
+     * Write data to the TX buffer.
+     * @param buf data
+     * @size
+     */
     uint16_t Write(void *buf, uint16_t size);
+    
+    /**
+     * Send data from the TX buffer to the network.
+     */
     bool Send();
+    
+    /**
+     * Send data from the user buffer to the network.
+     * Current TX buffer is overwritten.
+     * @param buf data
+     * @size
+     */
     bool Send(void *buf, uint16_t size);
+    
+    /**
+     * Reset ethernet registers and PHY registers.
+     * @param Linkmode select auto-negotiation or fixed link speed and duplex
+     */
     bool Reset(LinkMode mode=AutoNegotiate);
+    
+    /**
+     * Gets ethernet address.
+     * @return ethernet address
+     */
     static const char* getHwAddr() { return (const char*)mac_; }
 
 private:
+    /** The number of RX resources */
     static const uint8_t N_RX_BUF = 5;
+    
+    /// The number of TX resources
     static const uint8_t N_TX_BUF = 3;
-    static const uint32_t BASE_ADDR = 0x20080000;
     static const uint16_t PHY_ADDR = 0x0100;
     static uint8_t mac_[6];
     static Descriptor rx_desc_[N_RX_BUF];
@@ -44,14 +137,6 @@
     static StatusTx tx_status_[N_TX_BUF];
     static Frame rx_frame_[N_RX_BUF];
     static Frame tx_frame_[N_TX_BUF];
-    /*
-    Descriptor *rx_desc_;
-    Descriptor *tx_desc_;
-    StatusRx *rx_status_;
-    StatusTx *tx_status_;
-    Frame *rx_frame_;
-    Frame *tx_frame_;
-    */
     uint8_t *write_next_;
     uint8_t *read_next_;
     uint16_t write_size_;