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; } ...
Revision 3:aa88808326b9, committed 2021-03-29
- Comitter:
- hudakz
- Date:
- Mon Mar 29 08:37:01 2021 +0000
- Parent:
- 2:19d290369c66
- Commit message:
- Mbed OS Ethernet MAC (EMAC) driver for the ENC28J60 Ethernet controller. This a simplified fork of https://github.com/tobiasjaster/ENC28J60-EMAC-Driver published by Tobias Jaster.
Changed in this revision
diff -r 19d290369c66 -r aa88808326b9 enc28j60.cpp --- a/enc28j60.cpp Sat Mar 27 22:52:41 2021 +0000 +++ b/enc28j60.cpp Mon Mar 29 08:37:01 2021 +0000 @@ -80,6 +80,7 @@ * @retval */ ENC28J60::ENC28J60(mbed::SPI* spi, PinName cs) : + _spi(spi), _cs(cs), _bank(0), _ready(true), @@ -97,7 +98,6 @@ void ENC28J60::init() { // Initialize SPI interface - _cs = 1; _spi->format(8, 0); // 8bit, mode 0 _spi->frequency(20000000); // 20MHz
diff -r 19d290369c66 -r aa88808326b9 enc28j60_emac.cpp --- a/enc28j60_emac.cpp Sat Mar 27 22:52:41 2021 +0000 +++ b/enc28j60_emac.cpp Mon Mar 29 08:37:01 2021 +0000 @@ -20,7 +20,6 @@ #include "mbed_assert.h" #include "netsocket/nsapi_types.h" #include "mbed_shared_queues.h" - #include "enc28j60_emac.h" /**
diff -r 19d290369c66 -r aa88808326b9 enc28j60_emac.h --- a/enc28j60_emac.h Sat Mar 27 22:52:41 2021 +0000 +++ b/enc28j60_emac.h Mon Mar 29 08:37:01 2021 +0000 @@ -26,7 +26,6 @@ #include "mbed.h" #include "EMAC.h" #include "rtos.h" - #include "enc28j60_reg.h" #include "enc28j60.h" #include "enc28j60_emac_config.h"