Skip to content

Commit

Permalink
[spi] increase max size for spi buffer length (8bits to 16bits)
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Feb 10, 2015
1 parent 605527b commit c2576c3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sw/airborne/arch/linux/mcu_periph/spi_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool_t spi_submit(struct spi_periph *p, struct spi_transaction *t)
memset(&xfer, 0, sizeof xfer);

/* length in bytes of transaction */
uint8_t buf_len = Max(t->input_length, t->output_length);
uint16_t buf_len = Max(t->input_length, t->output_length);

/* handle transactions with different input/output length */
if (buf_len > t->output_length) {
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/arch/lpc21/mcu_periph/spi_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ __attribute__((always_inline)) static inline void SpiTransmit(struct spi_periph
{
// when all byte are sent, continue until tx_idx reach input_length
// needed when input_length is bigger than output_length
uint8_t max_idx = Max(t->output_length, t->input_length);
uint16_t max_idx = Max(t->output_length, t->input_length);
while (p->tx_idx_buf < max_idx && bit_is_set(((sspRegs_t *)(p->reg_addr))->sr, TNF)) {
if (p->tx_idx_buf < t->output_length) {
if (t->dss == SPIDss8bit) {
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/mcu_periph/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ typedef void (*SPICallback)(struct spi_transaction *trans);
struct spi_transaction {
volatile uint8_t *input_buf; ///< pointer to receive buffer for DMA
volatile uint8_t *output_buf; ///< pointer to transmit buffer for DMA
uint8_t input_length; ///< number of data words to read
uint8_t output_length; ///< number of data words to write
uint16_t input_length; ///< number of data words to read
uint16_t output_length; ///< number of data words to write
uint8_t slave_idx; ///< slave id: #SPI_SLAVE0 to #SPI_SLAVE4
enum SPISlaveSelect select; ///< slave selection behavior
enum SPIClockPolarity cpol; ///< clock polarity control
Expand Down

0 comments on commit c2576c3

Please sign in to comment.