commit 261e3e9205d461842c8beff728efaf5d7aea9f83 Author: cfif Date: Wed Dec 4 13:10:48 2024 +0300 Init diff --git a/I2cPorts.c b/I2cPorts.c new file mode 100644 index 0000000..ffe12dd --- /dev/null +++ b/I2cPorts.c @@ -0,0 +1,41 @@ +// +// Created by xemon on 19.10.22. +// +#include +#include "I2cPorts.h" + +void I2cPorts_InitI2c3(tI2cPortNation *env) { + +// //Init I2c 3 +// //SCL +// InitGpioPinConfigOnly(GPIOC, GPIO_PIN_0, GPIO_Mode_AF_OD, GPIO_Speed_2MHz); +// //SDA +// InitGpioPinConfigOnly(GPIOC, GPIO_PIN_1, GPIO_Mode_AF_OD, GPIO_Speed_2MHz); + + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOC, ENABLE); + + GPIO_InitType GPIO_InitStructure; + + GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; + GPIO_InitPeripheral(GPIOC, &GPIO_InitStructure); + + //No remap +// GPIO_ConfigPinRemap(GPIO_RMP3_I2C3, ENABLE); + + vI2cPortNationInit7bit(env, I2C3, 400000); +} + +tI2cPorts I2C_PORTS; + +void I2cPorts_Init() { + tI2cPorts *env = &I2C_PORTS; + + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_AFIO, ENABLE); + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_I2C3, ENABLE); + + I2cPorts_InitI2c3(&env->max9860Port); + env->max9860Io = I2cPortNation_GetIO(&env->max9860Port); + +} \ No newline at end of file diff --git a/I2cPorts.h b/I2cPorts.h new file mode 100644 index 0000000..c15322a --- /dev/null +++ b/I2cPorts.h @@ -0,0 +1,20 @@ +// +// Created by xemon on 19.10.22. +// + +#ifndef UVEOS_ON_NATION_I2CPORTS_H +#define UVEOS_ON_NATION_I2CPORTS_H + +#include "I2cIO.h" +#include "I2cPortNation.h" + +typedef struct { + tI2cPortNation max9860Port; + tI2cIO max9860Io; +} tI2cPorts; + +extern tI2cPorts I2C_PORTS; + +void I2cPorts_Init(); + +#endif //UVEOS_ON_NATION_I2CPORTS_H diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..032a8aa --- /dev/null +++ b/modular.json @@ -0,0 +1,17 @@ +{ + "dep": [ + { + "type": "git", + "provider": "NAVIGATOR_UVEOS_NATION_TELIT", + "repo": "I2cPort_NATION_N32G45X" + } + ], + "cmake": { + "inc_dirs": [ + "./" + ], + "srcs": [ + "*.c" + ] + } +} \ No newline at end of file