Notes
Notes - notes.io |
{
uint32 rwData;
i2c_lprint(PRINT_L1, "==========BEGIN %s==========n", __FUNCTION__);
if (vdc_i2c_ctrl.i2c_port == 0)
{
vdc_i2c_cfg_clk_rst_pmpro();
}
else if (vdc_i2c_ctrl.i2c_port == 1)
{
vdc_i2c_cfg_clk_rst_slimpro();
}
else if( (vdc_i2c_ctrl.i2c_port >= 2) && (vdc_i2c_ctrl.i2c_port <= 4) )
{
vdc_i2c_cfg_clk_rst_sb_shcb();
}
// i2c_lprint(PRINT_L3, "Disable I2C n");
vdc_i2c_reg_wr(I2C_ENABLE_ADDR, 0x0);
vdc_i2c_reg_rd_print("I2C_ENABLE",I2C_ENABLE_ADDR, &rwData);
// i2c_lprint(PRINT_L3, "Disable all interrupt n");
vdc_i2c_reg_wr(I2C_INTR_MASK_ADDR, 0x0);
vdc_i2c_reg_rd_print("I2C_INTR_MASK",I2C_INTR_MASK_ADDR, &rwData);
i2c_lprint(PRINT_L3, "Set speed for I2C n");
rwData = (vdc_i2c_ctrl.i2c_core_clk / vdc_i2c_ctrl.i2c_speed) / 2;
if(vdc_i2c_ctrl.i2c_speed_mode == I2C_SPEED_MODE_STANDARD)
{
// vdc_i2c_debug();
// rwData = (vdc_i2c_ctrl.i2c_core_clk / vdc_i2c_ctrl.i2c_speed) / 2;
vdc_i2c_reg_wr( I2C_SS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()) );
vdc_i2c_reg_wr( I2C_SS_SCL_LCNT_ADDR, (rwData - 1));
vdc_i2c_reg_wr( I2C_FS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()) );
vdc_i2c_reg_wr( I2C_FS_SCL_LCNT_ADDR, (rwData - 1));
if(vdc_i2c_ctrl.i2c_addr_mode == I2C_ADDRESSING_7BIT)
vdc_i2c_reg_wr( I2C_CON_ADDR, 0x63);
else
vdc_i2c_reg_wr( I2C_CON_ADDR, 0x53);
}
else if(vdc_i2c_ctrl.i2c_speed_mode == I2C_SPEED_MODE_FAST)
{
// rwData = (vdc_i2c_ctrl.i2c_core_clk / vdc_i2c_ctrl.i2c_speed) / 2;
vdc_i2c_reg_wr( I2C_SS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()-20) );
vdc_i2c_reg_wr( I2C_SS_SCL_LCNT_ADDR, (rwData - 1+20));
vdc_i2c_reg_wr( I2C_FS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()-20) );
vdc_i2c_reg_wr( I2C_FS_SCL_LCNT_ADDR, (rwData - 1+20));
if(vdc_i2c_ctrl.i2c_addr_mode == I2C_ADDRESSING_7BIT)
vdc_i2c_reg_wr( I2C_CON_ADDR, 0x65);
// vdc_i2c_reg_wr( I2C_CON_ADDR, 0x45);
else
vdc_i2c_reg_wr( I2C_CON_ADDR, 0x55);
}
else if(vdc_i2c_ctrl.i2c_speed_mode == I2C_SPEED_MODE_PLUS)
{
// rwData = (vdc_i2c_ctrl.i2c_core_clk / vdc_i2c_ctrl.i2c_speed) / 2;
vdc_i2c_reg_wr( I2C_SS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()) );
vdc_i2c_reg_wr( I2C_SS_SCL_LCNT_ADDR, (rwData - 1));
vdc_i2c_reg_wr( I2C_FS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()) );
vdc_i2c_reg_wr( I2C_FS_SCL_LCNT_ADDR, (rwData - 1));
if(vdc_i2c_ctrl.i2c_addr_mode == I2C_ADDRESSING_7BIT)
// if(vdc_i2c_ctrl.i2c_port == I2C_I2C1)
vdc_i2c_reg_wr( I2C_CON_ADDR, 0x45);
// else
// vdc_i2c_reg_wr( I2C_CON_ADDR, 0x65);
else
vdc_i2c_reg_wr( I2C_CON_ADDR, 0x55);
}
else //Reserved
{
vdc_i2c_reg_wr( I2C_SS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()) );
vdc_i2c_reg_wr( I2C_SS_SCL_LCNT_ADDR, (rwData - 1));
vdc_i2c_reg_wr( I2C_FS_SCL_HCNT_ADDR, (rwData - 6 - vdc_i2c_get_fs_spklen_reg()) );
vdc_i2c_reg_wr( I2C_FS_SCL_LCNT_ADDR, (rwData - 1));
}
//Configured target address , salve address
vdc_i2c_reg_wr( I2C_TAR_ADDR, vdc_i2c_ctrl.i2c_tar_addr);
vdc_i2c_reg_wr( I2C_SAR_ADDR, vdc_i2c_ctrl.i2c_slv_addr);
vdc_i2c_reg_wr( I2C_RX_TL_ADDR, 0xFF);
vdc_i2c_reg_wr( I2C_TX_TL_ADDR, 0xFF);
vdc_i2c_reg_wr( I2C_SAR_ADDR, vdc_i2c_ctrl.i2c_slv_addr);
vdc_i2c_reg_wr( I2C_SDA_HOLD_ADDR, 1);
// i2c_lprint(PRINT_L3, "Enable I2C n");
vdc_i2c_reg_wr( I2C_ENABLE_ADDR, 0x1);
vdc_i2c_reg_rd_print("I2C_ENABLE",I2C_ENABLE_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_INTR_MASK",I2C_INTR_MASK_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_SS_SCL_HCNT",I2C_SS_SCL_HCNT_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_SS_SCL_LCNT",I2C_SS_SCL_LCNT_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_FS_SCL_HCNT",I2C_FS_SCL_HCNT_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_FS_SCL_LCNT",I2C_FS_SCL_LCNT_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_CON",I2C_CON_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_TAR",I2C_TAR_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_SAR",I2C_SAR_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_RX_TL", I2C_RX_TL_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_TX_TL", I2C_TX_TL_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_SDA_HOLD",I2C_SDA_HOLD_ADDR, &rwData);
vdc_i2c_reg_rd_print("I2C_ENABLE",I2C_ENABLE_ADDR, &rwData);
_delay_for(100);
i2c_lprint(PRINT_L1, "==========END %s==========n", __FUNCTION__);
return RET_OK;
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team