#!/bin/sh
#############################################################
path="${0%/*}"
. "$path/inc/gwhw.inc"

needRoot

usage() {
	die 'gwhw flash dali [IMAGE]'
}

IMAGE="${1:-$path/bin/dali.hex}"
shift

testcmd2 mspflash
#############################################################
# Turn ON
$GPIO -es PERIF_USB_PWR

if [ 'clean' = "${IMAGE}" ]; then
	IMAGE=
else
	[ 'blink-test' = "${IMAGE}" ] && IMAGE="${path}/bin/dali_blink_test.hex"
	[ -r "${IMAGE}" ] || die "Cant read binary"
fi

mspflash --gpio-rst="${DALI_RST}" --gpio-tst="${DALI_TST}" --i2c-dev="${DALI_I2C}" --binary="${IMAGE}"
