I2C. Alberto's clock setting code tested. Minor changes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@2721 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
918ff6d6b6
commit
eddd171ec8
|
@ -225,14 +225,11 @@ void i2c_lld_start(I2CDriver *i2cp) {
|
||||||
i2cp->id_i2c->CR1 = 0;
|
i2cp->id_i2c->CR1 = 0;
|
||||||
|
|
||||||
i2c_lld_set_clock(i2cp);
|
i2c_lld_set_clock(i2cp);
|
||||||
|
i2cp->id_i2c->CR2 |= I2C_CR2_ITERREN | I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN;
|
||||||
i2cp->id_i2c->CR1 |= 1; // enable interface
|
i2cp->id_i2c->CR1 |= 1; // enable interface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: dox here
|
||||||
|
|
||||||
// int32_t clock_speed, I2C_DutyCycle_t duty
|
|
||||||
|
|
||||||
void i2c_lld_set_clock(I2CDriver *i2cp) {
|
void i2c_lld_set_clock(I2CDriver *i2cp) {
|
||||||
volatile uint16_t regCCR, regCR2, freq, clock_div;
|
volatile uint16_t regCCR, regCR2, freq, clock_div;
|
||||||
volatile uint16_t pe_bit_saved;
|
volatile uint16_t pe_bit_saved;
|
||||||
|
@ -403,8 +400,7 @@ void i2c_lld_master_start(I2CDriver *i2cp){
|
||||||
while (i2cp->id_i2c->CR1 & I2C_CR1_START);
|
while (i2cp->id_i2c->CR1 & I2C_CR1_START);
|
||||||
|
|
||||||
// enable interrupts
|
// enable interrupts
|
||||||
i2cp->id_i2c->CR2 |= I2C_CR2_ITEVTEN;
|
i2cp->id_i2c->CR2 |= I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN;
|
||||||
i2cp->id_i2c->CR2 |= I2C_CR2_ITBUFEN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2c_lld_master_stop(I2CDriver *i2cp){
|
void i2c_lld_master_stop(I2CDriver *i2cp){
|
||||||
|
|
Loading…
Reference in New Issue