strong pullup = weak resistancedavenull wrote:BTW:
wouldn't additional external pullups even reduce the overall- resistance as additional pullups always are put parallel to the internal ones?
(1/R = 1/R' + 1/R'' ) ??
you can hope in this and keep waitingdavenull wrote:But enabling i2c-0 must compellingly be a menu item in raspi-config for the future, just for all those developers!
i don't think wiringpi was written for this kind of use (2 concurrent i2c buses), but i suspect that:davenull wrote:now what about witingPi on i2c-0 ?
Your expectations are out of kilter with the real world. IN an ideal world, we would have every library we needed for every thing we ever wanted to do. And that would be me out of a job. In the actual world, I still have a job, because there is always code that needs to be written.davenull wrote:I am a simple end-user and beginner to Raspi, no sytem developer or low lever hardware progger or Linux hacker.
Having purchased a Raspi designed for beginners I expect libs to be available which provide convenient C/C++ API libs for offered hardware, and not just for that Python crap.
But as I don't have HATs I simply want to use the very convenient and very handsome wiringPi API libs for C/C++ to i2c-0.
Eventually that would be what I need.
Well, I do have three children, all young. I would hope that as a grandfather you would show a little more respect for people trying to help you, and respect for the work of others.davenull wrote:@massi: I don't expect you to post anything if you would not like to be helpful - I wouldn't even expect you to post this statement.
@jamesh:
an undue restriction of my rights would be to "reserve" either GPIOs for 3rd party products and exlude me from using them ! Please read closely!
My language is clean and child-suitable. I have two grand kids who grew up and developed with it excellently, but crap is crap, and mess is mess, and suck is suck.
I assume you don't know much about Children's speech ( or language).
Code: Select all
// THIS code should run on i2c-0 !! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <errno.h>
#include <string.h>
int main (void)
{
int fd, i ;
static unsigned char test=0;
unsigned char data[32];
if ((fd = wiringPiI2CSetup (0x60) ) < 0)
{
fprintf (stderr, "Can't open RTC: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}
while(1)
{
memset(data, 0, sizeof(data) );
read (fd, data, 32);
delay(5); // short delay
for (i = 0 ; i < 7 ; ++i)
{
memset(data, 0, sizeof(data) );
data[6]= data[5]; // comm test
data[5]= test++;
write(fd, data, 32) ;
delay(5); // short delay
}
}
return 0 ;
}
Code: Select all
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <wiringPi.h>
#include <wiringPiI2C.h>
int main() {
int fd;
unsigned char a, b, c, d, e;
if ((fd = wiringPiI2CSetup (0x60) ) < 0)
{
fprintf (stderr, "Can't open RTC: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}
while(1) {
a = wiringPiI2CReadReg8 (fd, 1) ;
b = wiringPiI2CReadReg8 (fd, 2) ;
c = wiringPiI2CReadReg8 (fd, 3) ;
d = wiringPiI2CReadReg8 (fd, 4) ;
e = wiringPiI2CReadReg8 (fd, 5) ;
delay(100); // long delay to pause device before next loop
}
return (0);
} Code: Select all
if ((fd = wiringPiI2CSetup (0x60) ) < 0)
{
fprintf (stderr, "Can't open RTC: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}
Code: Select all
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>
if ((fd = open ("/dev/i2c-0", O_RDWR)) < 0) {
fprintf (stderr, "Can't open i2c-0: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}
if (ioctl (fd, I2C_SLAVE, 0x60) < 0) {
fprintf (stderr, "Can't open RTC: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}Code: Select all
if ((fd = open ("/dev/i2c-0", O_RDWR)) < 0) {
fprintf (stderr, "Can't open i2c-0: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}
if (ioctl (fd, I2C_SLAVE, 0x60) < 0) {
fprintf (stderr, "Can't open RTC: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}Code: Select all
int dev1=wiringPiI2CSetupInterface("/dev/i2c-0", 0x60);
int dev2=wiringPiI2CSetupInterface("/dev/i2c-0", 0x22);
int dev3=wiringPiI2CSetup(0x45);
int dev4;
if ((dev4 = open ("/dev/i2c-0", O_RDWR)) < 0) {
fprintf (stderr, "Can't open i2c-0: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}
if (ioctl (dev4, I2C_SLAVE, 0x60) < 0) {
fprintf (stderr, "Can't open RTC: %s\n", strerror (errno)) ;
exit (EXIT_FAILURE) ;
}
//read from dev2
a = wiringPiI2CReadReg8 (dev2, 1) ;
//read from dev3
b = wiringPiI2CReadReg8 (dev3, 2) ;
//read / write RTC
memset(data, 0, sizeof(data) );
read (dev1, data, 32);
delay(5); // short delay
for (i = 0 ; i < 7 ; ++i)
{
memset(data, 0, sizeof(data) );
data[6]= data[5]; // comm test
data[5]= test++;
write(dev1, data, 32) ;
delay(5); // short delay
}
}
//write to dev4
b = wiringPiI2CWriteReg8 (dev4, 2, 0) ;
with the new version it surely would work:Please note that the official way to get wiringPi is via git from
git.drogon.net and not GitHub.
ie.
git clone git://git.drogon.net/wiringPi
Code: Select all
int dev0=wiringPiI2CSetupInterface("/dev/i2c-0", 0x60);
int dev1=wiringPiI2CSetupInterface("/dev/i2c-1", 0x60);you've been the only one who really provided precious help and reasonable hints which makes it possible to resolve this.(???)
I2C-0 Is not available for users
it is dedicated to the HAT interface
And what advice was given about using that configuration?
You're missing the point
I2C-0 is (now) reserved for hat use (and thus for those folks designing hats)
"go with the flow" not "against it"
Quite simply it's "reserved" via the firmware provided by the designers of the Pi.
The pins are reserved for use by HATs...the term 'reserved' is very common in computing to indicate that there is a 'standard' way of using something
i don't think wiringpi was written for this kind of use (2 concurrent i2c buses)
Your expectations are out of kilter with the real world
I would hope that...you would show a little more respect for people trying to help you, and respect for the work of others
(???)


No you're not designing a HAT, you're designing a Pi add on board. To call it a HAT you have to follow the HAT specification, and that requires an EEPROM attached to the pins 27&28 of the GPIO header which will load up a device tree fragment to configure Linux for your device. Omit that and it is not a HAT.davenull wrote:well, I actually am just designing my own "HATs", based on 1-2 Arduino Dues, providing 50 digital pins, 10 DAC, 2 ADC, 1 extra i2c, 1 SPI, 3 UARTs, and a USB host each. costs: 13 EUR each, and not a fortune, and C/C++ available, not just that crappy Python....
I2C muxes (eg TCA9548) are supported by the kernel (https://i2c.wiki.kernel.org/index.php/I ... ltiplexing), so get the device tree entries rightand you should be able to get Linux to show the outputs of the mux as independent i2c devices under /dev.davenull wrote:but what shall I do instead?
UART is already in use, I do need 1 quick i2c to interface my Arduino "HATs", and an extra, slower one for many different other devices, which may go slower but at least reasonable: that is most important to have for me.

It doesn't have to be anything. It may be a Linux system, but it's not open hardware.davenull wrote:My point is: I dislike an open-source product "reserving" pins for 3rd party companies, if not even just for special products:
i2c is i2c is i2c, period.
It has to be open for all purposes from default, and other way round: for special purposes like HATs (™ or ®) it has to be enabled before, because then it becomes a restriction of the open design!
(no matter who wants that feature or bug finally, if majority or minority of the customers - and who knows if a majority will ever keep to be it, or if it once will be detached by a minority eventually... except you'll limit the possibilities so much that the minority will migrate to other competitors: if it's that what you wish or intend to get, well....)
Read up a little on the display.davenull wrote:So why the heck do you reserve an i2c port to a display?
Surely fast or high speed i2c may be a bit faster than 100kHz, but what is that compared to 100MHz??
I am already running my Arduino TFTs (ILI9341) by 84MHz SPI in DMA mode!!
read again:
on an Arduino !!by 84 MHz!!
and by DMA!!
![]()
Firstly I don't work for Raspberry Pi, so I have no control at all over any policies. I worked at Broadcom before they laid off most of the team behind BCM2835 and BCM2836, so I know how the chip works, and provide support VOLUNTARILY because it is generally nice to help people.davenull wrote:So drop this TFT and cam design for i2c and abandon the HAT reservation for i2c-0!
Free i2c-0 (and anything) by default !
I've been following this thread with a certain amount of distaste, and what it comes down to it....I want to use the device a certain way, and I demand it should be the default. Well, sorry, but a very large number of people disagree with that because they use the camera, or HAT's.davenull wrote:The pins we are talking about are exposed as i2c-0 and not as MIPI DSI,
and honestly: who needs MIPI DSI when already HDMI by full-HD 1920x1080 is exposed by an extra (standard) HDMI jack (which I expect to work via automatic plug-and-play just like for TVs and Sat tuners) ?
But instead, having just 1 i2c (and just 1 UART) is rediculously poor.... :-/
anyway...
> /dev/null