Пример #1
0
static void writeBuf(word len, const byte* data) {
    enableChip();
    xferSPI(ENC28J60_WRITE_BUF_MEM);
    while (len--)
        xferSPI(*data++);
    disableChip();
}
Пример #2
0
static void readBuf(word len, byte* data) {
    enableChip();
    xferSPI(ENC28J60_READ_BUF_MEM);
    while (len--) {
        xferSPI(0x00);
        *data++ = SPDR;
    }
    disableChip();
}
Пример #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;
}
Пример #4
0
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;
}
Пример #5
0
static void drop(word len) {

    enableChip();
    xferSPI(ENC28J60_READ_BUF_MEM);
    while (len--) {
        xferSPI(0x00);
        SPDR;
    }
    disableChip();
}
Пример #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();
}
Пример #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(); 
}
Пример #8
0
static void writeOp (byte op, byte address, byte data) {
    enableChip();
    xferSPI(op | (address & ADDR_MASK));
    xferSPI(data);
    disableChip();
}
Пример #9
0
void ENC28J60Driver::writeOp (uint8_t op, uint8_t address, uint8_t data) {
    enableChip();
    xferSPI(op | (address & ADDR_MASK));
    xferSPI(data);
    disableChip();
}