RPi 4B i2c buss 6

115 views
Skip to first unread message

Ron Patton

unread,
Mar 6, 2020, 9:41:20 AM3/6/20
to bcm2835
Hi,

I have started a new thread regarding bcm2835 accessing the new additional i2c buses on the RPi 4B.  The short of the issue we have is an audio hat we are implementing needs exclusive access to i2c buss 1.   We also need to implement i2c devices.  I have a test configuration with the hat installed and one of our i2c devices on buss 6.   This works in so far as i2cdetect finds the hat on buss 1 and our i2c device on buss 6.   However when testing the hat by playing music via VLC,  when I start my program that uses PIGPIO ,  the output of the audio hat turns to white noise.  

The bottom line is that it looks like I need to take a look at the source code for PIGPIO so while I am at digging around in source code, I thought I would take a look at bcm2835 source also.  But,  would someone let me know where I need to start looking in the bcm2835 source to find where it defines the access point(s).

Regards,
Ron. 

Arjan van Vught

unread,
Mar 6, 2020, 9:47:30 AM3/6/20
to bcm...@googlegroups.com
Hi Ron, 
with a grep you can see all references to i2c :

src % grep i2c_ bcm2835.*

bcm2835.c:static int i2c_byte_wait_us = 0;
bcm2835.c:int bcm2835_i2c_begin(void)
bcm2835.c:    i2c_byte_wait_us = ((float)cdiv / BCM2835_CORE_CLK_HZ) * 1000000 * 9;
bcm2835.c:void bcm2835_i2c_end(void)
bcm2835.c:void bcm2835_i2c_setSlaveAddress(uint8_t addr)
bcm2835.c:void bcm2835_i2c_setClockDivider(uint16_t divider)
bcm2835.c:    i2c_byte_wait_us = ((float)divider / BCM2835_CORE_CLK_HZ) * 1000000 * 9;
bcm2835.c:void bcm2835_i2c_set_baudrate(uint32_t baudrate)
bcm2835.c: bcm2835_i2c_setClockDivider( (uint16_t)divider );
bcm2835.c:uint8_t bcm2835_i2c_write(const char * buf, uint32_t len)
bcm2835.c:uint8_t bcm2835_i2c_read(char* buf, uint32_t len)
bcm2835.c:uint8_t bcm2835_i2c_read_register_rs(char* regaddr, char* buf, uint32_t len)
bcm2835.c:    bcm2835_delayMicroseconds(i2c_byte_wait_us * 3);
bcm2835.c:uint8_t bcm2835_i2c_write_read_rs(char* cmds, uint32_t cmds_len, char* buf, uint32_t buf_len)
bcm2835.c:    bcm2835_delayMicroseconds(i2c_byte_wait_us * (cmds_len + 1));

bcm2835.h:  bcm2835_spi_begin() and bcm2835_i2c_begin() will return false and all
bcm2835.h:  The bcm2835_i2c_* functions allow you to control the BCM 2835 BSC interface,
bcm2835.h:  \version 1.18 Added bcm2835_i2c_* functions. Changes to bcm2835_delayMicroseconds: 
bcm2835.h:  \version 1.23 Added bcm2835_i2c_set_baudrate and bcm2835_i2c_read_register_rs. 
bcm2835.h:  Improvements to bcm2835_i2c_read and bcm2835_i2c_write functions
bcm2835.h:  \version 1.34 Added bcm2835_i2c_write_read_rs() which writes an arbitrary number of bytes, 
bcm2835.h:  Fixed possibly incorrect reads in bcm2835_i2c_read_register_rs, patch from Eckhardt Ulrich.<br>
bcm2835.h:  Added patch from Eckhardt Ulrich that fixed problems that could cause hanging with bcm2835_i2c_read_register_rs
bcm2835.h:  bcm2835_spi_begin() and bcm2835_i2c_begin() will now return 0 if not running as root 
bcm2835.h:  Fixed a bug in bcm2835_i2c_read reported by Charles Hayward where a noisy I2C line cold cause a seg fault by
bcm2835.h:  Specifies the reason codes for the bcm2835_i2c_write and bcm2835_i2c_read functions.
bcm2835.h:      You should call bcm2835_i2c_end() when all I2C functions are complete to return the pins to
bcm2835.h:      \sa  bcm2835_i2c_end()
bcm2835.h:    extern int bcm2835_i2c_begin(void);
bcm2835.h:    extern void bcm2835_i2c_end(void);
bcm2835.h:    extern void bcm2835_i2c_setSlaveAddress(uint8_t addr);
bcm2835.h:    extern void bcm2835_i2c_setClockDivider(uint16_t divider);
bcm2835.h:      the equivalent I2C clock divider. ( see \sa bcm2835_i2c_setClockDivider)
bcm2835.h:    extern void bcm2835_i2c_set_baudrate(uint32_t baudrate);
bcm2835.h:      (as previously set by \sa bcm2835_i2c_setSlaveAddress)
bcm2835.h:    extern uint8_t bcm2835_i2c_write(const char * buf, uint32_t len);
bcm2835.h:      (as previously set by \sa bcm2835_i2c_setSlaveAddress)
bcm2835.h:    extern uint8_t bcm2835_i2c_read(char* buf, uint32_t len);
bcm2835.h:      \sa bcm2835_i2c_write
bcm2835.h:      \sa bcm2835_i2c_read
bcm2835.h:      Will read from the slave previously set by \sa bcm2835_i2c_setSlaveAddress
bcm2835.h:    extern uint8_t bcm2835_i2c_read_register_rs(char* regaddr, char* buf, uint32_t len);
bcm2835.h:      Will write to and read from the slave previously set by \sa bcm2835_i2c_setSlaveAddress
bcm2835.h:    extern uint8_t bcm2835_i2c_write_read_rs(char* cmds, uint32_t cmds_len, char* buf, uint32_t buf_len);


- Arjan



Regards,
Ron. 

--
You received this message because you are subscribed to the Google Groups "bcm2835" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bcm2835+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bcm2835/b9e308d6-ba19-4ab0-aadd-3023ca1af739%40googlegroups.com.

XperCAD

unread,
Apr 30, 2020, 8:09:56 PM4/30/20
to bcm2835
Hi,

I can see that bcm2835_i2c_begin(void) is wired to use GPIO 2 (PIN 3) and GPIO 3 (PIN 5) ALT0 for the I2C functions. Is there some way to use the other I2C channels (e.g. SDA6 and SCL6 ALT5) the Pi 4 has available?

Many Thanks,
Aaron
Hi Ron, 
To unsubscribe from this group and stop receiving emails from it, send an email to bcm...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages