From 59ef83a4406b0cbd5e61aaf6af383c31656c0a1d Mon Sep 17 00:00:00 2001 From: Sergey Matyukevich Date: Thu, 1 Dec 2016 22:59:19 +0300 Subject: [PATCH] stm32: l0/l4: add i2c support According to reference manuals both l0 and l4 have "v2" i2c peripheral. This patch adds i2c support to l0 and l4 using previously unified "v2" i2c headers and implementation. No real hardware has been tested so far. Only compilation tests for both libopencm3 and libopencm3-examples for all stm32 families. Signed-off-by: Sergey Matyukevich --- include/libopencm3/stm32/l0/i2c.h | 37 ++++++++++++++++++++++++++ include/libopencm3/stm32/l4/i2c.h | 43 +++++++++++++++++++++++++++++++ lib/stm32/l0/Makefile | 1 + lib/stm32/l0/i2c.c | 32 +++++++++++++++++++++++ lib/stm32/l4/Makefile | 1 + lib/stm32/l4/i2c.c | 32 +++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 include/libopencm3/stm32/l0/i2c.h create mode 100644 include/libopencm3/stm32/l4/i2c.h create mode 100644 lib/stm32/l0/i2c.c create mode 100644 lib/stm32/l4/i2c.c diff --git a/include/libopencm3/stm32/l0/i2c.h b/include/libopencm3/stm32/l0/i2c.h new file mode 100644 index 00000000..f2bf276d --- /dev/null +++ b/include/libopencm3/stm32/l0/i2c.h @@ -0,0 +1,37 @@ +/** @defgroup i2c_defines I2C Defines + +@brief Defined Constants and Types for the STM32L0xx I2C + +@ingroup STM32L0xx_defines + +@version 1.0.0 + +@date 1 December 2016 + +LGPL License Terms @ref lgpl_license + */ + +/* + * This file is part of the libopencm3 project. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + */ + +#ifndef LIBOPENCM3_I2C_H +#define LIBOPENCM3_I2C_H + +#include + +#endif + diff --git a/include/libopencm3/stm32/l4/i2c.h b/include/libopencm3/stm32/l4/i2c.h new file mode 100644 index 00000000..27a0f362 --- /dev/null +++ b/include/libopencm3/stm32/l4/i2c.h @@ -0,0 +1,43 @@ +/** @defgroup i2c_defines I2C Defines + +@brief Defined Constants and Types for the STM32L4xx I2C + +@ingroup STM32L4xx_defines + +@version 1.0.0 + +@date 12 October 2012 + +LGPL License Terms @ref lgpl_license + */ + +/* + * This file is part of the libopencm3 project. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + */ + +#ifndef LIBOPENCM3_I2C_H +#define LIBOPENCM3_I2C_H + +#include + +/**@{*/ + +#define I2C3 I2C3_BASE + +/**@}*/ + +#endif + diff --git a/lib/stm32/l0/Makefile b/lib/stm32/l0/Makefile index c43630af..82838ad8 100644 --- a/lib/stm32/l0/Makefile +++ b/lib/stm32/l0/Makefile @@ -43,6 +43,7 @@ OBJS += gpio_common_all.o gpio_common_f0234.o rcc_common_all.o OBJS += adc_common_v2.o OBJS += crs_common_all.o OBJS += exti_common_all.o +OBJS += i2c_common_v2.o OBJS += rng_common_v1.o OBJS += usb.o usb_control.o usb_standard.o diff --git a/lib/stm32/l0/i2c.c b/lib/stm32/l0/i2c.c new file mode 100644 index 00000000..0880f4d0 --- /dev/null +++ b/lib/stm32/l0/i2c.c @@ -0,0 +1,32 @@ +/** @defgroup i2c_file I2C + * + * @ingroup STM32L0xx + * + * @brief libopencm3 STM32L0xx I2C + * + * @version 1.0.0 + * + * @date 1 December 2016 + * + * LGPL License Terms @ref lgpl_license + */ + +/* + * This file is part of the libopencm3 project. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + */ + +#include + diff --git a/lib/stm32/l4/Makefile b/lib/stm32/l4/Makefile index daae491b..9ab3b557 100644 --- a/lib/stm32/l4/Makefile +++ b/lib/stm32/l4/Makefile @@ -45,6 +45,7 @@ OBJS += gpio_common_all.o gpio_common_f0234.o OBJS += adc_common_v2.o adc_common_v2_multi.o OBJS += rng_common_v1.o OBJS += timer_common_all.o +OBJS += i2c_common_v2.o VPATH += ../../usb:../:../../cm3:../common VPATH += ../../ethernet diff --git a/lib/stm32/l4/i2c.c b/lib/stm32/l4/i2c.c new file mode 100644 index 00000000..40df10ca --- /dev/null +++ b/lib/stm32/l4/i2c.c @@ -0,0 +1,32 @@ +/** @defgroup i2c_file I2C + * + * @ingroup STM32L4xx + * + * @brief libopencm3 STM32L4xx I2C + * + * @version 1.0.0 + * + * @date 1 December 2016 + * + * LGPL License Terms @ref lgpl_license + */ + +/* + * This file is part of the libopencm3 project. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + */ + +#include +