mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
SPI: Provide byte[] JNI interfaces.
This avoids a direct byte buffer allocation on every read/write/transaction for the byte[] variants. Also change spiGetAccumulatorOutput() to directly set the AccumulatorResult object, avoiding a ByteBuffer allocation. Changes HAL SPI interfaces to use const for dataToSend. Fixes #733.
This commit is contained in:
@@ -260,7 +260,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
||||
* @param size Number of bytes to transfer. [0..7]
|
||||
* @return Number of bytes transferred, -1 for error
|
||||
*/
|
||||
int32_t HAL_TransactionSPI(HAL_SPIPort port, uint8_t* dataToSend,
|
||||
int32_t HAL_TransactionSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
||||
uint8_t* dataReceived, int32_t size) {
|
||||
if (port < 0 || port >= kSpiMaxHandles) {
|
||||
return -1;
|
||||
@@ -286,7 +286,8 @@ int32_t HAL_TransactionSPI(HAL_SPIPort port, uint8_t* dataToSend,
|
||||
* @param sendSize The number of bytes to be written
|
||||
* @return The number of bytes written. -1 for an error
|
||||
*/
|
||||
int32_t HAL_WriteSPI(HAL_SPIPort port, uint8_t* dataToSend, int32_t sendSize) {
|
||||
int32_t HAL_WriteSPI(HAL_SPIPort port, const uint8_t* dataToSend,
|
||||
int32_t sendSize) {
|
||||
if (port < 0 || port >= kSpiMaxHandles) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user