Skip to content

Commit 55b488f

Browse files
committed
update example
1 parent 56a9726 commit 55b488f

6 files changed

Lines changed: 73 additions & 13 deletions

File tree

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/08.extend/Blink_FastIO/Blink_FastIO.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Blink use fastIO macro PorPin demo
3+
34
45
fastIO macro list:(Pxx as PA2/PB/2/PC3//PD4/PE5/PF2..)
56
pinMode_Pxx(mode)

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/08.extend/Blink_MACRO/Blink_MACRO.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
2-
Blink use fastIO macro SDUINO_ASSIGN_POLARITY demo
3-
4-
Macro: SDUINO_ASSIGN_POLARITY(name[s],port[A...I],pin[0..7],polarity[0/1])
5-
exp: SDUINO_ASSIGN_POLARITY(LED,D,7,0) assign
2+
Blink use fastIO macro GPIO_ALIAS_ASSIGN_POLARITY demo
3+
4+
5+
Macro: GPIO_ALIAS_ASSIGN_POLARITY(name[s],port[A...I],pin[0..7],polarity[0/1])
6+
exp: GPIO_ALIAS_ASSIGN_POLARITY(LED,D,7,0) assign
67
*/
78

89
#define LED PD7 //LED is PD7
910

10-
SDUINO_ASSIGN_POLARITY(Led,B,3,0)/*name Led/port GPIOD/pin 7 / & On is Low */
11+
GPIO_ALIAS_ASSIGN_POLARITY(Led,B,3,0)/*name Led/port GPIOD/pin 7 / & On is Low */
1112

1213
void setup() {
13-
// initialize digital pin LED_BUILTIN as an output.
14+
// initialize digital pin LED_BUILTIN as an output.
1415
Led_OUTPUT();
15-
(GPIOA->CR2 &= ~_BV(2); GPIOA->CR1 &= ~_BV(2); GPIOA->DDR &= ~_BV(2));
16-
// pinMode(LED_BUILTIN,OUTPUT);
16+
// pinMode(LED_BUILTIN,OUTPUT);
1717
}
1818

1919
// the loop function runs over and over again forever

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/08.extend/Blink_SPL/Blink_SPL.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*
2-
Blink use fastIO macro SDUINO_ASSIGN_POLARITY demo
3-
Macro: SDUINO_ASSIGN_POLARITY(name[s],port[A...I],pin[0..7],polarity[0/1])
4-
exp: SDUINO_ASSIGN_POLARITY(LED,D,7,0) assign
2+
Blink use fastIO macro GPIO_ALIAS_ASSIGN_POLARITY demo
3+
4+
5+
Macro: GPIO_ALIAS_ASSIGN_POLARITY(name[s],port[A...I],pin[0..7],polarity[0/1])
6+
exp: GPIO_ALIAS_ASSIGN_POLARITY(LED,D,7,0) assign
57
*/
68

79
#ifdef PD7
8-
FASTIO_POLARITY(Led,D, 7, 0) /*name Led/port GPIOD/pin 7 / & On is Low */
10+
GPIO_ALIAS_ASSIGN_POLARITY(Led,D, 7, 0) /*name Led/port GPIOD/pin 7 / & On is Low */
911
#else
1012
#error #!his board hav'nt PG2 pin!
1113
#endif

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/08.extend/showPortLever/showPortLever.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
showPortLever
3+
34
*/
45

56
// the setup routine runs once when you press reset:

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/08.extend/systic_callback/systic_callback.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* systic_callback.ino: TIM4(timebase) interrupt callback demo;
33
* 2018.3.22 [email protected]
44
*/
5+
56
// the setup routine runs once when you press reset:
67
void setup() {
78
// initialize serial communication at 115200 bits per second:
@@ -12,7 +13,8 @@ void setup() {
1213
void loop() {
1314
}
1415

15-
/*TIM4 ms interrupt callback func: void systic_callback() */
16+
17+
/*TIM4 1ms interrupt callback func: void systic_callback() */
1618
uint16_t count = 0;
1719
void systic_callback(void)
1820
{
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
testPin.ino 对每个脚翻转电平,通过示波器检测波形,探测引脚
3+
for stm8s003f/103f 示例针对 stm8s003f/103f
4+
5+
by [email protected] 2018.4.2
6+
*/
7+
8+
// the setup function runs once when you press reset or power the board
9+
void setup() {
10+
// initialize digital pin LED_BUILTIN as an output.
11+
pinMode(PA1, OUTPUT); //set all pins as OUTPUT 将所有脚设定为输出
12+
pinMode(PA2, OUTPUT);
13+
pinMode(PA3, OUTPUT);
14+
pinMode(PB4, OUTPUT);
15+
pinMode(PB5, OUTPUT);
16+
pinMode(PC3, OUTPUT);
17+
pinMode(PC4, OUTPUT);
18+
pinMode(PC5, OUTPUT);
19+
pinMode(PC6, OUTPUT);
20+
pinMode(PC7, OUTPUT);
21+
pinMode(PD1, OUTPUT);
22+
pinMode(PD2, OUTPUT);
23+
pinMode(PD3, OUTPUT);
24+
pinMode(PD4, OUTPUT);
25+
pinMode(PD5, OUTPUT);
26+
pinMode(PD6, OUTPUT);
27+
}
28+
29+
void blink(uint8_t pin, uint8_t n) {
30+
for (uint8_t i = 0; i < n; i++) {
31+
digitalToggle(pin);
32+
delay(1);
33+
}
34+
}
35+
// the loop function runs over and over again forever
36+
37+
void loop() {
38+
blink(PA1, 2); //每个脚不同的翻转次数,可通过示波器检测判别
39+
blink(PA2, 4);
40+
blink(PA3, 6);
41+
blink(PB4, 8);
42+
blink(PB5, 10);
43+
blink(PC3, 12);
44+
blink(PC4, 14);
45+
blink(PC5, 16);
46+
blink(PC6, 18);
47+
blink(PC7, 20);
48+
blink(PD1, 22);
49+
blink(PD2, 24);
50+
blink(PD3, 26);
51+
blink(PD4, 28);
52+
blink(PD5, 30);
53+
blink(PD6, 32);
54+
}

0 commit comments

Comments
 (0)