aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32F1xx/I2C/i2c_pns.c
blob: 95218b58384b1eb5be3ffd3e9ff8b5b0ce7b0b5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "ch.h"
#include "hal.h"

#include "i2c_pns.h"

#include "lis3.h"

/* I2C1 */
static const I2CConfig i2cfg1 = {
    OPMODE_I2C,
    400000,
    FAST_DUTY_CYCLE_16_9,
};



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 */
  chThdSleepMilliseconds(100);
  init_lis3();
}