I2C. Fixed indent style. All tabs changed to 2 spaces.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3071 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
fbeff97d92
commit
10153a4f30
|
@ -146,8 +146,7 @@ struct I2CSlaveConfig{
|
|||
i2cblock_t *rxbuf; /*!< Pointer to receive buffer. */
|
||||
i2cblock_t *txbuf; /*!< Pointer to transmit buffer.*/
|
||||
|
||||
/* Status Change @p EventSource.*/
|
||||
EventSource *sevent;
|
||||
EventSource *sevent; /*!< Status Change @p EventSource.*/
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -514,35 +514,35 @@ void i2c_lld_stop(I2CDriver *i2cp) {
|
|||
/**
|
||||
* @brief Transmits data ever the I2C bus as master.
|
||||
*
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
* @param[in] rxbytes number of bytes to be received
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
* @param[in] rxbytes number of bytes to be received
|
||||
*
|
||||
*/
|
||||
void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, size_t txbytes, size_t rxbytes) {
|
||||
i2cp->slave_addr = slave_addr;
|
||||
i2cp->txbytes = txbytes;
|
||||
i2cp->rxbytes = rxbytes;
|
||||
i2cp->slave_addr = slave_addr;
|
||||
i2cp->txbytes = txbytes;
|
||||
i2cp->rxbytes = rxbytes;
|
||||
|
||||
// enable ERR, EVT & BUF ITs
|
||||
i2cp->id_i2c->CR2 |= (I2C_CR2_ITERREN|I2C_CR2_ITEVTEN|I2C_CR2_ITBUFEN);
|
||||
i2cp->id_i2c->CR1 &= ~I2C_CR1_POS;
|
||||
|
||||
if(slave_addr & 0x8000){// 10-bit mode used
|
||||
// add the two msb of 10-bit address to the header
|
||||
i2cp->slave_addr1 = ((slave_addr >>7) & 0x0006);
|
||||
// add the header bits with LSB = 0 -> write
|
||||
i2cp->slave_addr1 |= 0xF0;
|
||||
// the remaining 8 bit of 10-bit address
|
||||
i2cp->slave_addr2 = slave_addr & 0x00FF;
|
||||
// add the two msb of 10-bit address to the header
|
||||
i2cp->slave_addr1 = ((slave_addr >>7) & 0x0006);
|
||||
// add the header bits with LSB = 0 -> write
|
||||
i2cp->slave_addr1 |= 0xF0;
|
||||
// the remaining 8 bit of 10-bit address
|
||||
i2cp->slave_addr2 = slave_addr & 0x00FF;
|
||||
}
|
||||
else{
|
||||
// LSB = 0 -> write
|
||||
i2cp->slave_addr1 = ((slave_addr <<1) & 0x00FE);
|
||||
// LSB = 0 -> write
|
||||
i2cp->slave_addr1 = ((slave_addr <<1) & 0x00FE);
|
||||
}
|
||||
|
||||
i2cp->flags = 0;
|
||||
|
@ -563,13 +563,13 @@ void i2c_lld_master_transmit(I2CDriver *i2cp, uint16_t slave_addr, size_t txbyte
|
|||
/**
|
||||
* @brief Receives data from the I2C bus.
|
||||
*
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
* @param[in] rxbytes number of bytes to be received
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
* @param[in] rxbytes number of bytes to be received
|
||||
*
|
||||
*/
|
||||
void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, size_t rxbytes){
|
||||
|
@ -582,12 +582,12 @@ void i2c_lld_master_receive(I2CDriver *i2cp, uint16_t slave_addr, size_t rxbytes
|
|||
i2cp->id_i2c->CR1 &= ~I2C_CR1_POS;
|
||||
|
||||
if(slave_addr & 0x8000){// 10-bit mode used
|
||||
// add the two msb of 10-bit address to the header
|
||||
i2cp->slave_addr1 = ((slave_addr >>7) & 0x0006);
|
||||
// add the header bits (the LSB -> 1 will be add to second
|
||||
i2cp->slave_addr1 |= 0xF0;
|
||||
// the remaining 8 bit of 10-bit address
|
||||
i2cp->slave_addr2 = slave_addr & 0x00FF;
|
||||
// add the two msb of 10-bit address to the header
|
||||
i2cp->slave_addr1 = ((slave_addr >>7) & 0x0006);
|
||||
// add the header bits (the LSB -> 1 will be add to second
|
||||
i2cp->slave_addr1 |= 0xF0;
|
||||
// the remaining 8 bit of 10-bit address
|
||||
i2cp->slave_addr2 = slave_addr & 0x00FF;
|
||||
}
|
||||
else{
|
||||
// LSB = 1 -> receive
|
||||
|
|
|
@ -163,17 +163,17 @@ struct I2CDriver{
|
|||
*/
|
||||
const I2CSlaveConfig *id_slave_config;
|
||||
|
||||
size_t txbytes; /*!< Number of bytes to be transmitted. */
|
||||
size_t rxbytes; /*!< Number of bytes to be received. */
|
||||
uint8_t *rxBuffp; /*!< Pointer to the current byte in slave rx buffer. */
|
||||
uint8_t *txBuffp; /*!< Pointer to the current byte in slave tx buffer. */
|
||||
size_t txbytes; /*!< Number of bytes to be transmitted. */
|
||||
size_t rxbytes; /*!< Number of bytes to be received. */
|
||||
uint8_t *rxBuffp; /*!< Pointer to the current byte in slave rx buffer. */
|
||||
uint8_t *txBuffp; /*!< Pointer to the current byte in slave tx buffer. */
|
||||
|
||||
i2cflags_t errors; /*!< Error flags.*/
|
||||
i2cflags_t flags; /*!< State flags.*/
|
||||
i2cflags_t errors; /*!< Error flags.*/
|
||||
i2cflags_t flags; /*!< State flags.*/
|
||||
|
||||
uint16_t slave_addr; /*!< Current slave address. */
|
||||
uint8_t slave_addr1; /*!< 7-bit address of the slave with r\w bit.*/
|
||||
uint8_t slave_addr2; /*!< Used in 10-bit address mode. */
|
||||
uint16_t slave_addr; /*!< Current slave address. */
|
||||
uint8_t slave_addr1;/*!< 7-bit address of the slave with r\w bit.*/
|
||||
uint8_t slave_addr2;/*!< Used in 10-bit address mode. */
|
||||
|
||||
/*********** End of the mandatory fields. **********************************/
|
||||
|
||||
|
|
|
@ -135,14 +135,14 @@ void i2cStop(I2CDriver *i2cp) {
|
|||
/**
|
||||
* @brief Sends data ever the I2C bus.
|
||||
*
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] i2cscfg pointer to the @p I2C slave config
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
* @param[in] rxbytes number of bytes to be received
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] i2cscfg pointer to the @p I2C slave config
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
* @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) {
|
||||
|
||||
|
@ -183,13 +183,13 @@ void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t
|
|||
/**
|
||||
* @brief Receives data from the I2C bus.
|
||||
*
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] i2cscfg pointer to the @p I2C slave config
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
* @param[in] i2cp pointer to the @p I2CDriver object
|
||||
* @param[in] i2cscfg pointer to the @p I2C slave config
|
||||
* @param[in] slave_addr Slave device address. Bits 0-9 contain slave
|
||||
* device address. Bit 15 must be set to 1 if 10-bit
|
||||
* addressing modes used. Otherwise keep it cleared.
|
||||
* Bits 10-14 unused.
|
||||
* @param[in] txbytes number of bytes to be transmited
|
||||
*/
|
||||
void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg, uint16_t slave_addr, size_t rxbytes){
|
||||
|
||||
|
@ -251,7 +251,7 @@ void i2cAddFlagsI(I2CDriver *i2cp, i2cflags_t mask) {
|
|||
chDbgCheck(i2cp != NULL, "i2cAddFlagsI");
|
||||
|
||||
i2cp->errors |= mask;
|
||||
chEvtBroadcastI(&i2cp->id_slave_config->sevent);
|
||||
chEvtBroadcastI(&i2cp->sevent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue