16个帖子/ 0新
Last post
sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
documentation

你好,

我找不到任何谈论14580(或其他)的外围设备功能的文件以及如何为不同的选项设置它们。

I2C,SPI,A / D,PWM,....等。

有人能指出我这样的文件吗?

关键词:
设备:
MT_dialog
离线
Last seen:1 month 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

Please have a look at the documents UM-B-050 at the peripheral examples applications section (7) and also you can have a look to the doc UM-B-051 in the peripheral drivers section (10) for the drivers of the peripherals.

Thanks MT_dialog

sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
你好,

你好,

我已经看到了这些文件。
There is no description of the hardware structure of the peripherals and how these can be setup . The examples cannot cover all possible combinations and functionalities.

Please confirm that this document is missing.

MT_dialog
离线
Last seen:1 month 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

There are no other documents concerning the da peripherals and the developed APIs, for more info about any additional functionalities can be found in the da's datasheet. Also you might want to have a look at the documents UM-B-005 and UM-B-004 to check if those documents cover any additional functionalities.

Thanks MT_dialog

sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
Example : I want to command a

示例:我想使用i2c命令传感器。我需要发送命令写入然后最终读取。读取可以是max n字节。

I dont know how to set the bits and bytes in the I2C registers to send and receive because it is not written anywhere !.

在这种情况下,I2C_EEPROM示例的功能是可用的?

谢谢 !

mhv_dialog.
离线
Last seen:1个月2周前
Staff
加入:2013-12-06 15:10
你好,

你好,

我不认为I2C_EEPROM示例的I2C功能是传感器驱动程序的一个很好的起点。我一直在使用下面的例子,更好地解释了如何攻击I2C:

/ ****************************************************************************************
* MACROS
*****************************************************************************************
// i2c Helper宏
#define send_i2c_command(x)setword16(i2c_data_cmd_reg,(x))
#define WAIT_WHILE_I2C_FIFO_IS_FULL() while(!(GetWord16(I2C_STATUS_REG) & TFNF))
#define WAIT_UNTIL_I2C_FIFO_IS_EMPTY() while(!(GetWord16(I2C_STATUS_REG) & TFE))
#define wait_until_no_master_actity()(getword16(i2c_status_reg)&mst_actity)
#define WAIT_FOR_RECEIVED_BYTE() while(!GetWord16(I2C_RXFLR_REG))

/ * ---------------------------------------------------------------------------
|@brieie初始化提供从地址的I2C接口
|
|@param [in] slave_address,i2c从地址与之通信
|
|@return void.
------------------------------------------------------------------------------------------------- * /
void i2c_init(uint8_t slave_address)
{
//Initialize the I2C with the address provided as argument
// todo:支持10bit寻址
setbits16(clk_per_reg,i2c_enable,1);//为i2c启用时钟
SetWord16(I2C_ENABLE_REG, 0x0); // Disable the I2C controller
setword16(i2c_con_reg,i2c_master_mode | i2c_slave_disable | i2c_restart_en);//从站被禁用
setBits16(i2c_con_reg,i2c_speed,1);//设置速度。标准速度= 1,快速= 2
SetBits16(I2C_CON_REG, I2C_10BITADDR_MASTER, 0); // Set addressing mode. 7bit = 0, 10bit= 1
setword16(i2c_tar_reg,slave_address&0xff);//设置从设备地址
setword16(i2c_enable_reg,0x1);//启用I2C控制器
而(getword16(i2c_status_reg)&0x20);//等待I2C主FSM闲置
}
//

