导航

    全志在线开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 话题
    • 在线文档
    • 社区主页
    1. 主页
    2. mstempin
    3. 最佳
    M
    • 资料
    • 关注 2
    • 粉丝 0
    • 我的积分 920
    • 主题 1
    • 帖子 21
    • 最佳 1
    • 群组 0

    mstempin 发布的最佳帖子

    • 回复: 全志引脚计算器 AllwinnerPin 小工具发布

      Here is a Shell version, no dependency:
      这是一个 Shell 版本,没有依赖关系:

      #!/bin/bash
      
      # Convert argument to uppercase
      arg=${1^^}
      
      if [[ "$arg" =~ ^[0-9]+$ ]]; then
      
          # Argument is numeric, each port is 32-bit wide
          let port_base=$arg/32
      
          # Convert port number to ASCII code ('A' is 65)
          let port=$port_base+65
          let bit=$arg%32
          printf "P%b%d\n" $(printf '\x%x\n' $port 2>/dev/null) $bit
      elif [[ "$arg" =~ ^P[A-Z][0-9]+$ ]]; then
      
          # Argument is a pin name, convert port name to number ('A' is 65)
          let port=$(printf "%d" "'${arg:1:1}")-65
      
          # Each port is 32-bit wide
          let port_base=$port*32
          let gpio=port_base+${arg:2}
          echo $gpio
      else
          >&2 echo "wrong argument"
      fi
      
      
      发布在 其它全志芯片讨论区
      M
      mstempin
    • 1 / 1