你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

USB Type C 如何测试?

[复制链接]
gaosmile 发布时间:2021-1-11 11:27
背景

# M" f9 J2 E: V- \* n" W4 A
微信图片_20210111112354.png
% r" o' V" P9 S1 m: S( T
搞了这么个玩意儿,因为Typec的24个引脚焊盘都引出来了,为保证质量,要进行测量,从而保证其该通的通,该断的断。时间紧,没办法,看手上有F4的开发板,索性就用它来DIY了
% t" R2 P1 H  o2 I
需求

/ Q& C. A" i: Z! N6 ]4 x6 f7 C" z7 X
微信图片_20210111112447.png

- q. a, b9 l. a
如图所示,因24个引脚中,只用了 VCC, GND, DP, DN, CC1, CC2 7个信号,外加一个外壳,所以通路只需确认这7路即可。短路就简单了,不该短的别短的就OK了。

$ W; U2 r+ i* `8 A. y* M5 M# ?
原理
, V* t; q- L" ^- ^) t
首先将公头和母座的24个脚加外壳,一共25个引脚分别引出来接到IO口上。
* h$ c7 ]' t! M/ u) g" [: i( E
短路测试:将1个pin设为输出高电平,其余pin设为输入并依次读取,如果为高即为短路。因AB面短路的可能性极低,也懒的搞,所以A面只测A面,B面只测B面
) S" y0 W/ s) d2 e) g  h
通路测试:根据电路图,只测所有相连引脚,同样将1个pin设为输出高电平,其余设为输入并依次读取,如果为高即为通路
/ J' J: H+ f# B9 G! g' ?
硬件制作
/ `: O- T/ ]$ b4 y8 @) r- n
某宝上买了24引脚加外壳都引出来的测试板,然后焊线接到开发板的IO口上。直接上图

