mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/enc28j60: always set memory bank, if valid
Simplify handling of memory banks, ie. remove check if current bank is target bank and set it explicitly every time.
This commit is contained in:
parent
4759f691fc
commit
f35e4786f3
@ -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)
|
||||
@ -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;
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user