slitaz-arm rev 182
Add raspicomm utility for RaspiComm board support
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat May 10 14:31:30 2014 +0200 (2014-05-10) |
parents | d45f922abf21 |
children | 054c80b093ca |
files | rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi rpi/raspicomm sat-rpi |
line diff
1.1 --- a/rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi Thu May 08 19:03:10 2014 +0200 1.2 +++ b/rpi/cgi-adm/plugins/rpi_gpio/rpi_gpio.cgi Sat May 10 14:31:30 2014 +0200 1.3 @@ -69,7 +69,7 @@ 1.4 <h2>Export GPIO pin</h2> 1.5 <div class="button"> 1.6 EOT 1.7 -for pin in 0 1 4 7 8 9 10 11 14 15 17 18 21 22 23 24 25 1.8 +for pin in 0 1 4 7 8 9 10 11 14 15 17 18 21 22 23 24 25 27 1.9 do 1.10 echo -n "<a href='$script?rpi_gpio=export&pin=$pin'>${pin}</a> " 1.11 done
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/rpi/raspicomm Sat May 10 14:31:30 2014 +0200 2.3 @@ -0,0 +1,109 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +# rapicomm: A tiny utility to play with RaspiComm board and SliTaz 2.7 +# It can be used to initialize the board from cmdline or at boot time. 2.8 +# RaspiComm can also be used to run a testsuite to check the board. 2.9 +# Read the official RaspiComm user manual to found the GPIO pins map. 2.10 +# the utility is compatibel with Busybox Ash and sould be usable on 2.11 +# any GNU/Linux OS. 2.12 +# 2.13 +# (C) 2014 SliTaz Raspberry Pi - BSD License 2.14 +# AUTHORS: Christophe Lincoln <pankso@slitaz.org> 2.15 +# 2.16 +. /lib/libtaz.sh 2.17 +check_root 2.18 + 2.19 +gpio="/sys/class/gpio" 2.20 + 2.21 +# 2.22 +# TODO: RS-232 serial port + RS-485 motors control 2.23 +# 2.24 + 2.25 +# RTC initialization 2.26 +init_rtc() { 2.27 + i2c="/sys/class/i2c-adapter/i2c-1" 2.28 + new_device="$i2c/new_device" 2.29 + if [ ! -d "$i2c/1-0068" ]; then 2.30 + echo -n "Configuring real time clock..." 2.31 + echo ds1307 0x68 > ${new_device}; status 2.32 + fi 2.33 + hwclock --hctosys 2.34 +} 2.35 + 2.36 +# Usage: read_pin_value pinNB 2.37 +read_pin_value() { 2.38 + local pin="$1" 2.39 + while true; do 2.40 + value=$(cat ${gpio}/gpio${pin}/value) 2.41 + usleep 500000 2.42 + if [ "$value" == "1" ]; then 2.43 + status && break 2.44 + fi 2.45 + done 2.46 +} 2.47 + 2.48 +load_modules() { 2.49 + modprobe i2c-bcm2708 2.50 + modprobe i2c-dev 2.51 +} 2.52 + 2.53 +case "$1" in 2.54 + init) 2.55 + # Initialize all componments 2.56 + colorize 35 "Initializing RaspiComm board..." 2.57 + load_modules 2.58 + 2.59 + # Real Time Clock 2.60 + init_rtc 2.61 + 2.62 + # Joystick gpio pins 2.63 + echo -n "Activing the joystick..." 2.64 + for pi in 4 22 23 24 25 2.65 + do 2.66 + echo ${pi} > ${gpio}/export 2.67 + echo in > ${gpio}/gpio${pi}/direction 2.68 + done; status 2.69 + 2.70 + # Output LEDs 2.71 + echo -n "Configuring LEDs..." 2.72 + for pi in 18 27 2.73 + do 2.74 + echo ${pi} > ${gpio}/export 2.75 + echo out > ${gpio}/gpio${pi}/direction 2.76 + done; status ;; 2.77 + 2.78 + init-rtc) 2.79 + # Init only the RTC: boot time alternative to init 2.80 + load_modules 2.81 + init_rtc ;; 2.82 + 2.83 + testsuite) 2.84 + colorize 35 "Testing RaspiComm board..." 2.85 + 2.86 + # Clock 2.87 + echo -n "Hardware clock: "; hwclock -r 2.88 + 2.89 + # LEDs 2.90 + echo -n "Turning on LED1..." 2.91 + echo 1 > ${gpio}/gpio18/value; status 2.92 + sleep 2 2.93 + echo -n "Turning on LED2..." 2.94 + echo 1 > ${gpio}/gpio27/value; status 2.95 + sleep 2 2.96 + echo -n "Turning off LED1..." 2.97 + echo 0 > ${gpio}/gpio18/value; status 2.98 + sleep 2 2.99 + echo -n "Turning off LED2..." 2.100 + echo 0 > ${gpio}/gpio27/value; status 2.101 + 2.102 + # Joystick 2.103 + echo -n "Move joystick left (towards audio) " 2.104 + read_pin_value 24 2.105 + echo -n "Move joystick top (towards usb) " 2.106 + read_pin_value 25 ;; 2.107 + 2.108 + *) 2.109 + echo "Usage: $(basename $0) [init|init-rtc|testsuite]" ;; 2.110 + 2.111 +esac 2.112 +exit 0
3.1 --- a/sat-rpi Thu May 08 19:03:10 2014 +0200 3.2 +++ b/sat-rpi Sat May 10 14:31:30 2014 +0200 3.3 @@ -175,7 +175,7 @@ 3.4 fi 3.5 3.6 # TazBerry, Piboot, Pileds, ... 3.7 - for tool in tazberry piboot pileds 3.8 + for tool in tazberry piboot pileds raspicomm 3.9 do 3.10 echo -n "Copying utility: $tool" 3.11 cp -f ${rpi}/${tool} ${rootfs}/usr/sbin