add constant to i2c functions

This commit is contained in:
Zaltora 2017-02-14 07:53:00 +01:00
parent 79a0b2d6b6
commit c6f10147ca
2 changed files with 6 additions and 6 deletions

View file

@ -238,7 +238,6 @@ void i2c_force_bus(bool state)
force = state ; force = state ;
} }
static int i2c_bus_test() static int i2c_bus_test()
{ {
taskENTER_CRITICAL(); // To prevent task swaping after checking flag and before set it! taskENTER_CRITICAL(); // To prevent task swaping after checking flag and before set it!
@ -268,7 +267,7 @@ static int i2c_bus_test()
return 0 ; return 0 ;
} }
int i2c_slave_write(uint8_t slave_addr, uint8_t *data, uint8_t *buf, uint32_t len) int i2c_slave_write(uint8_t slave_addr, const uint8_t *data, const uint8_t *buf, uint32_t len)
{ {
if(i2c_bus_test()) if(i2c_bus_test())
return -EBUSY ; return -EBUSY ;
@ -294,7 +293,7 @@ int i2c_slave_write(uint8_t slave_addr, uint8_t *data, uint8_t *buf, uint32_t le
return -EIO; return -EIO;
} }
int i2c_slave_read(uint8_t slave_addr, uint8_t *data, uint8_t *buf, uint32_t len) int i2c_slave_read(uint8_t slave_addr, const uint8_t *data, uint8_t *buf, uint32_t len)
{ {
if(i2c_bus_test()) if(i2c_bus_test())
return -EBUSY ; return -EBUSY ;

View file

@ -103,7 +103,8 @@ bool i2c_status(void);
//Level 1 API (Don't need functions above) //Level 1 API (Don't need functions above)
/** /**
* This function will allow you to force a transmission I2C, canceled the current one. * This function will allow you to force a transmission I2C, cancel current transmission.
* Warning: Use with precaution. Don't use it if you can avoid it. Usefull for priority transmission.
* @param state Force the next I2C transmission if true (Use with precaution) * @param state Force the next I2C transmission if true (Use with precaution)
*/ */
void i2c_force_bus(bool state); void i2c_force_bus(bool state);
@ -116,7 +117,7 @@ void i2c_force_bus(bool state);
* @param len Number of byte to send * @param len Number of byte to send
* @return Non-Zero if error occured * @return Non-Zero if error occured
*/ */
int i2c_slave_write(uint8_t slave_addr, uint8_t *data, uint8_t *buf, uint32_t len); int i2c_slave_write(uint8_t slave_addr, const uint8_t *data, const uint8_t *buf, uint32_t len);
/** /**
* Issue a send operation of 'data' register adress, followed by reading 'len' bytes * Issue a send operation of 'data' register adress, followed by reading 'len' bytes
@ -127,7 +128,7 @@ int i2c_slave_write(uint8_t slave_addr, uint8_t *data, uint8_t *buf, uint32_t le
* @param len Number of byte to read * @param len Number of byte to read
* @return Non-Zero if error occured * @return Non-Zero if error occured
*/ */
int i2c_slave_read(uint8_t slave_addr, uint8_t *data, uint8_t *buf, uint32_t len); int i2c_slave_read(uint8_t slave_addr, const uint8_t *data, uint8_t *buf, uint32_t len);
#ifdef __cplusplus #ifdef __cplusplus
} }