/ * ---------------------------------------------------------------------------
|@brief扫描从设备的I2C总线进行奴隶设备
|
|@param[in] extended, if true: Response will include potential I2C slave device IDs
|@param [in]远程,扫描命令的始发者
|
|@return void.
------------------------------------------------------------------------------------------------- * /
void i2c_scan(bool扩展,bool remote)
{
char temp_str[255] = {0};
char response_str [255] = {0};
uint8_t response_idx = 0;

//遍历所有I2C地址(仅限7bit寻址!)
for(uint8_t i = 0x01; i < 0x7F; i++)
{
//设置下一个从地址
i2c_init(i);

send_i2c_command(0x00&0x3ff);//在总线上传输地址
等待_while_i2c_fifo_is_full();//等待i2c tx fifo已满
send_i2c_command(0x0100&0x3ff);//发送读取寄存器0x00
wait_until_i2c_fifo_is_empty();//等到TX FIFO是空的
wait_until_no_master_actity();//Make sure Master has finished

//我们是否收到了任何数据?
if(getword16(i2c_rxflr_reg)!= 0)
{
/ /读取接收到的数据(device_id)
uint8_t device_id =0xFF & GetWord16(I2C_DATA_CMD_REG);
//If this is an extended scan then report the device ID as well as the address
if(extended)
//扩展扫描。报告地址和注册0x00(device_id)
Sprintf(Temp_str,“0x%02x => 0x%02x,”,i,device_id);
别的
//Normal scan => report address
sprintf(temp_str, "0x%02X,",i);
memcpy(&response_str [response_idx],temp_str,strlen(temp_str));
//警告:如果在总线上提供超过50个I2C设备,则会失败
response_idx += strlen(temp_str);
}

}
//Append Carriage-return, Linefeed and 'OK' to response
Sprintf(Temp_str,“\ n \ rok”);
memcpy(&response_str [response_idx-1],temp_str,strlen(temp_str));
//Display response (remote or locally)
响应(response_str,strlen(response_str),远程);

//禁用i2c.
SetWord16(I2C_ENABLE_REG, 0x0); // Disable the I2C controller
SetBits16(CLK_PER_REG, I2C_ENABLE, 0); // Disable clock for I2C

}
//

/ * ---------------------------------------------------------------------------
|@brief发送i2c从存储器地址
|
|@param [in] I2C从存储器的地址
------------------------------------------------------------------------------------------------- * /
void i2c_send_address(uint8_t地址_to_send)
{

send_i2c_command(地址_to_send&0xff);//设置地址LSB,写访问
}
//

/ * ---------------------------------------------------------------------------
|@brief从i2c从站读取单个字节。
|
|@param[in] address, Memory address to read the byte from.
|
|@return Read byte.
------------------------------------------------------------------------------------------------- * /
int8_t i2c_read_byte(uint8_t address)
{
i2c_send_address(address & 0x3FF);
等待_while_i2c_fifo_is_full();//等待TX FIFO已满
send_i2c_command(0x0100&0x3ff);//Set R/W bit to 1 (read access)
wait_until_i2c_fifo_is_empty();//Wait until I2C Tx FIFO empty
wait_until_no_master_actity();//确保大师已完成
返回(0xff&getword16(i2c_data_cmd_reg));//获得收到的字节
}
//

/ * ---------------------------------------------------------------------------
|@brief将单个字节写入i2c从属。
|
|@param[in] address, Memory address to write the byte to.
|@param [in] wr_data,编写的数据。
|
|@return void。
------------------------------------------------------------------------------------------------- * /
void i2c_write_byte(uint16_t address, uint8_t wr_data)
{
i2c_send_address(地址);
等待_while_i2c_fifo_is_full();//等待i2c tx fifo已满
send_i2c_command(wr_data&0xff);//发送写入数据
wait_until_i2c_fifo_is_empty();//等到TX FIFO是空的
wait_until_no_master_actity();//等到没有主活动
}
//

