示例#1
0
文件: enc28j60.c 项目: Devesh24/6lbr
/*---------------------------------------------------------------------------*/
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();
}
示例#2
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();
}
示例#3
0
文件: enc28j60.c 项目: ADVANSEE/mist
/*---------------------------------------------------------------------------*/
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();
}
示例#4
0
文件: enc28j60.c 项目: ADVANSEE/mist
/*---------------------------------------------------------------------------*/
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();
}
示例#5
0
文件: enc28j60.c 项目: ADVANSEE/mist
/*---------------------------------------------------------------------------*/
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;
}
示例#6
0
文件: enc28j60.c 项目: ADVANSEE/mist
/*---------------------------------------------------------------------------*/
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;
}
示例#7
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();
}
示例#8
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();
  }
}
示例#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;
}
示例#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;
}