code: interfacing a chipcorder isd1760

some info regarding direct memory access:

many of the commands let you specify a range in memory to start and stop at. to automate playback ... recording etc...

my chip is the 60second version, the max memory location you can specify is 0x1EF or 495

each locaton is 10 bits long.

if you wanted to play from:
001 00100001 - 289
to
001 01000111 - 327

this chip will never use the first 2 bits, but the 240 second version will, its max value is
111 10001111 - 1935

the second byte you send is actually the first 3 bits of the number, the chipcorder is just lsb so its a little odd.
this spi command will do that (binary for readability

  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(SET_PLAY); // clear interupt and eom bit
  spi_transfer(0x00); // data byte
  
  spi_transfer(B00100001); // data byte start
  spi_transfer(B00000001); // data byte last 3 bits
  spi_transfer(B01000111); // data byte stop
  spi_transfer(B00000001); // data byte last 3 bits
  spi_transfer(0x00); // data byte blank
  digitalWrite(SLAVESELECT,HIGH);

now how about a better way to do this?

  int start = 289;
  int end   = 327;
  
  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(SET_PLAY); // clear interupt and eom bit
  spi_transfer(0); // data byte
  
  spi_transfer(start%256); // data byte start
  spi_transfer((int)start/256); // data byte last 3 bits
  spi_transfer(end%256); // data byte stop
  spi_transfer((int)end/256); // data byte last 3 bits
  spi_transfer(0); // data byte blank
  digitalWrite(SLAVESELECT,HIGH);

you could use also (read should probably) use bitmask also say
start&255 then start>>8

  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(SET_PLAY); // clear interupt and eom bit
  spi_transfer(0); // data byte
  
  spi_transfer(start&255); // data byte start
  spi_transfer(start>>8); // data byte last 3 bits
  spi_transfer(end&255); // data byte stop
  spi_transfer(start>>8); // data byte last 3 bits
  spi_transfer(0); // data byte blank
  digitalWrite(SLAVESELECT,HIGH);