8 b2 \/ L% [. r8 r6 j; q1 H- \
微信图片_20210111112450.jpg

, ~' q1 A0 R: D& c5 t
看着很乱是吧,本来线就多,还用错线了,也懒的再重新焊了,就加了下转接。

" _% M2 V/ E% D  @* j: i
软件编程
$ H; c, m/ F# }
着急用, 怎么简单就怎么来了,代码直接堆,IO口接一个填一个。
+ d2 |8 {+ Q3 I0 Y- n3 P
所用IO定义

" A$ s6 q8 ?( o4 F5 Y) V/ j4 c
  • / W! H1 e. U/ b( C1 C9 U
/*************************************母头A面所用IO****************************************/uint16_t        gblpFemaleAPin[13] = {GPIO_Pin_14, GPIO_Pin_15, GPIO_Pin_11, GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_2,                                                                                                GPIO_Pin_3, GPIO_Pin_4, GPIO_Pin_5, GPIO_Pin_6, GPIO_Pin_1, GPIO_Pin_8,  GPIO_Pin_6 };GPIO_TypeDef *        gblpFemaleAPort[13] = {GPIOB, GPIOB, GPIOD, GPIOD, GPIOD, GPIOG,GPIOG,                                                                                                                                 GPIOG, GPIOG, GPIOG, GPIOD, GPIOG, GPIOC};/*************************************母头B面所用IO****************************************/        uint16_t        gblpFemaleBPin[12] = {GPIO_Pin_6, GPIO_Pin_5, GPIO_Pin_4, GPIO_Pin_15, GPIO_Pin_14, GPIO_Pin_7,                                                                                                  GPIO_Pin_15, GPIO_Pin_5, GPIO_Pin_11, GPIO_Pin_12, GPIO_Pin_13,  GPIO_Pin_14 };GPIO_TypeDef *        gblpFemaleBPort[12] = {GPIOD, GPIOD, GPIOD, GPIOD, GPIOD, GPIOD,GPIOG,                                                                                                                                 GPIOB, GPIOG, GPIOG, GPIOG, GPIOG};% v2 }; L5 b$ \3 a$ ]' Y
/*************************************公头A面所用IO****************************************/                                                                                                                                uint16_t        gblpMaleAPin[13] = {GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_8, GPIO_Pin_0, GPIO_Pin_15, GPIO_Pin_10,                                                                                                GPIO_Pin_13, GPIO_Pin_12, GPIO_Pin_11, GPIO_Pin_1, GPIO_Pin_0, GPIO_Pin_0,  GPIO_Pin_1 };GPIO_TypeDef *        gblpMaleAPort[13] = {GPIOB, GPIOB, GPIOD, GPIOG, GPIOF, GPIOD,GPIOF,                                                                                                                                 GPIOF, GPIOF, GPIOB, GPIOB, GPIOF, GPIOF};/*************************************公头B面所用IO****************************************/                uint16_t        gblpMaleBPin[12] = {GPIO_Pin_6, GPIO_Pin_5, GPIO_Pin_4, GPIO_Pin_13, GPIO_Pin_3, GPIO_Pin_2,                                                                                                  GPIO_Pin_1, GPIO_Pin_0, GPIO_Pin_5, GPIO_Pin_4, GPIO_Pin_6,  GPIO_Pin_2 };GPIO_TypeDef *        gblpMaleBPort[12] = {GPIOA, GPIOA, GPIOA, GPIOC, GPIOC, GPIOC,GPIOC,                                                                                                                                 GPIOC, GPIOF, GPIOF, GPIOE, GPIOF};                        
/ c1 B3 o( Y; t6 A0 z& c3 _
/************************************通路测试所用IO****************************************/                                uint16_t        gblpFAConnectPin[4] = {GPIO_Pin_6, GPIO_Pin_8, GPIO_Pin_5, GPIO_Pin_4};GPIO_TypeDef *        gblpFAConnectPort[4] = {GPIOC, GPIOG, GPIOG, GPIOG};uint16_t        gblpFBConnectPin[3] = {GPIO_Pin_5, GPIO_Pin_15, GPIO_Pin_7};GPIO_TypeDef *        gblpFBConnectPort[3] = {GPIOB, GPIOG, GPIOD};

' q) l- _% n' @8 d, F
短路测试部分代码
4 o( B8 g% R: p

  • 8 u3 b$ p4 C' f8 O7 F; M
for(i=0; i<12; i++)        {                GPIO_InitStructure.GPIO_Pin = gblpFemaleAPin;                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;                GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;                 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;                GPIO_Init(gblpFemaleAPort, &GPIO_InitStructure);                        GPIO_WriteBit(gblpFemaleAPort, gblpFemaleAPin, Bit_SET);for(l=i+1; l<13; l++)                {if(GPIO_ReadInputDataBit(gblpFemaleAPort[l], gblpFemaleAPin[l]))                        {printf("FA%d = FA%d    ", 12-i,12-l);if(i==0 && l==11)                                        aFlag |= 0x8000;else if(i==3 && l==8)                                        aFlag |= 0x4000;else                                        aFlag |= 0x2000;: N7 f9 I3 S2 Y* Z( r
                                aFlag++;                        }                        Delay_ms(2);                }                                GPIO_InitStructure.GPIO_Pin = gblpFemaleAPin;                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;                GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;                 GPIO_Init(gblpFemaleAPort, &GPIO_InitStructure);                        GPIO_WriteBit(gblpFemaleAPort, gblpFemaleAPin, Bit_RESET);        }        if((aFlag&0xE000) == 0xC000)        {printf("PASS\r\n");                flag |= 0x01;        }        else        {printf("Failed\r\n");        }

) ]0 H  R: [: v# s% W1 P" ]9 E6 C% ?- l
通过测试部分代码
% Q. F6 k/ w: N# V4 r

  • $ |% x, K  f7 b1 H$ D4 A5 j
GPIO_InitStructure.GPIO_Pin = gblpFAConnectPin[2];        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;         GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;        GPIO_Init(gblpFAConnectPort[2], &GPIO_InitStructure);                GPIO_WriteBit(gblpFAConnectPort[2], gblpFAConnectPin[2], Bit_SET);if(GPIO_ReadInputDataBit(gblpMaleAPort[3], gblpMaleAPin[3])  &&                 GPIO_ReadInputDataBit(gblpMaleAPort[8], gblpMaleAPin[8]) &&                 GPIO_ReadInputDataBit(gblpMaleBPort[3], gblpMaleBPin[3]) &&                GPIO_ReadInputDataBit(gblpMaleBPort[8], gblpMaleBPin[8]))        {printf("FA4 = MA4 = MA9 = MB4 = MB9    ");                aFlag |= 0x0004;        }        GPIO_InitStructure.GPIO_Pin = gblpFAConnectPin[2];        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;         GPIO_Init(gblpFAConnectPort[2], &GPIO_InitStructure);                GPIO_WriteBit(gblpFAConnectPort[2], gblpFAConnectPin[2], Bit_RESET);

- N6 l& n3 [: {" R8 X& o: m
运行结果
1 N* Z  `$ Y& z3 x+ E) Q
# N5 S- m1 G9 O2 p- M) D, D8 }
微信图片_20210111112454.png
( @) z" ~& Z/ z0 Z4 N
赞 收藏 评论0 发布时间:2021-1-11 11:27

举报

0个回答
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版