Exemple #1
0
/*---------------------------------------------------------------------------*/
static void
writereg(uint8_t reg, uint8_t data)
{
  enc28j60_arch_spi_select();
  enc28j60_arch_spi_write(0x40 | (reg & 0x1f));
  enc28j60_arch_spi_write(data);
  enc28j60_arch_spi_deselect();
}
Exemple #2
0
/*---------------------------------------------------------------------------*/
static void
write_op(uint8_t op, uint8_t address, uint8_t data)
{
  enc28j60_arch_spi_select();
  enc28j60_arch_spi_write(op | (address & ADDR_MASK));
  enc28j60_arch_spi_write(data);
  enc28j60_arch_spi_deselect();
}
Exemple #3
0
/*---------------------------------------------------------------------------*/
static void
writedatabyte(uint8_t byte)
{
  enc28j60_arch_spi_select();
  /* The Write Buffer Memory (WBM) command is 0 1 1 1 1 0 1 0  */
  enc28j60_arch_spi_write(0x7a);
  enc28j60_arch_spi_write(byte);
  enc28j60_arch_spi_deselect();
}
Exemple #4
0
/*---------------------------------------------------------------------------*/
static void
writedata(const uint8_t *data, int datalen)
{
  int i;
  enc28j60_arch_spi_select();
  /* The Write Buffer Memory (WBM) command is 0 1 1 1 1 0 1 0  */
  enc28j60_arch_spi_write(0x7a);
  for(i = 0; i < datalen; i++) {
    enc28j60_arch_spi_write(data[i]);
  }
  enc28j60_arch_spi_deselect();
}
Exemple #5
0
/*---------------------------------------------------------------------------*/
static void
clearregbitfield(uint8_t reg, uint8_t mask)
{
  if(is_mac_mii_reg(reg)) {
    writereg(reg, readreg(reg) & ~mask);
  } else {
    enc28j60_arch_spi_select();
    enc28j60_arch_spi_write(0xa0 | (reg & 0x1f));
    enc28j60_arch_spi_write(mask);
    enc28j60_arch_spi_deselect();
  }
}
Exemple #6
0
/*---------------------------------------------------------------------------*/
static void
softreset(void)
{
  enc28j60_arch_spi_select();
  /* The System Command (soft reset) is 1 1 1 1 1 1 1 1 */
  enc28j60_arch_spi_write(0xff);
  enc28j60_arch_spi_deselect();
}
Exemple #7
0
/*---------------------------------------------------------------------------*/
static uint8_t
readreg(uint8_t reg)
{
  uint8_t r;
  enc28j60_arch_spi_select();
  enc28j60_arch_spi_write(0x00 | (reg & 0x1f));
  r = enc28j60_arch_spi_read();
  enc28j60_arch_spi_deselect();
  return r;
}
Exemple #8
0
/*---------------------------------------------------------------------------*/
static uint8_t
readdatabyte(void)
{
  uint8_t r;
  enc28j60_arch_spi_select();
  /* THe Read Buffer Memory (RBM) command is 0 0 1 1 1 0 1 0 */
  enc28j60_arch_spi_write(0x3a);
  r = enc28j60_arch_spi_read();
  enc28j60_arch_spi_deselect();
  return r;
}
Exemple #9
0
/*---------------------------------------------------------------------------*/
static int
readdata(uint8_t *buf, int len)
{
  int i;
  enc28j60_arch_spi_select();
  /* THe Read Buffer Memory (RBM) command is 0 0 1 1 1 0 1 0 */
  enc28j60_arch_spi_write(0x3a);
  for(i = 0; i < len; i++) {
    buf[i] = enc28j60_arch_spi_read();
  }
  enc28j60_arch_spi_deselect();
  return i;
}
Exemple #10
0
/*---------------------------------------------------------------------------*/
static uint8_t
readreg(uint8_t reg)
{
  uint8_t r;
  enc28j60_arch_spi_select();
  enc28j60_arch_spi_write(0x00 | (reg & 0x1f));
  if(is_mac_mii_reg(reg)) {
    /* MAC and MII registers require that a dummy byte be read first. */
    enc28j60_arch_spi_read();
  }
  r = enc28j60_arch_spi_read();
  enc28j60_arch_spi_deselect();
  return r;
}
Exemple #11
0
/*---------------------------------------------------------------------------*/
uint8_t
enc28j60_arch_spi_read(void)
{
  return enc28j60_arch_spi_write(0);
}