05-29-2021, 01:35 PM
(This post was last modified: 05-29-2021, 01:36 PM by Tim Curtis.
Edit Reason: ETA
)
Below is i2c section of raspi-config script. It looks like its doing the following:
1. Adding "dtparam=i2c_arm=on" to /boot/config.txt
2. Adding "i2c-dev' to /etc/modules
3. Manually loading i2c-dev module via "modprobe i2c-dev"
moOde already includes "dtparam=i2c_arm=on" in /boot/config.txt so if I add "i2c-dev' to /etc/modules" as the default it will get loaded automatically at boot by Linux.
There wouldn't be a need to use raspi-config at this point correct?
What is SPI used for?
1. Adding "dtparam=i2c_arm=on" to /boot/config.txt
2. Adding "i2c-dev' to /etc/modules
3. Manually loading i2c-dev module via "modprobe i2c-dev"
moOde already includes "dtparam=i2c_arm=on" in /boot/config.txt so if I add "i2c-dev' to /etc/modules" as the default it will get loaded automatically at boot by Linux.
There wouldn't be a need to use raspi-config at this point correct?
What is SPI used for?
Code:
do_i2c() {
DEFAULT=--defaultno
if [ $(get_i2c) -eq 0 ]; then
DEFAULT=
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2
RET=$?
else
RET=$1
fi
if [ $RET -eq 0 ]; then
SETTING=on
STATUS=enabled
elif [ $RET -eq 1 ]; then
SETTING=off
STATUS=disabled
else
return $RET
fi
set_config_var dtparam=i2c_arm $SETTING $CONFIG &&
if ! [ -e $BLACKLIST ]; then
touch $BLACKLIST
fi
sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/"
sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/"
if ! grep -q "^i2c[-_]dev" /etc/modules; then
printf "i2c-dev\n" >> /etc/modules
fi
dtparam i2c_arm=$SETTING
modprobe i2c-dev
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The ARM I2C interface is $STATUS" 20 60 1
fi
}