一般情况下,beaglebone black默认启动两个cape:
1、BB-BONE-EMMC-2G
2、BB-BONELT-HDMI
我们可以通过编辑uEnv.txt的文件来决定是否启动HDMI,步骤如下
1、加载启动分区:
mkdir /mnt/sdcard
mount /dev/mmcblk0p1 /mnt/card
2、编辑uEnv.txt
vim /mnt/card/uEnv.txt
文件内容如下
##These are needed to be compliant with Angstrom's 2013.06.20 u-boot.
loadaddr=0x82000000
fdtaddr=0x88000000
rdaddr=0x88080000
initrd_high=0xffffffff
fdt_high=0xffffffff
##These are needed to be compliant with Debian 2014-05-14 u-boot.
loadximage=load mmc 0:2 ${loadaddr} /boot/vmlinuz-${uname_r}
loadxfdt=load mmc 0:2 ${fdtaddr} /boot/dtbs/${uname_r}/${fdtfile}
loadxrd=load mmc 0:2 ${rdaddr} /boot/initrd.img-${uname_r}; setenv rdsize ${filesize}
loaduEnvtxt=load mmc 0:2 ${loadaddr} /boot/uEnv.txt ; env import -t ${loadaddr} ${filesize};
check_dtb=if test -n ${dtb}; then setenv fdtfile ${dtb};fi;
loadall=run loaduEnvtxt; run check_dtb; run loadximage; run loadxrd; run loadxfdt;
mmcargs=setenv bootargs console=tty0 console=${console} ${optargs} ${cape_disable} ${cape_enable} root=/dev/
mmcblk0p2 rootfstype=${mmcrootfstype} ${cmdline}
uenvcmd=run loadall; run mmcargs; bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr};
在”mmcargs=setenv…”一行插入以下语句
optargs=quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
保存,退出
3、重启
4、开机查看slots已经变成了这样:
root@beaglebone:~# cat $SLOTS
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
eQEP 全称Enhanced Quadrature Encoder Pulse 增强型正交编码脉冲,也具有输入的特性,设置GPIO引脚模式为eQEP1A_in或eQEP1B_in,A和B是正交编码的信号输入,或者是脉冲(A)和方向(B)的信号输入。
I是Index,也就是零位信号输入,S是Strobe,也就是锁存信号。
EQEP功能模块的输入涉及4个GPIO
AM335X的PWMSS分三个部分:
Enhanced PWM Module(ePWM);
Enhanced Capture Module(eCAP);
Enhanced Quadrature Encoder Pulse Module(eQEP).
先加载PWM功能的设备树 echo am33xx_pwm > /sys/devices/bone_capemgr.9/slots
echo bone_eqep1 > /sys/devices/bone_capemgr.9/slots
然后加载eqep:beaglebone上sysfs条目的路径是
/sys/devices/ocp.*/{epwmss_addr}.epwmss/{eqep_addr}.eqep/
对于eqep 0,epwmss地址为48300000,eqep地址为48300180。
对于eqep 1,epwmss地址为48302000,eqep地址为48302180。
对于eqep 2,epwmss地址为48304000,eqep地址为48304180。
需要注意的是,Beaglebone上只有eQEP 1和eQEP 2可用,而Beaglebone Black上提供了所有这三个版本。这是因为在原始Beaglebone上,没有为eQEP0断开编码器时钟输入引脚之一。
如果使用eQEP 1和/或2,则必须在Beaglebone和Beaglebone Black上禁用HDMI,因为它们与LCD_数据线共享引脚。
1、测试的编码器为ROTARY增量式编码器,共4根线(vcc、GND、A相、B相);
2、选择P8_35 EQEP1A 和P8_33 EQEP1B引脚,分别作为A、B相,VCC接P9_08的sys_5v,GND接P9_02的GND;(P8_41 P8_42为EQEP2A 和P8_33 EQEP2B引脚)
3、编写程序读取position的数据即可
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h> #define ENCODERDATA1 "/sys/devices/ocp.3/48302000.epwmss/48302180.eqep/"
#define ENCODERDATA2 "/sys/devices/ocp.3/48304000.epwmss/48304180.eqep/"
#define MAX_LINE 100
struct encoderdata{
char encoder1[MAX_LINE];
char encoder2[MAX_LINE];
char encoder3[MAX_LINE];
}; main(int argc, char **argv)
{
struct encoderdata p1;
FILE *stream = NULL;
FILE *stream1 = NULL;
FILE *stream2 = NULL;
while(1)
{
stream = fopen(ENCODERDATA"position","r+");
if(!stream){
printf("file error \n");
return ;}
stream1 = fopen(ENCODERDATA1"position","r+");
if(!stream1){
printf("file error1 \n");
return ;}
stream2 = fopen(ENCODERDATA2"position","r+");
if(!stream2){
printf("file error2 \n");
return ;} fgets(p1.encoder1, MAX_LINE, stream);
fgets(p1.encoder2, MAX_LINE, stream1);
fgets(p1.encoder3, MAX_LINE, stream2); fclose(stream);
fclose(stream1);
fclose(stream2);
usleep(100000); printf("\nThe current encoder data is: %s, %s, %s\n",p1.encoder1,p1.encoder2,p1.encoder3);
}
}