Example #1
0
uint8_t W5100_MemReadWord(uint16_t addr, uint16_t *val) {
  uint8_t low, high;
  
  W5100_RequestSPIBus();

  W5100_CS_ENABLE();
  SPIWriteByte(W5100_CMD_READ);
  SPIWriteByte(addr>>8); /* high address */
  SPIWriteByte(addr&0xff); /* low address */
  high = SPIReadByte(); /* data */
  W5100_CS_DISABLE();
  
  addr++;
  W5100_CS_ENABLE();
  SPIWriteByte(W5100_CMD_READ);
  SPIWriteByte(addr>>8); /* high address */
  SPIWriteByte(addr&0xff); /* low address */
  low = SPIReadByte(); /* data */
  W5100_CS_DISABLE();
  
  W5100_ReleaseSPIBus();
  
  *val = (high<<8)|low;
  return ERR_OK;
}
Example #2
0
uint8_t W5100_MemWriteWord(uint16_t addr, uint16_t val) {
  W5100_RequestSPIBus();

  W5100_CS_ENABLE();
  SPIWriteByte(W5100_CMD_WRITE);
  SPIWriteByte(addr>>8); /* high address */
  SPIWriteByte(addr&0xff); /* low address */
  SPIWriteByte(val>>8); /* data */
  W5100_CS_DISABLE();

  addr++;
  W5100_CS_ENABLE();
  SPIWriteByte(W5100_CMD_WRITE);
  SPIWriteByte(addr>>8); /* high address */
  SPIWriteByte(addr&0xff); /* low address */
  SPIWriteByte(val&0xff); /* data */
  W5100_CS_DISABLE();

  W5100_ReleaseSPIBus();
  return ERR_OK;
}
Example #3
0
void W5100_GetBus(void) {
  W5100_RequestSPIBus();
  W5100_CS_ENABLE();
}
Example #4
0
/*
** ===================================================================
**     Event       :  SD1_OnActivate (module Events)
**
**     Component   :  SD1 [SD_Card]
**     Description :
**         Event called when Activate() method is called. This gives an
**         opportunity to the application to synchronize access to a
**         shared bus.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void SD1_OnActivate(void)
{
    W5100_RequestSPIBus();
}