Skip to content

Commit

Permalink
use 32 bits for lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
marcushultman committed Jul 8, 2023
1 parent 4710757 commit 3ca3ba7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/spidev_lib++.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool SPI::setMode(uint8_t p_mode){

}

int SPI::xfer(uint8_t *p_txbuffer, uint8_t p_txlen, uint8_t *p_rxbuffer, uint8_t p_rxlen){
int SPI::xfer(uint8_t *p_txbuffer, uint32_t p_txlen, uint8_t *p_rxbuffer, uint32_t p_rxlen){
struct spi_ioc_transfer spi_message[1];
memset(spi_message, 0, sizeof(spi_message));

Expand All @@ -86,7 +86,7 @@ int SPI::xfer(uint8_t *p_txbuffer, uint8_t p_txlen, uint8_t *p_rxbuffer, uint8_t
return ioctl(m_spifd, SPI_IOC_MESSAGE(1), spi_message);
}

int SPI::write(uint8_t *p_txbuffer,uint8_t p_txlen){
int SPI::write(uint8_t *p_txbuffer, uint32_t p_txlen){
struct spi_ioc_transfer spi_message[1];
memset(spi_message, 0, sizeof(spi_message));
spi_message[0].tx_buf = (unsigned long)p_txbuffer;
Expand All @@ -96,7 +96,7 @@ int SPI::write(uint8_t *p_txbuffer,uint8_t p_txlen){

}

int SPI::read(uint8_t *p_rxbuffer,uint8_t p_rxlen){
int SPI::read(uint8_t *p_rxbuffer, uint32_t p_rxlen){
struct spi_ioc_transfer spi_message[1];
memset(spi_message, 0, sizeof(spi_message));

Expand Down
6 changes: 3 additions & 3 deletions src/spidev_lib++.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ bool m_open;
~SPI();
bool begin();
bool end();
int read(uint8_t *p_rxbuffer,uint8_t p_rxlen);
int write(uint8_t *p_txbuffer,uint8_t p_txlen);
int xfer(uint8_t *p_txbuffer, uint8_t p_txlen, uint8_t *p_rxbuffer, uint8_t p_rxlen);
int read(uint8_t *p_rxbuffer, uint32_t p_rxlen);
int write(uint8_t *p_txbuffer, uint32_t p_txlen);
int xfer(uint8_t *p_txbuffer, uint32_t p_txlen, uint8_t *p_rxbuffer, uint32_t p_rxlen);
bool setSpeed(uint32_t p_speed);
bool setMode(uint8_t p_mode);
bool setBitPerWord(uint8_t p_bit);
Expand Down
6 changes: 3 additions & 3 deletions src/spidev_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int spi_close(int fd) {
return close(fd);
}

int spi_xfer(int fd, uint8_t *tx_buffer, uint8_t tx_len, uint8_t *rx_buffer, uint8_t rx_len){
int spi_xfer(int fd, uint8_t *tx_buffer, uint32_t tx_len, uint8_t *rx_buffer, uint32_t rx_len){
struct spi_ioc_transfer spi_message[1];
memset(spi_message, 0, sizeof(spi_message));

Expand All @@ -88,7 +88,7 @@ int spi_xfer(int fd, uint8_t *tx_buffer, uint8_t tx_len, uint8_t *rx_buffer, uin
return ioctl(fd, SPI_IOC_MESSAGE(1), spi_message);
}

int spi_read(int fd, uint8_t *rx_buffer, uint8_t rx_len){
int spi_read(int fd, uint8_t *rx_buffer, uint32_t rx_len){
struct spi_ioc_transfer spi_message[1];
memset(spi_message, 0, sizeof(spi_message));

Expand All @@ -99,7 +99,7 @@ int spi_read(int fd, uint8_t *rx_buffer, uint8_t rx_len){
return ioctl(fd, SPI_IOC_MESSAGE(1), spi_message);
}

int spi_write(int fd, uint8_t *tx_buffer, uint8_t tx_len){
int spi_write(int fd, uint8_t *tx_buffer, uint32_t tx_len){
struct spi_ioc_transfer spi_message[1];
memset(spi_message, 0, sizeof(spi_message));

Expand Down
6 changes: 3 additions & 3 deletions src/spidev_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ typedef struct {

int spi_open(char *device, spi_config_t config);
int spi_close(int fd);
int spi_xfer(int fd, uint8_t *tx_buffer, uint8_t tx_len, uint8_t *rx_buffer, uint8_t rx_len);
int spi_read(int fd, uint8_t *rx_buffer, uint8_t rx_len);
int spi_write(int fd, uint8_t *tx_buffer, uint8_t tx_len);
int spi_xfer(int fd, uint8_t *tx_buffer, uint32_t tx_len, uint8_t *rx_buffer, uint32_t rx_len);
int spi_read(int fd, uint8_t *rx_buffer, uint32_t rx_len);
int spi_write(int fd, uint8_t *tx_buffer, uint32_t tx_len);
#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 3ca3ba7

Please sign in to comment.