Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LPC1769Emac.h@0:b4bf563e9741, 2012-05-06 (annotated)
- Committer:
- moccos
- Date:
- Sun May 06 10:11:53 2012 +0000
- Revision:
- 0:b4bf563e9741
- Child:
- 1:95a4c234aaf6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
moccos | 0:b4bf563e9741 | 1 | #ifndef LPC1769EMAC_H |
moccos | 0:b4bf563e9741 | 2 | #define LPC1769EMAC_H |
moccos | 0:b4bf563e9741 | 3 | #include <stdint.h> |
moccos | 0:b4bf563e9741 | 4 | #include "Frame.h" |
moccos | 0:b4bf563e9741 | 5 | |
moccos | 0:b4bf563e9741 | 6 | class LPC1769Emac { |
moccos | 0:b4bf563e9741 | 7 | public: |
moccos | 0:b4bf563e9741 | 8 | enum LinkMode { |
moccos | 0:b4bf563e9741 | 9 | AutoNegotiate, |
moccos | 0:b4bf563e9741 | 10 | HalfDuplex10, |
moccos | 0:b4bf563e9741 | 11 | FullDuplex10, |
moccos | 0:b4bf563e9741 | 12 | HalfDuplex100, |
moccos | 0:b4bf563e9741 | 13 | FullDuplex100 |
moccos | 0:b4bf563e9741 | 14 | }; |
moccos | 0:b4bf563e9741 | 15 | |
moccos | 0:b4bf563e9741 | 16 | public: |
moccos | 0:b4bf563e9741 | 17 | LPC1769Emac(); |
moccos | 0:b4bf563e9741 | 18 | ~LPC1769Emac(); |
moccos | 0:b4bf563e9741 | 19 | bool PhyWrite(uint8_t reg, uint16_t value); |
moccos | 0:b4bf563e9741 | 20 | uint16_t PhyRead(uint16_t reg); |
moccos | 0:b4bf563e9741 | 21 | static void SetAddress(uint8_t a5, uint8_t a4, uint8_t a3, uint8_t a2, uint8_t a1, uint8_t a0); |
moccos | 0:b4bf563e9741 | 22 | void StartRx(); |
moccos | 0:b4bf563e9741 | 23 | void StartTx(); |
moccos | 0:b4bf563e9741 | 24 | void StopRx(); |
moccos | 0:b4bf563e9741 | 25 | void StopTx(); |
moccos | 0:b4bf563e9741 | 26 | bool Link(); |
moccos | 0:b4bf563e9741 | 27 | uint16_t Recv(void *buf, uint16_t max_size); |
moccos | 0:b4bf563e9741 | 28 | uint16_t ReadyToReceive(); |
moccos | 0:b4bf563e9741 | 29 | uint16_t Write(void *buf, uint16_t size); |
moccos | 0:b4bf563e9741 | 30 | bool Send(); |
moccos | 0:b4bf563e9741 | 31 | bool Send(void *buf, uint16_t size); |
moccos | 0:b4bf563e9741 | 32 | bool Reset(LinkMode mode=AutoNegotiate); |
moccos | 0:b4bf563e9741 | 33 | static const char* getHwAddr() { return (const char*)mac_; } |
moccos | 0:b4bf563e9741 | 34 | |
moccos | 0:b4bf563e9741 | 35 | private: |
moccos | 0:b4bf563e9741 | 36 | static const uint8_t N_RX_BUF = 5; |
moccos | 0:b4bf563e9741 | 37 | static const uint8_t N_TX_BUF = 3; |
moccos | 0:b4bf563e9741 | 38 | static const uint32_t BASE_ADDR = 0x20080000; |
moccos | 0:b4bf563e9741 | 39 | static const uint16_t PHY_ADDR = 0x0100; |
moccos | 0:b4bf563e9741 | 40 | static uint8_t mac_[6]; |
moccos | 0:b4bf563e9741 | 41 | static Descriptor rx_desc_[N_RX_BUF]; |
moccos | 0:b4bf563e9741 | 42 | static Descriptor tx_desc_[N_TX_BUF]; |
moccos | 0:b4bf563e9741 | 43 | static StatusRx rx_status_[N_RX_BUF]; |
moccos | 0:b4bf563e9741 | 44 | static StatusTx tx_status_[N_TX_BUF]; |
moccos | 0:b4bf563e9741 | 45 | static Frame rx_frame_[N_RX_BUF]; |
moccos | 0:b4bf563e9741 | 46 | static Frame tx_frame_[N_TX_BUF]; |
moccos | 0:b4bf563e9741 | 47 | /* |
moccos | 0:b4bf563e9741 | 48 | Descriptor *rx_desc_; |
moccos | 0:b4bf563e9741 | 49 | Descriptor *tx_desc_; |
moccos | 0:b4bf563e9741 | 50 | StatusRx *rx_status_; |
moccos | 0:b4bf563e9741 | 51 | StatusTx *tx_status_; |
moccos | 0:b4bf563e9741 | 52 | Frame *rx_frame_; |
moccos | 0:b4bf563e9741 | 53 | Frame *tx_frame_; |
moccos | 0:b4bf563e9741 | 54 | */ |
moccos | 0:b4bf563e9741 | 55 | uint8_t *write_next_; |
moccos | 0:b4bf563e9741 | 56 | uint8_t *read_next_; |
moccos | 0:b4bf563e9741 | 57 | uint16_t write_size_; |
moccos | 0:b4bf563e9741 | 58 | uint16_t read_size_; |
moccos | 0:b4bf563e9741 | 59 | |
moccos | 0:b4bf563e9741 | 60 | private: |
moccos | 0:b4bf563e9741 | 61 | void WriteAddress_(); |
moccos | 0:b4bf563e9741 | 62 | bool CheckAutoNeg_(); |
moccos | 0:b4bf563e9741 | 63 | void InitRxBuffer_(); |
moccos | 0:b4bf563e9741 | 64 | void InitTxBuffer_(); |
moccos | 0:b4bf563e9741 | 65 | }; |
moccos | 0:b4bf563e9741 | 66 | |
moccos | 0:b4bf563e9741 | 67 | #endif |