Skip to content

Commit

Permalink
[mark1] Check for specific I2C address for Mark 1
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed May 2, 2024
1 parent 2651c92 commit 87e4f45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function ver() {
# This function takes an argument like "2f", this will be converted
# to "0x2f".
function i2c_get() {
if i2cdetect -y -a "$I2C_BUS" "0x$1" "0x$1" 2>>"$LOG_FILE" | grep -q "$1"; then
if i2cdetect -y -a "$I2C_BUS" "0x$1" "0x$1" 2>>"$LOG_FILE" | grep -Eq "$1|UU"; then
return 0
fi
return 1
Expand All @@ -380,7 +380,7 @@ function i2c_scan() {
for device in "${!SUPPORTED_DEVICES[@]}"; do
address="${SUPPORTED_DEVICES[$device]}"
if i2c_get "$address"; then
if [ "$device" == "reserved" ]; then
if [ "$device" == "atmega328p" ]; then
detect_mark1_device
else
DETECTED_DEVICES+=("$device")
Expand All @@ -394,7 +394,8 @@ function i2c_scan() {
# Downloads avrdude binary with libgpiod support from
# https://artifacts.smartgic.io. Once downloaded, a custom avrduderc will
# be created with the Mark 1 required pinout. This binary will only be
# downloaded when I2C UU reserved address and Raspberry Pi board are detected.
# downloaded when I2C 1a address (UU reserved address) and Raspberry Pi
# board are detected.
function setup_avrdude() {
if [ -f "$AVRDUDE_BINARY_PATH" ]; then
rm "$AVRDUDE_BINARY_PATH"
Expand Down Expand Up @@ -426,7 +427,7 @@ EOF
# This function is only triggered when a I2C reserved device is detected.
function detect_mark1_device() {
setup_avrdude
atmega328p="$(avrdude -p atmega328p -c linuxgpio -U signature:r:-:i -F 2>>"$LOG_FILE" | head -1)"
atmega328p="$(avrdude -C +"$RUN_AS_HOME"/.avrduderc -p atmega328p -c linuxgpio -U signature:r:-:i -F 2>>"$LOG_FILE" | head -1)"
if [ "$atmega328p" == "$ATMEGA328P_SIGNATURE" ] ; then
DETECTED_DEVICES+=("atmega328p")
return 0
Expand Down
2 changes: 1 addition & 1 deletion utils/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export SCENARIO_NAME="scenario.yaml"
export SCENARIO_PATH=""
declare -rA SUPPORTED_DEVICES=(
["tas5806"]="2f" #https://www.ti.com/product/TAS5806MD
["reserved"]="UU"
["atmega328p"]="1a" #Displayed as UU
)
export SUPPORTED_DEVICES
export TUI_WINDOW_HEIGHT="35"
Expand Down

0 comments on commit 87e4f45

Please sign in to comment.