Skip to main content
deleted 11 characters in body
Source Link
Mikael Patel
  • 8k
  • 2
  • 16
  • 21

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer but transfer can be byte aligned with the start bit.

READ is op-code(10) followed by 7-bit address, a dummy bit and the read value. That is in total 1011+8-bits. Mapping that to 8-bit transfer would be (addr is 7-bits, MSB must be zero):

spi.transfer(0b110b110);
spi.transfer(addr << 1);
data = spi.transfer(0);

That will give 65-bit zero, start-bit, MSB of op-code in the first transfer, and LSB of op-code followed by 7-bit address and dummy bit (LSB) in second transfer. The third transfer is the read data.

EWEN would map to:

spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.

The WRITE operation becomes:

spi.transfer(0b10);
spi.transfer(0x80 | addr);
spi.transfer(data);

Cheers!

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer.

READ is op-code(10) followed by 7-bit address. That is in total 10-bits. Mapping that to 8-bit transfer would be (addr is 7-bits, MSB must be zero):

spi.transfer(0b11);
spi.transfer(addr);
data = spi.transfer(0);

That will give 6-bit zero, start-bit, MSB of op-code in first transfer, and LSB of op-code followed by 7-bit address in second transfer.

EWEN would map to:

spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.

The WRITE operation becomes:

spi.transfer(0b10);
spi.transfer(0x80 | addr);
spi.transfer(data);

Cheers!

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer but transfer can be byte aligned with the start bit.

READ is op-code(10) followed by 7-bit address, a dummy bit and the read value. That is in total 11+8-bits. Mapping that to 8-bit transfer would be:

spi.transfer(0b110);
spi.transfer(addr << 1);
data = spi.transfer(0);

That will give 5-bit zero, start-bit, op-code in the first transfer, and followed by 7-bit address and dummy bit (LSB) in second transfer. The third transfer is the read data.

EWEN would map to:

spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.

The WRITE operation becomes:

spi.transfer(0b10);
spi.transfer(0x80 | addr);
spi.transfer(data);

Cheers!

added 116 characters in body
Source Link
Mikael Patel
  • 8k
  • 2
  • 16
  • 21

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer.

READ is op-code(10) followed by 7-bit address. That is in total 10-bits. Mapping that to 8-bit transfer would be (addr is 7-bits, MSB must be zero):

spi.transfer(0b11);
spi.transfer(address & 0x7faddr);
data = spi.transfer(0);

That will give 6-bit zero, start-bit, MSB of op-code in first transfer, and LSB of op-code followed by 7-bit address in second transfer.

EWEN would map to:

spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.

The WRITE operation becomes:

spi.transfer(0b10);
spi.transfer(0x80 | addr);
spi.transfer(data);

Cheers!

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer.

READ is op-code(10) followed by 7-bit address. That is in total 10-bits. Mapping that to 8-bit transfer would be:

spi.transfer(0b11);
spi.transfer(address & 0x7f);
data = spi.transfer(0);

That will give 6-bit zero, start-bit, MSB of op-code in first transfer, and LSB of op-code followed by 7-bit address in second transfer.

EWEN would map to:

spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.

Cheers!

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer.

READ is op-code(10) followed by 7-bit address. That is in total 10-bits. Mapping that to 8-bit transfer would be (addr is 7-bits, MSB must be zero):

spi.transfer(0b11);
spi.transfer(addr);
data = spi.transfer(0);

That will give 6-bit zero, start-bit, MSB of op-code in first transfer, and LSB of op-code followed by 7-bit address in second transfer.

EWEN would map to:

spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.

The WRITE operation becomes:

spi.transfer(0b10);
spi.transfer(0x80 | addr);
spi.transfer(data);

Cheers!

Source Link
Mikael Patel
  • 8k
  • 2
  • 16
  • 21

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer.

READ is op-code(10) followed by 7-bit address. That is in total 10-bits. Mapping that to 8-bit transfer would be:

spi.transfer(0b11);
spi.transfer(address & 0x7f);
data = spi.transfer(0);

That will give 6-bit zero, start-bit, MSB of op-code in first transfer, and LSB of op-code followed by 7-bit address in second transfer.

EWEN would map to:

spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.

Cheers!