Ejemplo n.º 1
0
void enc28j60_writeBuffer(enc28j60_connection* c, uint16_t len, uint8_t* data){
  spi_cs_on(c->cs_pin);
  
  // issue write command
  spi_write(ENC28J60_WRITE_BUF_MEM);
  spi_write_buffer(data, len);

  spi_cs_off(c->cs_pin);
}
Ejemplo n.º 2
0
void enc28j60_readBuffer(enc28j60_connection* c, uint16_t len, uint8_t* data) {
  spi_cs_on(c->cs_pin);

  // issue read command
  spi_write(ENC28J60_READ_BUF_MEM);
  spi_read_buffer(data, len);
  
  spi_cs_off(c->cs_pin);
}
Ejemplo n.º 3
0
void enc28j60_writeOp(enc28j60_connection* c, uint8_t op, uint8_t address, uint8_t data){
  spi_cs_on(c->cs_pin);

  // issue write command
  spi_write(op | (address & ADDR_MASK));
  // write data
  spi_write(data);

  spi_cs_off(c->cs_pin);
}
Ejemplo n.º 4
0
void SD_SendCommand(u08 cmd, u32 arg, u08 crc, u08 * buffer, u16 len)
{
  u16 i;
  spi_cs_off();
  spi_master_SendByte(cmd);
  spi_master_SendByte(arg>>24);
  spi_master_SendByte(arg>>16);
  spi_master_SendByte(arg>>8);
  spi_master_SendByte(arg);
  spi_master_SendByte(crc);
  for(i=0;i<len;i++) buffer[i] = spi_master_SendByte(0xFF);
  spi_cs_on();
}
Ejemplo n.º 5
0
uint8_t enc28j60_readOp(enc28j60_connection* c, uint8_t op, uint8_t address) {
  uint8_t ret;
  
  spi_cs_on(c->cs_pin);

  // issue read command
  spi_write(op | (address & ADDR_MASK));
  // read data
  ret = spi_read();
  // do dummy read if needed (for mac and mii, see datasheet page 29)
  if(address & 0x80) 
    ret = spi_read();
  
  // release CS
  spi_cs_off(c->cs_pin);
  
  return ret;
}