Skip to content

Commit

Permalink
drivers/enc28j60: always set memory bank, if valid
Browse files Browse the repository at this point in the history
Simplify handling of memory banks, ie. remove check if current bank
is target bank and set it explicitly every time.
  • Loading branch information
smlng committed Sep 5, 2018
1 parent 4759f69 commit f35e478
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions drivers/enc28j60/enc28j60.c
Expand Up @@ -89,16 +89,15 @@

static void switch_bank(enc28j60_t *dev, int8_t bank)
{
/* only switch bank if needed */
if ((bank < 0) || (dev->bank == bank)) {
assert(bank < 0x04);

if (bank < 0) {
return;
}
/* clear old value */
spi_transfer_reg(SPI_BUS, CS_PIN, (CMD_BFC | REG_ECON1), 0x03);
/* set new value */
spi_transfer_reg(SPI_BUS, CS_PIN, (CMD_BFS | REG_ECON1), bank);
/* remember active bank */
dev->bank = bank;
}

static uint8_t cmd_rcr(enc28j60_t *dev, uint8_t reg, int8_t bank)
Expand Down Expand Up @@ -540,7 +539,6 @@ static const netdev_driver_t netdev_driver_enc28j60 = {
void enc28j60_setup(enc28j60_t *dev, const enc28j60_params_t *params)
{
dev->netdev.driver = &netdev_driver_enc28j60;
dev->bank = 99; /* mark as invalid */
dev->p = *params;
mutex_init(&dev->lock);
dev->tx_time = 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/include/enc28j60.h
Expand Up @@ -47,7 +47,6 @@ typedef struct {
*/
typedef struct {
netdev_t netdev; /**< pull in the netdev fields */
int8_t bank; /**< remember the active register bank */
enc28j60_params_t p; /**< SPI and pin confiuration */
mutex_t lock; /**< lock the device on access */
uint32_t tx_time; /**< last transmission time for timeout handling */
Expand Down

0 comments on commit f35e478

Please sign in to comment.