rpi-config: Add CAN_OSCILLATOR variable to set mcp2515 crystal frequency

Current configuration (16MHz) is made for the PiCAN2 board that uses 16MHz crystal. This setting allows for use of Waveshare RS485 CAN HAT that has 8MHz crystal soldered (although according to Waveshare there is also a 12MHz crystal version of the board).

Signed-off-by: Jakub Luzny <jakub@luzny.cz>
This commit is contained in:
Jakub Luzny 2020-07-16 14:39:38 +02:00 committed by Andrei Gherzan
parent 7ee3131628
commit c2cbafe78f

View File

@ -28,6 +28,8 @@ VC4DTBO ?= "vc4-kms-v3d"
GPIO_IR ?= "18" GPIO_IR ?= "18"
GPIO_IR_TX ?= "17" GPIO_IR_TX ?= "17"
CAN_OSCILLATOR ?= "16000000"
inherit deploy nopackages inherit deploy nopackages
do_deploy() { do_deploy() {
@ -201,12 +203,12 @@ do_deploy() {
# ENABLE DUAL CAN # ENABLE DUAL CAN
if [ "${ENABLE_DUAL_CAN}" = "1" ]; then if [ "${ENABLE_DUAL_CAN}" = "1" ]; then
echo "# Enable DUAL CAN" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt echo "# Enable DUAL CAN" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
echo "dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt echo "dtoverlay=mcp2515-can0,oscillator=${CAN_OSCILLATOR},interrupt=25" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
echo "dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt echo "dtoverlay=mcp2515-can1,oscillator=${CAN_OSCILLATOR},interrupt=24" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
# ENABLE CAN # ENABLE CAN
elif [ "${ENABLE_CAN}" = "1" ]; then elif [ "${ENABLE_CAN}" = "1" ]; then
echo "# Enable CAN" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt echo "# Enable CAN" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
echo "dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt echo "dtoverlay=mcp2515-can0,oscillator=${CAN_OSCILLATOR},interrupt=25" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
fi fi
# Append extra config if the user has provided any # Append extra config if the user has provided any