Skip to content

Commit

Permalink
Legacy ethernet demo updated
Browse files Browse the repository at this point in the history
  • Loading branch information
marnovandermaas committed Nov 7, 2024
1 parent 50bb237 commit d410c66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
8 changes: 5 additions & 3 deletions sw/legacy/common/rv_plic.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "dev_access.h"
#include "sonata_system.h"

#define NUM_IRQS 182
#define NUM_IRQS 32

#define I2C0_INTERRUPT 16

#define RV_PLIC_IRQ_PRIO_BASE_REG 0x000000
#define RV_PLIC_IRQ_PENDING_BASE_REG 0x001000
Expand Down Expand Up @@ -43,8 +45,8 @@ void rv_plic_init(void) {
// Set priority threshold to 0 so IRQs can trigger with any non-zero priority.
DEV_WRITE(RV_PLIC_BASE + RV_PLIC_CTX_THRESHOLD_REG, 0);

install_exception_handler(11, rv_plic_handler);
enable_interrupts(1 << 11);
install_exception_handler(I2C0_INTERRUPT, rv_plic_handler);
enable_interrupts(1 << I2C0_INTERRUPT);
arch_local_irq_enable();
}

Expand Down
17 changes: 8 additions & 9 deletions sw/legacy/demo/ethernet/ksz8851.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
#include "spi.h"
#include "timer.h"

enum {
// IRQ
EthIntrIrq = 47,
#define ETHERNET_INTERRUPT_INDEX 2

// GPIO Output
EthRstPin = 14,
enum {
// CS line 1 on SPI controler.
EthRstPin = 1,

// CS line 0 on SPI controller.
EthCsLine = 0,
Expand Down Expand Up @@ -303,9 +302,9 @@ err_t ksz8851_init(struct netif *netif) {
if (!spi) return ERR_ARG;

// Reset chip
set_output_bit(GPIO_OUT, EthRstPin, 0);
spi_set_cs(spi, EthRstPin, 0);
timer_delay(150);
set_output_bit(GPIO_OUT, EthRstPin, 0x1);
spi_set_cs(spi, EthRstPin, 1);

uint16_t cider = ksz8851_reg_read(spi, ETH_CIDER);
putstr("KSZ8851: Chip ID is ");
Expand Down Expand Up @@ -380,8 +379,8 @@ err_t ksz8851_init(struct netif *netif) {

// Initialize IRQ
eth_netif = netif;
rv_plic_register_irq(EthIntrIrq, ksz8851_irq_handler);
rv_plic_enable(EthIntrIrq);
rv_plic_register_irq(ETHERNET_INTERRUPT_INDEX, ksz8851_irq_handler);
rv_plic_enable(ETHERNET_INTERRUPT_INDEX);

puts("KSZ8851: Initialized");
return ERR_OK;
Expand Down

0 comments on commit d410c66

Please sign in to comment.