This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

send more than 255 bytes by spi, nrf52

I'm communicating with N25 flash memory, the page size is 256 bytes. there is a page_program command which can write up to 256 bytes. there is no way to write in the middle of page (page @ + offset).

the issue it that SPI function has size parameter as uint8_t, so by adding the instruction code and the address to the frame (4 bytes in total), I always loose 4 bytes for each page.

is there anyway to send more then 255 bytes with nrf_drv_spi_transfer

Parents
  • In my opinion this is an error in the Nordic spi driver implementation, as maximum SPI write length should be set more explicitly, rather than simply because they use uint8_t for the rx_ and tx_ buffer length values.

    I modified this (and tested it, though not a huge amount) by changing nrf_drv_spi.c and .h to use uint16_t for rx and tx buffers, as well as bytes_transferred in the spi_control_block_t struct.

    I generally dislike modifying the stack but they provide source and this is an annoying constraint.

Reply
  • In my opinion this is an error in the Nordic spi driver implementation, as maximum SPI write length should be set more explicitly, rather than simply because they use uint8_t for the rx_ and tx_ buffer length values.

    I modified this (and tested it, though not a huge amount) by changing nrf_drv_spi.c and .h to use uint16_t for rx and tx buffers, as well as bytes_transferred in the spi_control_block_t struct.

    I generally dislike modifying the stack but they provide source and this is an annoying constraint.

Children
Related