1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

NetBSDで74HC595を制御してみた

Last updated at Posted at 2024-02-29

BCM5301XのGPIOドライバーは作りかけだったのでピン操作が出来るように書き足しました。

GPIOに接続された74HC595を制御してみます。

gpio.conf
# 74HC595
gpio0 4 set out
gpio0 6 set out
gpio0 7 set out
gpio0 8 set out

rc.confにgpio=YESを追加します。

led.sh
#!/bin/sh

#LED=01000000
LED=$1

SER=4
RCLK=6
SRCLK=7
SRCLR=8

reset() {
gpioctl -q gpio0 ${SRCLR} 0
gpioctl -q gpio0 ${SRCLR} 1
}

clock() {
gpioctl -q gpio0 ${SRCLK} 0
gpioctl -q gpio0 ${SRCLK} 1
}

reset

gpioctl -q gpio0 ${RCLK} 0

for COUNT in 1 2 3 4 5 6 7 8
do
VAL=`echo ${LED} | awk '{print substr($0,'${COUNT}',1)}'`
if [ "${VAL}" = "1" ] ; then
gpioctl -q gpio0 ${SER} 1
else
gpioctl -q gpio0 ${SER} 0
fi
clock
done

gpioctl -q gpio0 ${RCLK} 1
gpioctl -q gpio0 ${RCLK} 0

実行してみます。

# ./led.sh 00000100

猛牛さんのインジケーターが赤から白になりました。おそらく赤はOSが起動してないなどの致命的な状態を表しているのだと思いますが、猛牛さんのコーポレートカラーが赤なので、あまり緊迫感がありません。

BCM5301Xのドライバーは特殊な構成になっています。これはSOCのアーキテクチャからきているのかもしれません。ChipCommonA(cca)というデバイスにcomやgpioがぶら下がるようになっています。今の構成はccaにgpioが入っている形でconfig_found()でgpiobusを付けにいくとcomもprobeされてしまうので、ワークアラウンドを入れてあります。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?