Init
This commit is contained in:
commit
3c3e55cb0a
|
|
@ -0,0 +1,77 @@
|
||||||
|
//
|
||||||
|
// Created by ilya on 25.03.24.
|
||||||
|
//
|
||||||
|
#include <GpioPin.h>
|
||||||
|
#include "I2cPorts.h"
|
||||||
|
tI2cPorts I2C_PORTS;
|
||||||
|
|
||||||
|
void vI2cPorts_InitI2c3(tI2cPortArtery *env) {
|
||||||
|
gpio_init_type GPIO_InitStruct;
|
||||||
|
|
||||||
|
/* i2c periph clock enable */
|
||||||
|
crm_periph_clock_enable(CRM_I2C3_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable( CRM_GPIOC_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
|
/* gpio configuration */
|
||||||
|
GPIO_InitStruct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||||
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
||||||
|
GPIO_InitStruct.gpio_mode = GPIO_MODE_MUX;
|
||||||
|
GPIO_InitStruct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
||||||
|
|
||||||
|
/* configure i2c pins: scl */
|
||||||
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_0;
|
||||||
|
gpio_init(GPIOC,&GPIO_InitStruct);
|
||||||
|
gpio_pin_mux_config(GPIOC, GPIO_PINS_SOURCE0, GPIO_MUX_4);
|
||||||
|
|
||||||
|
|
||||||
|
/* configure i2c pins: sda */
|
||||||
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_1;
|
||||||
|
gpio_init(GPIOC,&GPIO_InitStruct);
|
||||||
|
gpio_pin_mux_config(GPIOC, GPIO_PINS_SOURCE1, GPIO_MUX_4);
|
||||||
|
|
||||||
|
|
||||||
|
I2cPortArtery_Init7bit(env,I2C3,I2C_SPEED_1KHz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vI2cPorts_InitI2c2(tI2cPortArtery *env) {
|
||||||
|
gpio_init_type GPIO_InitStruct;
|
||||||
|
|
||||||
|
/* i2c periph clock enable */
|
||||||
|
crm_periph_clock_enable(CRM_I2C2_PERIPH_CLOCK, TRUE);
|
||||||
|
crm_periph_clock_enable( CRM_GPIOA_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
|
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE1, GPIO_MUX_4);
|
||||||
|
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE0, GPIO_MUX_4);
|
||||||
|
|
||||||
|
|
||||||
|
/* gpio configuration */
|
||||||
|
GPIO_InitStruct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||||
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
||||||
|
GPIO_InitStruct.gpio_mode = GPIO_MODE_MUX;
|
||||||
|
GPIO_InitStruct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
||||||
|
|
||||||
|
|
||||||
|
/* configure i2c pins: scl */
|
||||||
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_0;
|
||||||
|
gpio_init(GPIOA,&GPIO_InitStruct);
|
||||||
|
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE0, GPIO_MUX_4);
|
||||||
|
|
||||||
|
|
||||||
|
/* configure i2c pins: sda */
|
||||||
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_1;
|
||||||
|
gpio_init(GPIOA,&GPIO_InitStruct);
|
||||||
|
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE1, GPIO_MUX_4);
|
||||||
|
|
||||||
|
|
||||||
|
I2cPortArtery_Init7bit(env,I2C2,0x80504C4E);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void I2cPorts_Init() {
|
||||||
|
vI2cPorts_InitI2c3(&I2C_PORTS.codecI2c3);
|
||||||
|
I2C_PORTS.codecI2c3_IO = I2cPortArtery_GetIO(&I2C_PORTS.codecI2c3);
|
||||||
|
|
||||||
|
vI2cPorts_InitI2c2(&I2C_PORTS.amplI2c2);
|
||||||
|
I2C_PORTS.amplI2c2_IO = I2cPortArtery_GetIO(&I2C_PORTS.amplI2c2);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// Created by ilya on 25.03.24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SMART_COMPONENTS_I2CPORTS_H
|
||||||
|
#define SMART_COMPONENTS_I2CPORTS_H
|
||||||
|
|
||||||
|
#include "I2cPortArtery.h"
|
||||||
|
#include "I2cIO.h"
|
||||||
|
|
||||||
|
#define I2C_SPEED_10KHz 0x8170F7F7
|
||||||
|
#define I2C_SPEED_1KHz 0x4F20FFFF
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tI2cPortArtery codecI2c3;
|
||||||
|
tI2cIO codecI2c3_IO;
|
||||||
|
|
||||||
|
tI2cPortArtery amplI2c2;
|
||||||
|
tI2cIO amplI2c2_IO;
|
||||||
|
} tI2cPorts;
|
||||||
|
|
||||||
|
void I2cPorts_Init();
|
||||||
|
|
||||||
|
extern tI2cPorts I2C_PORTS;
|
||||||
|
#endif //SMART_COMPONENTS_I2CPORTS_H
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"dep": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"provider": "Smart_Components_Aurus",
|
||||||
|
"repo": "I2cPort_ARTERY_At32f435_437_v2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cmake": {
|
||||||
|
"inc_dirs": [
|
||||||
|
"./"
|
||||||
|
],
|
||||||
|
"srcs": [
|
||||||
|
"./**.c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue