w mx
/
wmx_blink_led
core board test
main.cpp@0:4700b0ab9ad0, 2018-07-20 (annotated)
- Committer:
- xmwmx
- Date:
- Fri Jul 20 02:40:25 2018 +0000
- Revision:
- 0:4700b0ab9ad0
last commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xmwmx | 0:4700b0ab9ad0 | 1 | #include "mbed.h" |
xmwmx | 0:4700b0ab9ad0 | 2 | #define t 0.02 |
xmwmx | 0:4700b0ab9ad0 | 3 | DigitalOut a[]={PA_0,PA_1,PA_2,PA_3,PA_4,PA_5,PA_6,PA_7,PA_8,PA_9,PA_10,PA_11,PA_12,PA_13,PA_14,PA_15}; |
xmwmx | 0:4700b0ab9ad0 | 4 | DigitalOut b[]={PB_0,PB_1,PB_2,PB_3,PB_4,PB_5,PB_6,PB_7,PB_8,PB_9,PB_10,PB_11,PB_12,PB_13,PB_14,PB_15}; |
xmwmx | 0:4700b0ab9ad0 | 5 | DigitalOut c[]={PC_0,PC_1,PC_2,PC_3,PC_4,PC_5,PC_6,PC_7,PC_8,PC_9,PC_10,PC_11,PC_12,PC_13,PC_14,PC_15}; |
xmwmx | 0:4700b0ab9ad0 | 6 | DigitalOut d[]={PD_2}; |
xmwmx | 0:4700b0ab9ad0 | 7 | DigitalOut x[35]={PB_8,PC_15,PA_0,PA_1,PC_8,PA_3,PA_9,PA_10,PA_6,PA_7, PC_6,PB_1,PB_7,PB_6,PB_0,PC_11,PC_12,PD_2,PC_3, |
xmwmx | 0:4700b0ab9ad0 | 8 | PC_2,PB_4,PB_5,PB_3,PC_14,PB_9,PC_1,PC_0,PC_13,PA_4,PA_5,PA_13,PA_14,PA_2,PC_4,PC_5}; |
xmwmx | 0:4700b0ab9ad0 | 9 | |
xmwmx | 0:4700b0ab9ad0 | 10 | //注意!此程序会占用st-link所用引脚,在此程序运行时无法烧录新程序 |
xmwmx | 0:4700b0ab9ad0 | 11 | //烧录新程序:按住复位连接st-link,大概2秒后松手,烧录时先按住复位,进行复制,松开复位时才会烧录 |
xmwmx | 0:4700b0ab9ad0 | 12 | |
xmwmx | 0:4700b0ab9ad0 | 13 | int main() |
xmwmx | 0:4700b0ab9ad0 | 14 | { |
xmwmx | 0:4700b0ab9ad0 | 15 | //先亮一遍 |
xmwmx | 0:4700b0ab9ad0 | 16 | for(int i=0;i<16;i++) |
xmwmx | 0:4700b0ab9ad0 | 17 | { |
xmwmx | 0:4700b0ab9ad0 | 18 | a[i].write(1); |
xmwmx | 0:4700b0ab9ad0 | 19 | } |
xmwmx | 0:4700b0ab9ad0 | 20 | for(int i=0;i<16;i++) |
xmwmx | 0:4700b0ab9ad0 | 21 | { |
xmwmx | 0:4700b0ab9ad0 | 22 | b[i].write(1); |
xmwmx | 0:4700b0ab9ad0 | 23 | } |
xmwmx | 0:4700b0ab9ad0 | 24 | for(int i=0;i<16;i++) |
xmwmx | 0:4700b0ab9ad0 | 25 | { |
xmwmx | 0:4700b0ab9ad0 | 26 | c[i].write(1); |
xmwmx | 0:4700b0ab9ad0 | 27 | } |
xmwmx | 0:4700b0ab9ad0 | 28 | d[0].write(1); |
xmwmx | 0:4700b0ab9ad0 | 29 | wait(t); |
xmwmx | 0:4700b0ab9ad0 | 30 | while(1) |
xmwmx | 0:4700b0ab9ad0 | 31 | { |
xmwmx | 0:4700b0ab9ad0 | 32 | //流水灯 |
xmwmx | 0:4700b0ab9ad0 | 33 | // |
xmwmx | 0:4700b0ab9ad0 | 34 | for(int i=0;i<35;i++) |
xmwmx | 0:4700b0ab9ad0 | 35 | { |
xmwmx | 0:4700b0ab9ad0 | 36 | x[i].write(1); |
xmwmx | 0:4700b0ab9ad0 | 37 | wait(t); |
xmwmx | 0:4700b0ab9ad0 | 38 | } |
xmwmx | 0:4700b0ab9ad0 | 39 | for(int i=0;i<35;i++) |
xmwmx | 0:4700b0ab9ad0 | 40 | { |
xmwmx | 0:4700b0ab9ad0 | 41 | x[i].write(1); |
xmwmx | 0:4700b0ab9ad0 | 42 | wait(t); |
xmwmx | 0:4700b0ab9ad0 | 43 | } |
xmwmx | 0:4700b0ab9ad0 | 44 | for(int i=0;i<35;i++) |
xmwmx | 0:4700b0ab9ad0 | 45 | { |
xmwmx | 0:4700b0ab9ad0 | 46 | x[i].write(0); |
xmwmx | 0:4700b0ab9ad0 | 47 | wait(t); |
xmwmx | 0:4700b0ab9ad0 | 48 | } |
xmwmx | 0:4700b0ab9ad0 | 49 | // |
xmwmx | 0:4700b0ab9ad0 | 50 | wait(1); |
xmwmx | 0:4700b0ab9ad0 | 51 | for(int i=0;i<40;i++) |
xmwmx | 0:4700b0ab9ad0 | 52 | { |
xmwmx | 0:4700b0ab9ad0 | 53 | if(i<35){x[i].write(1);} |
xmwmx | 0:4700b0ab9ad0 | 54 | if(i>4&&i<40){x[i-5].write(0);} |
xmwmx | 0:4700b0ab9ad0 | 55 | wait(t); |
xmwmx | 0:4700b0ab9ad0 | 56 | } |
xmwmx | 0:4700b0ab9ad0 | 57 | |
xmwmx | 0:4700b0ab9ad0 | 58 | } |
xmwmx | 0:4700b0ab9ad0 | 59 | } |