Beispiel #1
0
static void writeBuf(word len, const byte* data) {
    enableChip();
    xferSPI(ENC28J60_WRITE_BUF_MEM);
    while (len--)
        xferSPI(*data++);
    disableChip();
}
Beispiel #2
0
static void readBuf(word len, byte* data) {
    enableChip();
    xferSPI(ENC28J60_READ_BUF_MEM);
    while (len--) {
        xferSPI(0x00);
        *data++ = SPDR;
    }
    disableChip();
}
Beispiel #3
0
static byte readOp (byte op, byte address) {
    enableChip();
    xferSPI(op | (address & ADDR_MASK));
    xferSPI(0x00);
    if (address & 0x80)
        xferSPI(0x00);
    byte result = SPDR;
    disableChip();
    return result;
}
byte ENC28J60Driver::readOp (uint8_t op, uint8_t address) {
    enableChip();
    xferSPI(op | (address & ADDR_MASK));
    xferSPI(0x00);
    if (address & 0x80)
        xferSPI(0x00);
    uint8_t result = SPDR;
    disableChip();
    return result;
}
Beispiel #5
0
static void drop(word len) {

    enableChip();
    xferSPI(ENC28J60_READ_BUF_MEM);
    while (len--) {
        xferSPI(0x00);
        SPDR;
    }
    disableChip();
}
Beispiel #6
0
static void writeBuf(uint16_t len, const byte* data) {
    enableChip();
    if (len != 0) {
        xferSPI(ENC28J60_WRITE_BUF_MEM);
           
        SPDR = *data++;    
        while (--len) {
            uint8_t nextbyte = *data++;
        	while (!(SPSR & (1<<SPIF)))
                ;
            SPDR = nextbyte;
     	};  
        while (!(SPSR & (1<<SPIF)))
            ;
    }
    disableChip();
}
Beispiel #7
0
static void readBuf(uint16_t len, byte* data) {
    uint8_t nextbyte;

    enableChip();
    if (len != 0) {    
        xferSPI(ENC28J60_READ_BUF_MEM);
          
        SPDR = 0x00; 
        while (--len) {
            while (!(SPSR & (1<<SPIF)))
                ;
            nextbyte = SPDR;
            SPDR = 0x00;
            *data++ = nextbyte;     
        }
        while (!(SPSR & (1<<SPIF)))
            ;
        *data++ = SPDR;    
    }
    disableChip(); 
}
Beispiel #8
0
static void writeOp (byte op, byte address, byte data) {
    enableChip();
    xferSPI(op | (address & ADDR_MASK));
    xferSPI(data);
    disableChip();
}
void ENC28J60Driver::writeOp (uint8_t op, uint8_t address, uint8_t data) {
    enableChip();
    xferSPI(op | (address & ADDR_MASK));
    xferSPI(data);
    disableChip();
}