C.04. command 222: get free space in send buffer, C.06. command 227: set read ready size, Section 3.c.06 – Pololu Orangutan X2 User Manual
Page 18: Section 3.c.05, Section, C.04
Values sent: UART byte (8 bits)
command byte = 220 | MSB of send byte
data byte = seven lowest bits of send byte
3.c.04. Command 222: Get Free Space in Send Buffer
Effect: This command loads into the mega168’s SPDR (SPI data register) the number of unoccupied bytes in the
UART send buffer. Sending a second byte (either the NULL command or a junk data byte) over the SPI once
the value is loaded will transfer it to the mega644’s SPDR. It is recommended you do not begin transmission of
this second byte until 3 us after the transmission of the command byte has completed. This is to make sure the
mega168 has time to load the SPDR. If the buffer is empty this command will return 32. If the buffer is full this
call will return 0.
Values sent: none
command byte = 222
3.c.05. Command 223: Get Number of Bytes in Read Buffer
Effect: This command loads into the mega168’s SPDR (SPI data register) the number of occupied bytes in the
UART read buffer. Sending a second byte (either the NULL command or a junk data byte) over the SPI once
the value is loaded will transfer it to the mega644’s SPDR. It is recommended you do not begin transmission of
this second byte until 3 us after the transmission of the command byte has completed. This is to make sure the
mega168 has time to load the SPDR. If the buffer is full this call will return 32. If the buffer is empty this call will
return 0.
Values sent: none
command byte = 223
3.c.06. Command 227: Set Read Ready Size
Effect: This command specifies the size in bytes the read buffer must reach before the mega168’s status byte
alerts the mega644 that the buffer is ready to be read. The value transmitted is a five-bit number representing
read-ready size - 1
. That is to say, if the value transmitted to the mega168 is 0, read-ready size will be 1 and
the read-ready status flag will be set after every received byte. If the value transmitted is 31, read-ready size will
be 32 and the read-ready status flag will be set only when the read buffer is full. The default value for this setting
is one (set the read-ready flag after every received byte).
This value can be saved to byte 16 of EEPROM using command 240 (
) so that it will persist after a
hardware reset. When storing in EEPROM, you must ensure the value is within the allowed range of 1 – 32. The
value saved should be
read-ready size
, not
read-ready size - 1
.
Values sent: read-ready size – 1 (5 bits)
command byte = 227
data byte = read-ready size – 1
Orangutan X2 Command Documentation v1.01
© 2001–2010 Pololu Corporation
3. Low-Level SPI Commands
Page 18 of 27