mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-07-10 13:29:52 -04:00
echoplayer: initialize I2C bus
Change-Id: I159d1a2c97b02b5e7aa61452098b05d9d854dc89
This commit is contained in:
parent
9c5017ea98
commit
4af1768795
6 changed files with 89 additions and 5 deletions
|
|
@ -1953,6 +1953,7 @@ target/arm/stm32/echoplayer/audiohw-echoplayer.c
|
|||
target/arm/stm32/echoplayer/backlight-echoplayer.c
|
||||
target/arm/stm32/echoplayer/button-echoplayer.c
|
||||
target/arm/stm32/echoplayer/clock-echoplayer.c
|
||||
target/arm/stm32/echoplayer/i2c-echoplayer.c
|
||||
target/arm/stm32/echoplayer/lcd-echoplayer.c
|
||||
target/arm/stm32/echoplayer/power-echoplayer.c
|
||||
target/arm/stm32/echoplayer/sdmmc-echoplayer.c
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ INIT_ATTR static void init_periph_clock(void)
|
|||
{
|
||||
reg_writef(RCC_D1CCIPR, SDMMCSEL_V(PLL1Q));
|
||||
reg_writef(RCC_D2CCIP1R, SPI45SEL_V(HSE));
|
||||
reg_writef(RCC_D2CCIP2R, I2C123SEL_V(HSI));
|
||||
|
||||
/* Enable AXI SRAM in sleep mode to allow DMA'ing out of it */
|
||||
reg_writef(RCC_AHB3LPENR, AXISRAMEN(1));
|
||||
|
|
@ -203,3 +204,11 @@ const struct stm32_clock spi5_ker_clock = {
|
|||
.lpen_reg = ITA_RCC_APB2LPENR,
|
||||
.lpen_bit = BM_RCC_APB2ENR_SPI5EN,
|
||||
};
|
||||
|
||||
const struct stm32_clock i2c1_ker_clock = {
|
||||
.frequency = STM32_HSI_FREQ,
|
||||
.en_reg = ITA_RCC_APB1LENR,
|
||||
.en_bit = BM_RCC_APB1LENR_I2C1EN,
|
||||
.lpen_reg = ITA_RCC_APB1LLPENR,
|
||||
.lpen_bit = BM_RCC_APB1LENR_I2C1EN,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,5 +28,6 @@ void echoplayer_clock_init(void) INIT_ATTR;
|
|||
extern struct stm32_clock sdmmc1_ker_clock;
|
||||
extern struct stm32_clock ltdc_ker_clock;
|
||||
extern struct stm32_clock spi5_ker_clock;
|
||||
extern struct stm32_clock i2c1_ker_clock;
|
||||
|
||||
#endif /* __CLOCK_ECHOPLAYER_H__ */
|
||||
|
|
|
|||
50
firmware/target/arm/stm32/echoplayer/i2c-echoplayer.c
Normal file
50
firmware/target/arm/stm32/echoplayer/i2c-echoplayer.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2026 by Aidan MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "i2c-stm32h7.h"
|
||||
#include "clock-echoplayer.h"
|
||||
#include "nvic-arm.h"
|
||||
#include "regs/stm32h743/i2c.h"
|
||||
|
||||
static const struct stm32_i2c_config i2c1_conf INITDATA_ATTR = {
|
||||
.instance = ITA_I2C1,
|
||||
.ker_clock = &i2c1_ker_clock,
|
||||
.bus_freq_hz = 400000,
|
||||
.scl_low_min_ns = 1300,
|
||||
.scl_high_min_ns = 600,
|
||||
.t_vd_dat_max_ns = 900,
|
||||
.t_su_dat_max_ns = 100,
|
||||
.rise_time_max_ns = 300,
|
||||
.fall_time_max_ns = 300,
|
||||
};
|
||||
|
||||
struct stm32_i2c_controller i2c1_ctl;
|
||||
|
||||
void i2c_init(void)
|
||||
{
|
||||
stm32_i2c_init(&i2c1_ctl, &i2c1_conf);
|
||||
nvic_enable_irq(NVIC_IRQN_I2C1_EV);
|
||||
nvic_enable_irq(NVIC_IRQN_I2C1_ER);
|
||||
}
|
||||
|
||||
void i2c1_irq_handler(void)
|
||||
{
|
||||
stm32_i2c_irq_handler(&i2c1_ctl);
|
||||
}
|
||||
28
firmware/target/arm/stm32/echoplayer/i2c-echoplayer.h
Normal file
28
firmware/target/arm/stm32/echoplayer/i2c-echoplayer.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2026 by Aidan MacDonald
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __I2C_ECHOPLAYER_H__
|
||||
#define __I2C_ECHOPLAYER_H__
|
||||
|
||||
#include "i2c-stm32h7.h"
|
||||
|
||||
extern struct stm32_i2c_controller i2c1_ctl;
|
||||
|
||||
#endif /* __I2C_ECHOPLAYER_H__ */
|
||||
|
|
@ -306,8 +306,3 @@ void stm32_i2c_irq_handler(struct stm32_i2c_controller *ctl)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: move to target */
|
||||
void i2c_init(void)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue