//-----------------------------------------------------------------------------
// \file evmomapl138.c
// \brief implementation of initialization functions for OMAP-L138.
//
//-----------------------------------------------------------------------------
#include "types.h"
#include "evmomapl138.h"
#include "evmomapl138_ddr.h"
#include "evmomapl138_i2c_gpio.h"
#ifdef DEBUG
#include "stdio.h"
#endif
//-----------------------------------------------------------------------------
// Private Defines and Macros
//-----------------------------------------------------------------------------
#define PINMUX_GPIO_UI_IO_EXP_REG (6)
#define PINMUX_GPIO_UI_IO_EXP_MASK (0x0000000F)
#define PINMUX_GPIO_UI_IO_EXP_VAL (0x00000008)
#define GPIO_UI_IO_EXP_BANK (2)
#define GPIO_UI_IO_EXP_PIN (7)
//-----------------------------------------------------------------------------
// Global Variable Initializations
//-----------------------------------------------------------------------------
const uint32_t bitval_u32[32] =
{
0x00000001, 0x00000002, 0x00000004, 0x00000008,
0x00000010, 0x00000020, 0x00000040, 0x00000080,
0x00000100, 0x00000200, 0x00000400, 0x00000800,
0x00001000, 0x00002000, 0x00004000, 0x00008000,
0x00010000, 0x00020000, 0x00040000, 0x00080000,
0x00100000, 0x00200000, 0x00400000, 0x00800000,
0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000
};
//-----------------------------------------------------------------------------
// Static Variable Declarations
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Private Function Prototypes
//-----------------------------------------------------------------------------
static uint32_t init_psc(void);
static uint32_t init_clocks(void);
//-----------------------------------------------------------------------------
// Public Function Definitions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// \brief initializes psc, pll, and pinmuxes.
//
// \param none.
//
// \return uint32_t
// ERR_NO_ERROR - everything is ok...cpu ready to use.
// ERR_INIT_FAIL - something happened during initialization.
//-----------------------------------------------------------------------------
uint32_t EVMOMAPL138_init(void)
{
uint32_t rtn = 0;
// configure power, sysconifg, and clocks.
rtn = init_psc();
rtn |= init_clocks();
if (rtn)
return (ERR_INIT_FAIL);
else
return (ERR_NO_ERROR);
}
//-----------------------------------------------------------------------------
// \brief initializes ram on EMIFB.
//
// \param none.
//
// \return uint32_t
// ERR_NO_ERROR - everything is ok...ram ready to use.
// ERR_INIT_FAIL - something happened during initialization.
//-----------------------------------------------------------------------------
uint32_t EVMOMAPL138_initRAM(void)
{
uint32_t rtn = 0;
// unlock the system config registers and set the ddr 2x clock source.
SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
CLRBIT(SYSCONFIG->CFGCHIP[3], CLK2XSRC);
// enable emif3a clock.
EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_EMIF3A, PSC_ENABLE);
// check if vtp calibration is enabled.
if (CHKBIT(VTPIO_CTL, 0x00000040))
{
// vtp cal disabled, begin cal.
// enable input buffer and vtp.
SETBIT(VTPIO_CTL, 0x00004000);
CLRBIT(VTPIO_CTL, 0x00000040);
// pulse clrz to init vtp cal.
SETBIT(VTPIO_CTL, 0x00002000);
CLRBIT(VTPIO_CTL, 0x00002000);
SETBIT(VTPIO_CTL, 0x00002000);
// poll ready bit to wait for cal to complete.
while (!CHKBIT(VTPIO_CTL, 0x00008000)) {}
// set lock and power save bits.
SETBIT(VTPIO_CTL, 0x00000180);
}
// config ddr timing.
DDR->DDRPHYCTL1 = 0x000000C4;
DDR->SDCR = 0x0893C622;
DDR->SDCR &= ((DDR->SDCR & 0xFF0FFFFF) | 0x00800000);
DDR->SDCR = ((DDR->SDCR & 0xFF0FFFFF) | 0x02000000);
DDR->SDCR &= (~0x00008000);
DDR->SDTIMR1 = 0x20923A89;
DDR->SDTIMR2 = 0x0015C720;
DDR->SDCR2 = 0x0;
DDR->SDRCR = 0x00000492;
// set ddr2 to sync reset.
SETBIT(DDR->SDRCR, 0xC0000000);
// sync reset the ddr clock.
EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_EMIF3A, PSC_SYNCRESET);
// enable the clock.
EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_EMIF3A, PSC_ENABLE);
// disable self refresh.
CLRBIT(DDR->SDRCR, 0xC0000000);
if (rtn)
return (ERR_INIT_FAIL);
else
return (ERR_NO_ERROR);
}
//-----------------------------------------------------------------------------
// \brief releases the dsp core from reset.
//
// \param none.
//
// \return none.
//-----------------------------------------------------------------------------
void EVMOMAPL138_enableDsp(void)
{
// power dsp core.
EVMOMAPL138_lpscTransition(PSC0, DOMAIN0, LPSC_DSP, PSC_ENABLE);
// wake up dsp core and release from reset.
SETBIT(PSC0->MDCTL[LPSC_DSP], LRST);
}
//-----------------------------------------------------------------------------
// \brief configures the desired pin mux register.
//
// \param uint32_t in_reg - pin mux register to be configured.
//
// \param uint32_t in_mask - bits to be set in pin mux register.
//
// \param uint32_t in_val - value to set the pin mux register.
//
// \return none.
//-----------------------------------------------------------------------------
void EVMOMAPL138_pinmuxConfig(uint32_t in_reg, uint32_t in_mask, uint32_t in_val)
{
// unlock the system config registers.
SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;
// make sure the pinmux register is cleared for the mask bits before
// setting the value.
CLRBIT(SYSCONFIG->PINMUX[in_reg], in_mask);
SETBIT(SYSCONFIG->PINMUX[in_reg], in_val);
// lock the system config registers.
SYSCONFIG->KICKR[0] = KICK0R_LOCK;
SYSCONFIG->KICKR[1] = KICK1R_LOCK;
}
//-----------------------------------------------------------------------------
// \brief transitions a local psc module to a new state.
//
// \param psc_regs_t *psc - psc register that contains the local module.
//
// \param uint32_t in_domain - input power domain (always on / internal).
//
// \param uint8_t in_module - module to be set.
//
// \param uint8_t in_next_state - next state for the local module.
//
// \return none.
//-----------------------------------------------------------------------------
void EVMOMAPL138_lpscTransition(psc_regs_t *psc, uint32_t in_domain, uint8_t in_module, uint8_t in_next_state)
{
// spin until existing transitions are done.
while (CHKBIT(psc->PTSTAT, in_domain)) {}
// if we are already in the requested state...just return.
if (CHKBIT(psc->MDSTAT[in_module], MASK_STATE) == in_next_state)
{
return;
}
// setup the transition...clear the bits before setting the next state.
CLRBIT(psc->MDCTL[in_module], NEXT);
SETBIT(psc->MDCTL[in_module], in_next_state);
// kick off the transition.
SETBIT(psc->PTCMD, in_domain);
// spin until transition is done.
while (CHKBIT(psc->PTSTAT, in_domain)) {}
while (CHKBIT(psc->MDSTAT[in_module], MASK_STATE) != in_next_state) {}
}
//-----------------------------------------------------------------------------
// helper function to initialize power and sleep config module.
//-----------------------------------------------------------------------------
uint32_t init_psc(void)
{
//-------
UART.zip_TI UART HOST_uart.c
版权申诉
3 浏览量
2022-09-24
04:26:10
上传
评论
收藏 286KB ZIP 举报
JaniceLu
- 粉丝: 79
- 资源: 1万+
最新资源
- 基于图像的三维模型重建C++源代码+文档说明(高分课程设计)
- 基于聚焦法的工件立体测量方案,根据数据进行三维重建 使用HALCON处理图像,MATLAB拟合数据+源代码+数据集+效果图
- 锄战三国村 修改:货币使用不减 v1.10(2) 原创 (中文).apk
- 基于python实现的单目双目视觉三维重建+源代码+图像图片(高分课程设计)
- 基于C+++OPENCV的全景图像拼接源码(课程设计)
- 基于Python+OpenCV对多张图片进行全景图像拼接,消除鬼影,消除裂缝+源代码+文档说明+界面截图(高分课程设计)
- 基于C++实现的全景图像拼接源码(课程设计)
- 基于SIFT特征点提取和RASIC算法实现全景图像拼接python源码+文档说明+界面截图+详细注释(95分以上课程大作业)
- 基于matlab实现眼部判别的疲劳检测系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的异常姿势识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