I2C. Some coding style improvements.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3074 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
97e643a2a2
commit
b1d043cede
|
@ -115,7 +115,8 @@ typedef void (*i2ccallback_t)(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg);
|
||||||
* @param[in] i2cscfg pointer to the @p I2CSlaveConfig object triggering the
|
* @param[in] i2cscfg pointer to the @p I2CSlaveConfig object triggering the
|
||||||
* callback
|
* callback
|
||||||
*/
|
*/
|
||||||
typedef void (*i2cerrorcallback_t)(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg);
|
typedef void (*i2cerrorcallback_t)(I2CDriver *i2cp,
|
||||||
|
const I2CSlaveConfig *i2cscfg);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,8 +228,10 @@ extern "C" {
|
||||||
void i2cObjectInit(I2CDriver *i2cp);
|
void i2cObjectInit(I2CDriver *i2cp);
|
||||||
void i2cStart(I2CDriver *i2cp, const I2CConfig *config);
|
void i2cStart(I2CDriver *i2cp, const I2CConfig *config);
|
||||||
void i2cStop(I2CDriver *i2cp);
|
void i2cStop(I2CDriver *i2cp);
|
||||||
void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t txbytes, size_t rxbytes);
|
void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg,
|
||||||
void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t rxbytes);
|
uint16_t slave_addr, size_t txbytes, size_t rxbytes);
|
||||||
|
void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg,
|
||||||
|
uint16_t slave_addr, size_t rxbytes);
|
||||||
void i2cMasterStart(I2CDriver *i2cp);
|
void i2cMasterStart(I2CDriver *i2cp);
|
||||||
void i2cMasterStop(I2CDriver *i2cp);
|
void i2cMasterStop(I2CDriver *i2cp);
|
||||||
void i2cAddFlagsI(I2CDriver *i2cp, i2cflags_t mask);
|
void i2cAddFlagsI(I2CDriver *i2cp, i2cflags_t mask);
|
||||||
|
|
|
@ -42,8 +42,8 @@ static uint32_t i2c_get_event(I2CDriver *i2cp){
|
||||||
}
|
}
|
||||||
|
|
||||||
static void i2c_serve_event_interrupt(I2CDriver *i2cp) {
|
static void i2c_serve_event_interrupt(I2CDriver *i2cp) {
|
||||||
#define txBuffp (i2cp->txBuffp)
|
#define txBuffp (i2cp->txbuff_p)
|
||||||
#define rxBuffp (i2cp->rxBuffp)
|
#define rxBuffp (i2cp->rxbuff_p)
|
||||||
|
|
||||||
I2C_TypeDef *dp = i2cp->id_i2c;
|
I2C_TypeDef *dp = i2cp->id_i2c;
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,8 @@ struct I2CDriver{
|
||||||
|
|
||||||
size_t txbytes; /*!< Number of bytes to be transmitted. */
|
size_t txbytes; /*!< Number of bytes to be transmitted. */
|
||||||
size_t rxbytes; /*!< Number of bytes to be received. */
|
size_t rxbytes; /*!< Number of bytes to be received. */
|
||||||
uint8_t *rxBuffp; /*!< Pointer to the current byte in slave rx buffer. */
|
uint8_t *rxbuff_p; /*!< Pointer to the current byte in slave rx buffer. */
|
||||||
uint8_t *txBuffp; /*!< Pointer to the current byte in slave tx buffer. */
|
uint8_t *txbuff_p; /*!< Pointer to the current byte in slave tx buffer. */
|
||||||
|
|
||||||
i2cflags_t errors; /*!< Error flags.*/
|
i2cflags_t errors; /*!< Error flags.*/
|
||||||
i2cflags_t flags; /*!< State flags.*/
|
i2cflags_t flags; /*!< State flags.*/
|
||||||
|
@ -227,8 +227,10 @@ void i2c_lld_set_opmode(I2CDriver *i2cp);
|
||||||
void i2c_lld_set_own_address(I2CDriver *i2cp);
|
void i2c_lld_set_own_address(I2CDriver *i2cp);
|
||||||
void i2c_lld_start(I2CDriver *i2cp);
|
void i2c_lld_start(I2CDriver *i2cp);
|
||||||
void i2c_lld_stop(I2CDriver *i2cp);
|
void i2c_lld_stop(I2CDriver *i2cp);
|
||||||
void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, size_t txbytes, size_t rxbytes);
|
void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr,
|
||||||
void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, size_t rxbytes);
|
size_t txbytes, size_t rxbytes);
|
||||||
|
void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr,
|
||||||
|
size_t rxbytes);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,8 @@ void i2cObjectInit(I2CDriver *i2cp) {
|
||||||
|
|
||||||
i2cp->id_state = I2C_STOP;
|
i2cp->id_state = I2C_STOP;
|
||||||
i2cp->id_config = NULL;
|
i2cp->id_config = NULL;
|
||||||
i2cp->rxBuffp = NULL;
|
i2cp->rxbuff_p = NULL;
|
||||||
i2cp->txBuffp = NULL;
|
i2cp->txbuff_p = NULL;
|
||||||
i2cp->id_slave_config = NULL;
|
i2cp->id_slave_config = NULL;
|
||||||
|
|
||||||
#if I2C_USE_WAIT
|
#if I2C_USE_WAIT
|
||||||
|
@ -144,7 +144,11 @@ void i2cStop(I2CDriver *i2cp) {
|
||||||
* @param[in] txbytes number of bytes to be transmited
|
* @param[in] txbytes number of bytes to be transmited
|
||||||
* @param[in] rxbytes number of bytes to be received
|
* @param[in] rxbytes number of bytes to be received
|
||||||
*/
|
*/
|
||||||
void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t txbytes, size_t rxbytes) {
|
void i2cMasterTransmit(I2CDriver *i2cp,
|
||||||
|
const I2CSlaveConfig *i2cscfg,
|
||||||
|
uint16_t slave_addr,
|
||||||
|
size_t txbytes,
|
||||||
|
size_t rxbytes) {
|
||||||
|
|
||||||
chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\
|
chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\
|
||||||
(slave_addr != 0) &&\
|
(slave_addr != 0) &&\
|
||||||
|
@ -191,7 +195,10 @@ void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t
|
||||||
* Bits 10-14 unused.
|
* Bits 10-14 unused.
|
||||||
* @param[in] txbytes number of bytes to be transmited
|
* @param[in] txbytes number of bytes to be transmited
|
||||||
*/
|
*/
|
||||||
void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t rxbytes){
|
void i2cMasterReceive(I2CDriver *i2cp,
|
||||||
|
const I2CSlaveConfig *i2cscfg,
|
||||||
|
uint16_t slave_addr,
|
||||||
|
size_t rxbytes){
|
||||||
|
|
||||||
chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\
|
chDbgCheck((i2cp != NULL) && (i2cscfg != NULL) &&\
|
||||||
(slave_addr != 0) &&\
|
(slave_addr != 0) &&\
|
||||||
|
|
Loading…
Reference in New Issue