From 65301e5a0b382585887ea7b13e4eb9b0cb26c60f Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Tue, 21 Feb 2017 23:11:43 +0000 Subject: i2c-master: start progressing to extracting common i2c code --- tests/i2c-master/i2c-master.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/i2c-master/i2c-master.c (limited to 'tests/i2c-master/i2c-master.c') diff --git a/tests/i2c-master/i2c-master.c b/tests/i2c-master/i2c-master.c new file mode 100644 index 0000000..64c9cfe --- /dev/null +++ b/tests/i2c-master/i2c-master.c @@ -0,0 +1,23 @@ +/* + * Feb 2017, Karl Palsson + */ + +#include +#include +#include "hw.h" +#include "i2c-master.h" + + +void i2cm_init(void) { + rcc_periph_clock_enable(hw_details.periph_rcc); + rcc_periph_reset_pulse(hw_details.periph_rst); + i2c_set_standard_mode(hw_details.periph); + i2c_enable_ack(hw_details.periph); + //i2c_set_dutycycle(hw_details.periph, I2C_CCR_DUTY_DIV2); /* default, no need to do this really */ + i2c_set_clock_frequency(hw_details.periph, I2C_CR2_FREQ_42MHZ); + /* 42MHz / (100kHz * 2) */ + i2c_set_ccr(hw_details.periph, 210); + /* standard mode, freqMhz+1*/ + i2c_set_trise(hw_details.periph, 43); + i2c_peripheral_enable(hw_details.periph); +} \ No newline at end of file -- cgit