From 0dbc5d32dbefadd8b963c16328f22bff3d57f6dd Mon Sep 17 00:00:00 2001 From: isometimes Date: Wed, 6 Jul 2022 19:58:16 +0100 Subject: [PATCH] A few corrections --- part14-spi-ethernet/README.md | 4 ++-- part14-spi-ethernet/kernel/arp.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/part14-spi-ethernet/README.md b/part14-spi-ethernet/README.md index 9c40a7c..9597ea9 100644 --- a/part14-spi-ethernet/README.md +++ b/part14-spi-ethernet/README.md @@ -51,7 +51,7 @@ void gpio_initOutputPinWithPullNone(unsigned int pin_number); Specifically, `spi_init()` sets GPIO 7, 9, 10, and 11 to use the ALT0 function. Cross-referencing with the [BCM2711 ARM Peripherals document](https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf), page 77, you'll see that this maps SPI0 to the GPIO header. GPIO 8 is mapped as an output pin, since we'll use this to signal to the ENC28J60 that we want to talk. In fact, the `spi_chip_select()` function takes a true/false (boolean) parameter which either sets or clears this pin. -Looking at the SPI0 register map on page 134, we see this reflected in our `REGS_SPI0` structure. This gives us handy access to the SPI0 peripheral's memory-mapped registers. +Looking at the SPI0 register map on page 136, we see this reflected in our `REGS_SPI0` structure. This gives us handy access to the SPI0 peripheral's memory-mapped registers. Our `spi_send_recv()` function then sets us up for some communcation: @@ -99,7 +99,7 @@ void ENC_SPI_SendWithoutSelection(unsigned char command) { } ``` -Perhaps the most confusing aspect is the chip selection. Through a bit of trial & error I discovered that when GPIO08 is clear, the device is selected, and when it's set, the device is deselected. If you can explain this to me, I'd love to hear from you - frankly, I was just pleased to get it working, so I moved on! +Perhaps the most confusing aspect is the chip selection. Through a bit of trial & error I discovered that when GPIO08 is clear, the device is selected, and when it's set, the device is deselected. It turns out this is because the Chip Select pin on the ENC28J60 is active LOW and there's no invertor on the board (presumably to save costs), so GPIO08 must be LOW to enable the IC. Some more timer functions ------------------------- diff --git a/part14-spi-ethernet/kernel/arp.c b/part14-spi-ethernet/kernel/arp.c index b3d6314..0df7a7b 100644 --- a/part14-spi-ethernet/kernel/arp.c +++ b/part14-spi-ethernet/kernel/arp.c @@ -105,7 +105,7 @@ void SendArpPacket(uint8_t *targetIP, uint8_t *deviceMAC) // The source of the packet will be the ENC28J60 MAC address memcpy(arpPacket.eth.SrcAddrs, deviceMAC, 6); - // The destination is broadcast - a MAC address of FF:FF:FF:FF:FF:FF */ + // The destination is broadcast - a MAC address of FF:FF:FF:FF:FF:FF memset(arpPacket.eth.DestAddrs, 0xFF, 6); arpPacket.eth.type = ARPPACKET;