opt: add SPI_TxRxBytes() to exchange multiple bytes

This commit is contained in:
IOsetting 2022-01-05 20:22:02 +08:00
parent 76f4fc2426
commit ddbaea3157
2 changed files with 9 additions and 0 deletions

View File

@ -92,5 +92,6 @@ typedef enum
#define SPI_SetPort(__ALTER_PORT__) (P_SW1 = P_SW1 & ~(0x03 << 2) | ((__ALTER_PORT__) << 2)) #define SPI_SetPort(__ALTER_PORT__) (P_SW1 = P_SW1 & ~(0x03 << 2) | ((__ALTER_PORT__) << 2))
uint8_t SPI_TxRx(uint8_t dat); uint8_t SPI_TxRx(uint8_t dat);
void SPI_TxRxBytes(uint8_t *pBuf, uint8_t len);
#endif #endif

View File

@ -24,3 +24,11 @@ uint8_t SPI_TxRx(uint8_t dat)
SPI_ClearInterrupts(); SPI_ClearInterrupts();
return SPDAT; return SPDAT;
} }
void SPI_TxRxBytes(uint8_t *pBuf, uint8_t len)
{
while(len--)
{
*pBuf++ = SPI_TxRx(*pBuf);
}
}