i2c: allow binary strings as parameters to write() functions in scripting
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -95,8 +95,8 @@ class I2c {
|
||||
* @param length Size of read
|
||||
* @return length of the read or 0 if failed
|
||||
*/
|
||||
int read(unsigned char * data, int length) {
|
||||
return mraa_i2c_read(m_i2c, data, length);
|
||||
int read(char * data, size_t length) {
|
||||
return mraa_i2c_read(m_i2c, (uint8_t*) data, (int) length);
|
||||
}
|
||||
/**
|
||||
* Write one byte to the bus
|
||||
@@ -105,8 +105,8 @@ class I2c {
|
||||
* @param length Size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(const unsigned char* data, int length) {
|
||||
return mraa_i2c_write(m_i2c, data, length);
|
||||
mraa_result_t write(char* data, size_t length) {
|
||||
return mraa_i2c_write(m_i2c, (const unsigned char *)data, (int) length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +116,8 @@ class I2c {
|
||||
* @param data Value to write to register
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t writeReg(const unsigned char reg, const unsigned char data) {
|
||||
const unsigned char buf[2] = {reg, data};
|
||||
mraa_result_t writeReg(char reg, char data) {
|
||||
const unsigned char buf[2] = {(unsigned char) reg, (unsigned char) data};
|
||||
return mraa_i2c_write(m_i2c, buf, 2);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class I2c {
|
||||
* @param data The byte to send on the bus
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(const unsigned char data) {
|
||||
mraa_result_t write(char data) {
|
||||
return mraa_i2c_write_byte(m_i2c, data);
|
||||
}
|
||||
private:
|
||||
|
||||
@@ -75,8 +75,8 @@ class Spi {
|
||||
* @param data the byte to send
|
||||
* @return data received on the miso line
|
||||
*/
|
||||
unsigned char write(uint8_t data) {
|
||||
return (unsigned char) mraa_spi_write(m_spi, data);
|
||||
unsigned char write(char data) {
|
||||
return (unsigned char) mraa_spi_write(m_spi, (uint8_t) data);
|
||||
}
|
||||
/**
|
||||
* Write buffer of bytes to SPI device
|
||||
@@ -85,8 +85,8 @@ class Spi {
|
||||
* @param length size of buffer to send
|
||||
* @return char* data received on the miso line. Same length as passed in
|
||||
*/
|
||||
unsigned char* write(uint8_t* data, int length) {
|
||||
return (unsigned char*) mraa_spi_write_buf(m_spi, data, length);
|
||||
unsigned char* write(char* data, size_t length) {
|
||||
return (unsigned char*) mraa_spi_write_buf(m_spi, (uint8_t *) data, (int) length);
|
||||
}
|
||||
/**
|
||||
* Change the SPI lsb mode
|
||||
|
||||
Reference in New Issue
Block a user