2011-04-01 18:23:35 +00:00
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
|
|
|
|
|
|
|
#include "i2c_pns.h"
|
|
|
|
|
|
|
|
#include "lis3.h"
|
|
|
|
|
|
|
|
/* I2C1 */
|
2011-06-18 13:35:26 +00:00
|
|
|
static const I2CConfig i2cfg1 = {
|
2011-06-18 11:12:33 +00:00
|
|
|
OPMODE_I2C,
|
2011-12-06 13:38:47 +00:00
|
|
|
400000,
|
|
|
|
FAST_DUTY_CYCLE_16_9,
|
2011-04-01 18:23:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void I2CInit_pns(void){
|
|
|
|
i2cInit();
|
|
|
|
|
|
|
|
i2cStart(&I2CD1, &i2cfg1);
|
|
|
|
|
|
|
|
/* tune ports for I2C1*/
|
|
|
|
palSetPadMode(IOPORT2, 6, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
|
|
|
|
palSetPadMode(IOPORT2, 7, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
|
|
|
|
|
|
|
|
/* startups. Pauses added just to be safe */
|
2011-12-06 09:09:53 +00:00
|
|
|
chThdSleepMilliseconds(100);
|
2011-04-01 18:23:35 +00:00
|
|
|
init_lis3();
|
|
|
|
}
|
|
|
|
|
|
|
|
|