Not able to use both sw IIC and hw IIC due to procedures having the same name.

28 views
Skip to first unread message

rob...@hotmail.com

unread,
Feb 13, 2022, 1:04:18 PM2/13/22
to jallib
Hi all,

I got an e-mail from a Jallib user who wants to use both IIC software and IIC hardware. This is, however, not possible because both libraries use the same names in procedures and functions.

For USART the convention 'sw', 'hw' and 'hw2' is used in the procedures.

The problem is easily fixed by adding _sw_ to the software iic procedures. I did this for this Jallib member and gave him a modified version of i2c_software. But when changing this and adding this to Jallib then all sample files that use i2c_software should be changed and members that have made projects with this library should modify their programs too.

Next to that, for consistency, the i2c_hardware should also get the addition (in procedure names) _hw_.

What do you think? Should this be changed and if so, how?

Thanks.

Kind regards,


Rob



Oliver Seitz

unread,
Feb 13, 2022, 3:59:11 PM2/13/22
to jal...@googlegroups.com
Hi Rob,

I think it's a good idea to change the names in both libs.

If it really is a problem for existing programs that are to hard to change accordingly, we could provide meta-libraries like i2c_legacy_software which do nothing more than include the new libraries and define aliases for the old names.

I wouldn't need those legacy libraries, I have an editor that has find/replace, so no big deal to modify my programs.

Greets,
Kiste

Am Sonntag, 13. Februar 2022, 19:12:31 MEZ hat rob...@hotmail.com <rob...@hotmail.com> Folgendes geschrieben:


--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/474cfa3b-7eac-4d43-821e-d77fd74916fan%40googlegroups.com.

Matthew Schinkel

unread,
Feb 13, 2022, 4:47:05 PM2/13/22
to jallib
Hi Rob, I agree. Change the i2c library variable and procedure names in both libs.

If there are any libraries using the i2c lib, they should not need to be changed. Instead, add aliases in the samples like what I've done for serial in many samples.

In 18f4620_sd_card.jal:
-- some aliases so it is easy to change from serial hw to serial sw.
alias serial_write is serial_hw_write
alias serial_read is serial_hw_read
alias serial_data is serial_hw_data
alias serial_data_available is serial_hw_data_available

This allows the user to switch between hardware and software libraries, or use both.

I don't think there is any need for a legacy library when the user can just add some alias lines to their sample. They'll need to change their sample either way.

Thanks,
Matt.

vsurducan

unread,
Feb 14, 2022, 2:21:31 AM2/14/22
to jal...@googlegroups.com
Hi all,
Would be interesting to find why it uses both types of i2c. From pure hw perspective, once you have an i2c bus, you can expand it as much you want by changing it's base address with a buffer/expander. Perhaps the user did not knew this.

--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.

Oliver Seitz

unread,
Feb 14, 2022, 2:28:05 AM2/14/22
to jal...@googlegroups.com
Different speeds?
Different pullup values?
Long lines?
Hardware as slave, Software as master?
Personal preference?


Am Mo., Feb. 14, 2022 at 8:21 schrieb vsurducan

Rob CJ

unread,
Feb 14, 2022, 12:46:39 PM2/14/22
to jal...@googlegroups.com
Hi Matt,

Aliases do not solve the problem. The procedure name still exists and so including both iic_software and iic_hardware will lead to a 'function already defined' error. 

If I am right an alias is only a different name for the same thing but with an alias you can use both the alias and the original name, correct?

Next to that iic_software uses function prototypes and so the alias has to be after the function prototype but then the function is already mentioned.

So the only way to solve this is - like Kiste mentioned - a find replace of iic_ by iic_sw for software and iic_hw for hardware iic. It is then up to the JAL user to either do the same or add an alias 😉.

Please correct me if I am wrong.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Matthew Schinkel <mattsc...@hotmail.com>
Verzonden: zondag 13 februari 2022 22:47
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] Re: Not able to use both sw IIC and hw IIC due to procedures having the same name.
 

Zet Weeh

unread,
Feb 14, 2022, 5:16:01 PM2/14/22
to jal...@googlegroups.com
Hai
Is it strange to have iic_software and iic_sw?
When you see this you think: what’s the difference?
When you open the iic_software you read: for duingebied with other pins than iic_hardware. 
When you open iic_sw you read: for using together with iic_hardware (when you need 2 iic connections).
For people who used iic_software in the past all remains working!
A possibility?
Peter 

Wees nieuwsgierig maar overdrijf niet. 

Op 14 feb. 2022 om 18:46 heeft Rob CJ <rob...@hotmail.com> het volgende geschreven:



Matthew Schinkel

unread,
Feb 14, 2022, 6:09:08 PM2/14/22
to jallib
Hi Rob, I was suggesting to change the procedure names and use aliases after the include. This does solve the issue.

As I mentioned, See 18f4620_sd_card.jal how the serial port is used. Changing these lines to serial_sw makes the sample and any further includes use serial sw.
-- some aliases so it is easy to change from serial hw to serial sw.
alias serial_write is serial_hw_write
alias serial_read is serial_hw_read
alias serial_data is serial_hw_data
alias serial_data_available is serial_hw_data_available

Although i2c is meant to support multiple devices, you may want another port because:
- you have too many devices and would rather not add components
- you want to use two of the same device that have the same address

Matt.

Rob CJ

unread,
Feb 15, 2022, 1:17:16 PM2/15/22
to jallib, zet....@gmail.com
Hi Matt,

You are completely right, I totally forgot about the addresses. I am solving a problem that is not a problem.

@zet....@gmail.com You do not have to use 2 libraries. Just use the IIC hardware library and connect both devices to the same IIC lines.

The address of the IIC devices make them unique and they are both slave devices so that will work.

Kind regards,

Rob


Verzonden: dinsdag 15 februari 2022 00:09
Aan: jallib <jal...@googlegroups.com>
Onderwerp: Re: [jallib] Re: Not able to use both sw IIC and hw IIC due to procedures having the same name.
 
Reply all
Reply to author
Forward
0 new messages