EMAC driver for the ENC28J60 Ethernet controller. This is a simplified fork of https://github.com/tobiasjaster/ENC28J60-EMAC-Driver published by Tobias Jaster.
Dependents: MQTT_Hello MQTT_HelloENC28J60
EMAC driver for the ENC28J60 Ethernet controller
This is a fork (the INT and RST pins are not used) of the ENC28J60-EMAC driver published by Tobias Jaster at
https://github.com/tobiasjaster/ENC28J60-EMAC-Driver
Usage:
- Connect the ENC28J60 module to the Mbed board as follows:
- Import (add) this ENC28J60-EMAC library to your program.
- Add a "mbed_app.json" file with the following content to the root directory of your program:
{ "target_overrides": { "*": { "platform.callback-nontrivial": true, "enc28j60-emac.mosi": "D11", "enc28j60-emac.miso": "D12", "enc28j60-emac.sck" : "D13", "enc28j60-emac.cs" : "D10" } } }
- Replace "D11", ..., "D10" with the actual pin names you selected on the Mbed board to be used for the SPI communication.
- To set the MAC address define an array with the desired address bytes and call the "set_hwaddr(mac)" function before calling the network interface "connect" function.
For example:
const uint8_t MAC[6] = { 0, 1, 2, 3, 4, 5 }; EthernetInterface net; int main() { net.get_emac().set_hwaddr(MAC); // set MAC address if (net.connect() != 0) { printf("Error: Unable to connect to the network.\n"); return -1; } ...
README.md@0:b599e748252c, 2021-03-26 (annotated)
- Committer:
- hudakz
- Date:
- Fri Mar 26 15:58:28 2021 +0000
- Revision:
- 0:b599e748252c
Mbed OS Ethernet MAC (EMAC) driver for the ENC28J60 Ethernet controller.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 0:b599e748252c | 1 | # mbed OS Ethernet MAC (EMAC) driver for the ENC28J60 Ethernet controller |
hudakz | 0:b599e748252c | 2 | and modules equipped with such chip. |
hudakz | 0:b599e748252c | 3 | |
hudakz | 0:b599e748252c | 4 | This is a fork (simplified version) of the ENC28J60-EMAC driver published by Tobias Jaster at |
hudakz | 0:b599e748252c | 5 | |
hudakz | 0:b599e748252c | 6 | https://github.com/tobiasjaster/ENC28J60-EMAC-Driver |
hudakz | 0:b599e748252c | 7 | |
hudakz | 0:b599e748252c | 8 | Usage: |
hudakz | 0:b599e748252c | 9 | |
hudakz | 0:b599e748252c | 10 | 1. Connect the ENC28J60 module to the Mbed board as follows: |
hudakz | 0:b599e748252c | 11 | |
hudakz | 0:b599e748252c | 12 | |
hudakz | 0:b599e748252c | 13 | ------------- SPI interface -------------- |
hudakz | 0:b599e748252c | 14 | | | |
hudakz | 0:b599e748252c | 15 | MOSI |----------------------| MOSI |
hudakz | 0:b599e748252c | 16 | | | |
hudakz | 0:b599e748252c | 17 | MISO |----------------------| MISO |
hudakz | 0:b599e748252c | 18 | Mbed | | ENC28J60 |
hudakz | 0:b599e748252c | 19 | board SCK |----------------------| SCK module |
hudakz | 0:b599e748252c | 20 | | | |
hudakz | 0:b599e748252c | 21 | CS |----------------------| CS |
hudakz | 0:b599e748252c | 22 | | | |
hudakz | 0:b599e748252c | 23 | GND |----------------------| GND |
hudakz | 0:b599e748252c | 24 | | | |
hudakz | 0:b599e748252c | 25 | ------------- -------------- |
hudakz | 0:b599e748252c | 26 | |
hudakz | 0:b599e748252c | 27 | 2. Import (add) this ENC28J60-EMAC library to your program. |
hudakz | 0:b599e748252c | 28 | |
hudakz | 0:b599e748252c | 29 | 3. Add a "mbed_app.json" file with the following content |
hudakz | 0:b599e748252c | 30 | to the root directory of your program: |
hudakz | 0:b599e748252c | 31 | |
hudakz | 0:b599e748252c | 32 | { |
hudakz | 0:b599e748252c | 33 | "target_overrides": { |
hudakz | 0:b599e748252c | 34 | "*": { |
hudakz | 0:b599e748252c | 35 | "platform.callback-nontrivial": true, |
hudakz | 0:b599e748252c | 36 | "enc28j60-emac.mosi": "D11", |
hudakz | 0:b599e748252c | 37 | "enc28j60-emac.miso": "D12", |
hudakz | 0:b599e748252c | 38 | "enc28j60-emac.sck" : "D13", |
hudakz | 0:b599e748252c | 39 | "enc28j60-emac.cs" : "D10" |
hudakz | 0:b599e748252c | 40 | } |
hudakz | 0:b599e748252c | 41 | } |
hudakz | 0:b599e748252c | 42 | } |
hudakz | 0:b599e748252c | 43 | |
hudakz | 0:b599e748252c | 44 | Replace "D11", ... with the actual pin names you selected on the Mbed board |
hudakz | 0:b599e748252c | 45 | to be used for the SPI communication. |
hudakz | 0:b599e748252c | 46 | |
hudakz | 0:b599e748252c | 47 | 4. To set the MAC address define an array with the desired address bytes and |
hudakz | 0:b599e748252c | 48 | call the "set_hwaddr(mac)" function before calling the network interface "connect" function. |
hudakz | 0:b599e748252c | 49 | |
hudakz | 0:b599e748252c | 50 | For example: |
hudakz | 0:b599e748252c | 51 | |
hudakz | 0:b599e748252c | 52 | const uint8_t MAC[6] = { 0, 1, 2, 3, 4, 5 }; |
hudakz | 0:b599e748252c | 53 | EthernetInterface net; |
hudakz | 0:b599e748252c | 54 | |
hudakz | 0:b599e748252c | 55 | int main() |
hudakz | 0:b599e748252c | 56 | { |
hudakz | 0:b599e748252c | 57 | net.get_emac().set_hwaddr(MAC); // set MAC address |
hudakz | 0:b599e748252c | 58 | if (net.connect() != 0) { |
hudakz | 0:b599e748252c | 59 | printf("Error: Unable to connect to the network.\n"); |
hudakz | 0:b599e748252c | 60 | return -1; |
hudakz | 0:b599e748252c | 61 | } |
hudakz | 0:b599e748252c | 62 | |
hudakz | 0:b599e748252c | 63 | ... |
hudakz | 0:b599e748252c | 64 |