/ * ---------------------------------------------------------------------------
|@brief从i2c从站读取数据
|
|@param [in] hw_address,i2c从设备的HW地址
|@param [in] reg_address,要读取的注册地址
|@param [in] num_bytes,要读取的字节数
|@param [in]远程,read命令的始发者
|
|@return void.
------------------------------------------------------------------------------------------------- * /
void i2c_read(uint16_t hw_address,uint16_t reg_address,uint8_t num_bytes,bool远程)
{
char temp_str[255] = {0};
i2c_init(hw_address);
for(uint8_t i=0;i{
UINT8_T DATA = I2C_READ_BYTE(REG_ADDRESS + I);
char str[10];
if(i==0)
sprintf(str,"0x%02X",data);
别的
Sprintf(str,“,0x%02x”,数据);
Sprintf(Temp_str,“%s%s”,temp_str,str);
}
Sprintf(Temp_str,“%s \ n \ rok”,temp_str);
respond(temp_str,strlen(temp_str),remote);
}
//

/ * ---------------------------------------------------------------------------
|@brief将数据写入I2C从站的寄存器地址
|
|@param [in] hw_address,i2c从设备的HW地址
|@param[in] reg_address, Register address to write to
|@param [in]数据,数据写入
|@param [in]远程,read命令的始发者
|
|@return void.
------------------------------------------------------------------------------------------------- * /
void i2c_write(uint16_t hw_address,uint16_t reg_address, uint16_t wr_data, bool remote)
{
i2c_init(hw_address);
i2c_write_byte(reg_address,wr_data);
respond_ok(remote);
}
//

I hope this helps.

sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
Ok this seems what I was

好的,这似乎正在寻找什么。我会试一试。

我不知道为什么你没有在SDK的文档和库中添加这个!!,这个论坛的许多人都会很开心。市场上有这么多的I2C设备,每个I2C设备都有自己的结构和协议。

谢谢你!

sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
Hello , where do I find these

您好,我在哪里找到了这些功能
Sprintf(Temp_str,“%s \ n \ rok”,temp_str);
respond(temp_str,strlen(temp_str),remote);

sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
对不起,我的意思是回复()和

对不起,我的意思是回复()和respond_ok()

mhv_dialog.
离线
Last seen:1个月2周前
Staff
加入:2013-12-06 15:10
你好,

你好,

SprIntf来自STDLIB库(只是#include“stdlib.h”) - 当您想要将数据转储到用户或调试期间,真正有用。

The two respond functions are just a set of functions that i have implemented to dump the data to a serial port. You can use UART2 and arch_printf to do this in your code.

我同意这应该将其添加到文档中 - 用于快速教程的有用材料。

sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
你好,好的,这很清楚。

你好,好的,这很清楚。
在上面的代码中,
......................
void i2c_write_byte(uint16_t address, uint8_t wr_data)
{
i2c_send_address(地址);
等待_while_i2c_fifo_is_full();//等待i2c tx fifo已满
send_i2c_command(wr_data&0xff);//发送写入数据
wait_until_i2c_fifo_is_empty();//等到TX FIFO是空的
wait_until_no_master_actity();//等到没有主活动
}
Tar寄存器包含从站的地址,DATA_CMD寄存器包含要发送的数据。I2C_SEND_ADDRESS(地址)会将地址写入DATA_CMD寄存器,然后send_i2c_command(wr_data ..)会这样做!。

这是一个错误还是我错过了什么?
都应该通过data_cmd_reg?即,要发送目标和数据的地址?
如果是,则tar_reg位0:7的范围是多少?

What is simply the mechanism to :
1 - 向奴隶发送一个命令?
Command could be read, write, reset , ..
2-从从设备读取N.字节?
所有没有中断,只是为了让它变得简单。
谢谢 !

MT_dialog
离线
Last seen:1 month 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

IC_TAR寄存器包含从设备的地址,在I2C驱动程序中,设备将首先写入模块的寄存器地址,即它想要读取/写入data_cmd,然后,在data_cmd中放置数据传输。I2C_tar是设备本身的地址,在I2C初始化期间设置了设备地址的设置。

Thanks MT_dialog

sjabir2004@yahoo.com
离线
Last seen:5 years 3 months ago
加入:2015-09-18 22:13
Hello

Hello

I2C_tar包含DA14580将写入的I2C设备的地址。
data_cmd_reg中包含要与设备进行通信的数据。

当我写入data_cmd_reg任何数据时,在I2C总线上,您首先拥有I2C_TAR_REG,然后是I2C_DATA_REG内容。

如果我将从地址写入data_cmd_reg,你将在公共汽车上有两次的地址!!

如果总线上有单个I2C设备,则需要一次加载tar_reg一次,然后将数据写入data_cmd_reg然后我获取地址 - >发送到设备的数据,

这就是我在内存示波器上看到的。

Am I missing something here ?

MT_dialog
离线
Last seen:1 month 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

你的意思是 ?如果在data_cmd_reg中编写设备的从站地址,则模块将发送I2C_TAR_REG(这是模块的地址),然后将在DATA_CMD_REG中发送数据,该数据再次成为模块的地址。您只需要使用要通信的设备初始化I2C,然后每次在data_cmd_reg中写入内容时,设备的地址将在总线上遵循操作(读/写),然后是数据在data_cmd_reg中。停止或重新启动条件后,I2C将启动新事务时,设备的地址将再次在总线上。

Thanks MT_dialog

ajay98
离线
Last seen:1 month 1 week ago
加入:2018-07-10 12:12
你好,

你好,
我正在使用SDK 5.0.4。在DA14580设备中检查安全功能,我必须在EEPROM中存储绑定数据。在向EEPROM写入字节时,我面临i2c_wait_until_eeprom_ready()函数的问题。它会影响调试。
if((getword16(sys_stat_reg)&dbg_is_up)== dbg_is_up)
__asm(“bkpt#0 \ n”);

我的代码如下所示,
************************************************************************************
/ ************************************************************
*为键数据存储选择内存介质:
*
* - spi flash(#define user_cfg_app_bond_db_use_spi_flash)
* - I2C EEPROM (#define USER_CFG_APP_BOND_DB_USE_I2C_EEPROM)
* - 仅缓存(定义任何内容)
*
* Select only one option.
************************************************************
* /
#undef user_cfg_app_bond_db_use_spi_flash.
#define user_cfg_app_bond_db_use_i2c_eeprom.

静态内联void bond_db_load_ext(void)
{
#f定义(user_cfg_app_bond_db_use_spi_flash)
bond_db_load_flash();
#elif定义(user_cfg_app_bond_db_use_i2c_eeprom)
bond_db_load_eeprom();
#万一
}

#elif定义(user_cfg_app_bond_db_use_i2c_eeprom)

静态void bond_db_load_eeprom(void)
{
uint32_t bytes_read;

i2c_eeprom_init(i2c_slave_address,i2c_speed_mode,i2c_address_mode,i2c_address_size);

i2c_eeprom_read_data((uint8_t *)&bdb,app_bond_db_data_offset,sizeof(struct bond_db),&bytes_read);
ASSERT_ERROR(bytes_read == sizeof(struct bond_db));

i2c_eeprom_release();
}

i2c_error_code i2c_eeprom_read_data(uint8_t *rd_data_ptr, uint32_t address, uint32_t size, uint32_t *bytes_read)
{
uint32_t tmp_size;

if (size == 0)
{
*bytes_read = 0;
返回i2c_no_error;
}

//检查要从a(max_size x 8)I2C EEPROM的读取的最大字节
if(size> i2c_eeprom_size - 地址)
{
tmp_size = I2C_EEPROM_SIZE - address;
*bytes_read = tmp_size;
}
别的
{
tmp_size = size;
*bytes_read = size;
}

if (i2c_wait_until_eeprom_ready() != I2C_NO_ERROR)
{
返回i2c_7b_addr_noack_error;
}

//一次读取32个字节
while (tmp_size >= 32)
{
read_data_single(&rd_data_ptr,地址,32);

address += 32; // Update base address for read
tmp_size -= 32; // Update tmp_size for bytes remaining to be read
}

if(tmp_size)
{
read_data_single(&rd_data_ptr, address, tmp_size);
}

返回i2c_no_error;
}

i2c_error_code i2c_wait_until_eeprom_ready(void)
{
uint16_t tx_abrt_source;

//Check if ACK is received
for(Uint32_t i = 0; i {
send_i2c_command(0x08);//制作假人
wait_until_i2c_fifo_is_empty();//等到TX FIFO是空的
wait_until_no_master_actity();//等到没有主活动
tx_abrt_source = getword16(i2c_tx_abrt_source_reg);//读取i2c_tx_abrt_source_reg寄存器
getword16(i2c_clr_tx_abrt_reg);//清除i2c_tx_abrt_source寄存器
if((tx_abrt_source&abrt_7b_addr_noack)== 0)
{
返回i2c_no_error;
}
}
返回i2c_7b_addr_noack_error;
}

注意:如果我在Sysram中加载了键数据,则它正常工作。IE,
#undef user_cfg_app_bond_db_use_spi_flash.
#undef user_cfg_app_bond_db_use_i2c_eeprom.

请给出一个有价值的建议,以避免这个问题。谢谢。

PM_Dialog
离线
Last seen:16 hours 2 min ago
Staff
加入:2018-02-08 11:03
嗨ajay98,

嗨ajay98,

The i2c_wait_until_eeprom_ready() is polling the device via sending a 0x08 byte until the device responds with an ACK. Can you please run the code in debug mode and indicate in which point of i2c_wait_until_eeprom_ready() the code gets stuck? Also, which example of the SDK are you using? Is this a custom implementation? Would it be possible to replicate it in the ble_app_security example of the SDK?

I would also recommend you creating a new forum thread with your issue, as this one is very old.

Thanks, PM_Dialog