I2C struct "i2c_packet" definition missing ?

Discussions around product based on ARM Cortex M0+ core.

Moderator: nferre

terbo
Posts: 26
Joined: Sun Oct 06, 2013 11:04 pm

I2C struct "i2c_packet" definition missing ?

Sun Jun 29, 2014 8:09 pm

Hi.
I have included the I2C master/poll and I2C slave/poll ASF in my project. I2C ASF functions as "i2c_master_read_packet_wait()" uses the struct "i2c_packet". It seems the definition is missing!
Q: Does anyone know in which file "struct i2c_packet" is (should have been?) defined ?
best regards
Terje Bohler
mkwired
Posts: 4
Joined: Tue Feb 25, 2014 11:39 pm

Re: I2C struct "i2c_packet" definition missing ?

Mon Jun 30, 2014 3:44 am

I only know of two packet types (i2c_master_packet and i2c_slave_packet). Where did you find the i2c_packet type?
terbo
Posts: 26
Joined: Sun Oct 06, 2013 11:04 pm

Re: I2C struct "i2c_packet" definition missing ?

Mon Jun 30, 2014 8:17 pm

In the:
APPLICATION NOTE
Atmel AT03254: SAM D20/D21 I2C Slave Mode Driver
(SERCOM I2C)
ASF PROGRAMMERS MANUAL

it refers to:

Code: Select all

static struct i2c_packet packet;
I guess it's a document error/mistake.
regards Terje Bohler
terbo
Posts: 26
Joined: Sun Oct 06, 2013 11:04 pm

Re: I2C struct "i2c_packet" definition missing ?

Mon Jun 30, 2014 8:46 pm

Hi.
It must be some error/mismatch here ...
In the Quick Start Guide of:
APPLICATION NOTE
AT03250: SAM D20/D21 I2C Master Mode Driver
(SERCOM I2C)
ASF PROGRAMMERS MANUAL
... it says:
6.3.3.3 Function i2c_master_write_packet_wait()
Writes data packet to slave.

Code: Select all

enum status_code i2c_master_write_packet_wait(
struct i2c_master_module *const module,
struct i2c_packet *const packet)
but:
1) the refered "struct i2c_packet" dont exist
2) The prototyped i2c_master_write_packet_wait(..) of/in the ASF generated code says:

Code: Select all

enum status_code i2c_master_write_packet_wait(
		struct i2c_master_module *const module,
		struct i2c_master_packet *const packet);
where:

Code: Select all

struct i2c_master_packet {
	/** Address to slave device  */
	uint16_t address;
	/** Length of data array */
	uint16_t data_length;
	/** Data array containing all data to be transferred */
	uint8_t *data;
	/** Use 10 bit addressing. Set to false if the feature is not supported by the device  */
	bool ten_bit_address;
	/** Use high speed transfer. Set to false if the feature is not supported by the device */
	bool high_speed;
	/** High speed mode master code (0000 1XXX), valid when high_speed is true */
	uint8_t hs_master_code;
};
Think I see the problem. Here's obvious something wrong in the "QSG app note" document (defining/specifying a non-existing "struct i2c_packet"), from where I copied my code ... and by the way are causing my program to execute/enter the "HardFault_Handler(..)"

best regards
Terje Bohler

If someone could support me with the correct
terbo
Posts: 26
Joined: Sun Oct 06, 2013 11:04 pm

Re: I2C struct "i2c_packet" definition missing ?

Mon Jun 30, 2014 10:42 pm

OK, here's the result (among others):

Code: Select all

	struct i2c_master_packet packet = {
		.address     = SLAVE_ADDRESS,
		.data_length = DATA_LENGTH,
		.data        = write_buffer,
		.ten_bit_address = false,
		.high_speed      = false,
		.hs_master_code  = 0x0,
	};
Because my project consists of many different MCU features/components, the way I generated my system initially, was:
1) Creating an "8Mhz osc..." project
2) Used the ASF Wizard to add ASF-components for ADC, I2C etc.
(so this code was not auto-generated for me)

Thanks again.

best regards
Terje Bohler

Return to “SAM D20 Cortex-M0+ MCU”

Who is online

Users browsing this forum: No registered users and 1 guest