mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Define and use DISCARD
This commit is contained in:
parent
35ade68bb3
commit
f96508ceec
2 changed files with 5 additions and 3 deletions
|
@ -55,9 +55,11 @@
|
||||||
#define PP_CALL(macro, ...) macro(__VA_ARGS__)
|
#define PP_CALL(macro, ...) macro(__VA_ARGS__)
|
||||||
|
|
||||||
#if !defined(UNUSED)
|
#if !defined(UNUSED)
|
||||||
#define UNUSED(x) (void)(x)
|
#define UNUSED(x) (void)(x) // Variables and parameters that are not used
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DISCARD(x) (void)(x) // To explicitly ignore result of x (usually an I/O register access).
|
||||||
|
|
||||||
#define STATIC_ASSERT(condition, name) _Static_assert((condition), #name)
|
#define STATIC_ASSERT(condition, name) _Static_assert((condition), #name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ uint8_t spiTransferByte(SPI_TypeDef *instance, uint8_t txByte)
|
||||||
{
|
{
|
||||||
uint16_t spiTimeout = 1000;
|
uint16_t spiTimeout = 1000;
|
||||||
|
|
||||||
instance->DR;
|
DISCARD(instance->DR);
|
||||||
|
|
||||||
while (SPI_I2S_GetFlagStatus(instance, SPI_I2S_FLAG_TXE) == RESET)
|
while (SPI_I2S_GetFlagStatus(instance, SPI_I2S_FLAG_TXE) == RESET)
|
||||||
if ((spiTimeout--) == 0)
|
if ((spiTimeout--) == 0)
|
||||||
|
@ -154,7 +154,7 @@ bool spiTransfer(SPI_TypeDef *instance, const uint8_t *txData, uint8_t *rxData,
|
||||||
uint16_t spiTimeout = 1000;
|
uint16_t spiTimeout = 1000;
|
||||||
|
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
instance->DR;
|
DISCARD(instance->DR);
|
||||||
while (len--) {
|
while (len--) {
|
||||||
b = txData ? *(txData++) : 0xFF;
|
b = txData ? *(txData++) : 0xFF;
|
||||||
while (SPI_I2S_GetFlagStatus(instance, SPI_I2S_FLAG_TXE) == RESET) {
|
while (SPI_I2S_GetFlagStatus(instance, SPI_I2S_FLAG_TXE) == RESET) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue