struct spiInitDef_t * spiInitDef = spiInitDefs + id - 1;
- while(nb >= 1)
+ while(nb--)
{
taskENTER_CRITICAL();
//read data
while (SPI_I2S_GetFlagStatus(spiInitDef->id, SPI_I2S_FLAG_RXNE) == RESET);
- *buffer = (uint8_t) SPI_I2S_ReceiveData(spiInitDef->id);
+ *buffer++ = (uint8_t) SPI_I2S_ReceiveData(spiInitDef->id);
//printf("%02x", *buffer);
taskEXIT_CRITICAL();
-
- nb--;
- buffer++;
}
}
struct spiInitDef_t * spiInitDef = spiInitDefs + id - 1;
- while(nb >= 1)
+ while(nb--)
{
taskENTER_CRITICAL();
//send data
while (SPI_I2S_GetFlagStatus(spiInitDef->id, SPI_I2S_FLAG_TXE) == RESET);
- SPI_I2S_SendData(spiInitDef->id, *buffer);
+ SPI_I2S_SendData(spiInitDef->id, *buffer++);
//read, because that's the rule
while (SPI_I2S_GetFlagStatus(spiInitDef->id, SPI_I2S_FLAG_RXNE) == RESET);
SPI_I2S_ReceiveData(spiInitDef->id);
taskEXIT_CRITICAL();
-
- nb--;
- buffer++;
}
}
void uart_read(uint8_t id, uint8_t *buffer, uint8_t nb)
{
- while (nb > 0)
- {
- *buffer = uart_receive_char(id);
- buffer++;
- nb--;
- }
+ while (nb--)
+ *buffer++ = uart_receive_char(id);
}
void uart_write(uint8_t id, uint8_t *buffer, uint8_t nb)
{
- while (nb > 0)
- {
- uart_send_char(id, (uint8_t) (*buffer));
- buffer++;
- nb--;
- }
+ while (nb--)
+ uart_send_char(id, (uint8_t) (*buffer++));
}