Skip to content

Commit 1ffac2e

Browse files
seanybagginsPiroro-hs
authored andcommitted
about to run code gen
1 parent 817252b commit 1ffac2e

File tree

2 files changed

+57
-33
lines changed

2 files changed

+57
-33
lines changed

codegen/src/codegen/gpio.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,24 @@ fn gen_pac_list(ports: &[Port], feature: &str) {
8686

8787
fn gen_port(port: &Port, feature: &str) -> Result<()> {
8888
let pac_module = get_port_pac_module(port, feature);
89+
let port_index = match port.id {
90+
'A' => 0,
91+
'B' => 1,
92+
'C' => 2,
93+
'D' => 3,
94+
'E' => 4,
95+
'F' => 5,
96+
'G' => 6,
97+
'H' => 7,
98+
_ => unreachable!(),
99+
};
89100

90101
println!(" {{");
91102
println!(
92-
" port: ({}/{}, pac: {}),",
103+
" port: ({}/{}, {}, {}),",
93104
port.id,
94105
port.id.to_lowercase(),
106+
port_index,
95107
pac_module,
96108
);
97109
println!(" pins: [");

src/gpio.rs

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ pub enum Resistor {
198198
PullDown,
199199
}
200200

201+
/// GPIO interrupt trigger edge selection
202+
pub enum Edge {
203+
/// Rising edge of voltage
204+
Rising,
205+
/// Falling edge of voltage
206+
Falling,
207+
/// Rising and falling edge of voltage
208+
RisingFalling,
209+
}
210+
201211
/// Generic pin
202212
pub struct Pin<GPIO, INDEX, MODE> {
203213
gpio: GPIO,
@@ -586,6 +596,7 @@ macro_rules! gpio {
586596
GPIO: $GPIOX:ident,
587597
gpio: $gpiox:ident,
588598
Gpio: $Gpiox:ty,
599+
port_index: $port_index:literal,
589600
gpio_mapped: $gpioy:ident,
590601
gpio_mapped_ioen: $iopxen:ident,
591602
gpio_mapped_iorst: $iopxrst:ident,
@@ -769,7 +780,7 @@ macro_rules! gpio {
769780
pacs: $pacs:tt,
770781
ports: [$(
771782
{
772-
port: ($X:ident/$x:ident, pac: $gpioy:ident),
783+
port: ($X:ident/$x:ident, $port_index:literal, $gpioy:ident),
773784
pins: [$(
774785
$i:literal => {
775786
reset: $MODE:ty,
@@ -787,6 +798,7 @@ macro_rules! gpio {
787798
GPIO: [<GPIO $X>],
788799
gpio: [<gpio $x>],
789800
Gpio: [<Gpio $x>],
801+
port_index: $port_index,
790802
gpio_mapped: $gpioy,
791803
gpio_mapped_ioen: [<iop $x en>],
792804
gpio_mapped_iorst: [<iop $x rst>],
@@ -802,14 +814,14 @@ macro_rules! gpio {
802814
};
803815
}
804816
// auto-generated using codegen
805-
// STM32CubeMX DB release: DB.6.0.0
817+
// STM32CubeMX DB release: DB.6.0.10
806818

807819
#[cfg(feature = "gpio-f302")]
808820
gpio!({
809821
pacs: [gpioa, gpiob, gpioc],
810822
ports: [
811823
{
812-
port: (A/a, pac: gpioa),
824+
port: (A/a, 0, gpioa),
813825
pins: [
814826
0 => { reset: Input, afr: L, af: [1, 3, 7, 15] },
815827
1 => { reset: Input, afr: L, af: [0, 1, 3, 7, 9, 15] },
@@ -830,7 +842,7 @@ gpio!({
830842
],
831843
},
832844
{
833-
port: (B/b, pac: gpiob),
845+
port: (B/b, 1, gpiob),
834846
pins: [
835847
0 => { reset: Input, afr: L, af: [3, 6, 15] },
836848
1 => { reset: Input, afr: L, af: [3, 6, 8, 15] },
@@ -851,7 +863,7 @@ gpio!({
851863
],
852864
},
853865
{
854-
port: (C/c, pac: gpioc),
866+
port: (C/c, 2, gpioc),
855867
pins: [
856868
0 => { reset: Input, afr: L, af: [1, 2] },
857869
1 => { reset: Input, afr: L, af: [1, 2] },
@@ -872,13 +884,13 @@ gpio!({
872884
],
873885
},
874886
{
875-
port: (D/d, pac: gpioc),
887+
port: (D/d, 3, gpioc),
876888
pins: [
877889
2 => { reset: Input, afr: L, af: [1] },
878890
],
879891
},
880892
{
881-
port: (F/f, pac: gpioc),
893+
port: (F/f, 5, gpioc),
882894
pins: [
883895
0 => { reset: Input, afr: L, af: [4, 5, 6] },
884896
1 => { reset: Input, afr: L, af: [4, 5] },
@@ -892,7 +904,7 @@ gpio!({
892904
pacs: [gpioa, gpiob, gpioc],
893905
ports: [
894906
{
895-
port: (A/a, pac: gpioa),
907+
port: (A/a, 0, gpioa),
896908
pins: [
897909
0 => { reset: Input, afr: L, af: [1, 3, 7, 8, 9, 10, 15] },
898910
1 => { reset: Input, afr: L, af: [0, 1, 3, 7, 9, 15] },
@@ -913,7 +925,7 @@ gpio!({
913925
],
914926
},
915927
{
916-
port: (B/b, pac: gpiob),
928+
port: (B/b, 1, gpiob),
917929
pins: [
918930
0 => { reset: Input, afr: L, af: [2, 3, 4, 6, 15] },
919931
1 => { reset: Input, afr: L, af: [2, 3, 4, 6, 8, 15] },
@@ -934,7 +946,7 @@ gpio!({
934946
],
935947
},
936948
{
937-
port: (C/c, pac: gpioc),
949+
port: (C/c, 2, gpioc),
938950
pins: [
939951
0 => { reset: Input, afr: L, af: [1, 2] },
940952
1 => { reset: Input, afr: L, af: [1, 2] },
@@ -955,7 +967,7 @@ gpio!({
955967
],
956968
},
957969
{
958-
port: (D/d, pac: gpioc),
970+
port: (D/d, 3, gpioc),
959971
pins: [
960972
0 => { reset: Input, afr: L, af: [1, 7, 12] },
961973
1 => { reset: Input, afr: L, af: [1, 4, 6, 7, 12] },
@@ -976,7 +988,7 @@ gpio!({
976988
],
977989
},
978990
{
979-
port: (E/e, pac: gpioc),
991+
port: (E/e, 4, gpioc),
980992
pins: [
981993
0 => { reset: Input, afr: L, af: [1, 2, 4, 6, 7, 12] },
982994
1 => { reset: Input, afr: L, af: [1, 4, 6, 7, 12] },
@@ -997,7 +1009,7 @@ gpio!({
9971009
],
9981010
},
9991011
{
1000-
port: (F/f, pac: gpioc),
1012+
port: (F/f, 5, gpioc),
10011013
pins: [
10021014
0 => { reset: Input, afr: L, af: [1, 4, 5, 6] },
10031015
1 => { reset: Input, afr: L, af: [1, 4, 5] },
@@ -1018,7 +1030,7 @@ gpio!({
10181030
],
10191031
},
10201032
{
1021-
port: (G/g, pac: gpioc),
1033+
port: (G/g, 6, gpioc),
10221034
pins: [
10231035
0 => { reset: Input, afr: L, af: [1, 2, 12] },
10241036
1 => { reset: Input, afr: L, af: [1, 2, 12] },
@@ -1039,7 +1051,7 @@ gpio!({
10391051
],
10401052
},
10411053
{
1042-
port: (H/h, pac: gpioc),
1054+
port: (H/h, 7, gpioc),
10431055
pins: [
10441056
0 => { reset: Input, afr: L, af: [1, 2, 12] },
10451057
1 => { reset: Input, afr: L, af: [1, 2, 12] },
@@ -1054,7 +1066,7 @@ gpio!({
10541066
pacs: [gpioa, gpiob, gpioc],
10551067
ports: [
10561068
{
1057-
port: (A/a, pac: gpioa),
1069+
port: (A/a, 0, gpioa),
10581070
pins: [
10591071
0 => { reset: Input, afr: L, af: [1, 3, 7, 8, 9, 10, 15] },
10601072
1 => { reset: Input, afr: L, af: [0, 1, 3, 7, 9, 15] },
@@ -1075,7 +1087,7 @@ gpio!({
10751087
],
10761088
},
10771089
{
1078-
port: (B/b, pac: gpiob),
1090+
port: (B/b, 1, gpiob),
10791091
pins: [
10801092
0 => { reset: Input, afr: L, af: [2, 3, 4, 6, 15] },
10811093
1 => { reset: Input, afr: L, af: [2, 3, 4, 6, 8, 15] },
@@ -1096,7 +1108,7 @@ gpio!({
10961108
],
10971109
},
10981110
{
1099-
port: (C/c, pac: gpioc),
1111+
port: (C/c, 2, gpioc),
11001112
pins: [
11011113
0 => { reset: Input, afr: L, af: [1] },
11021114
1 => { reset: Input, afr: L, af: [1] },
@@ -1117,7 +1129,7 @@ gpio!({
11171129
],
11181130
},
11191131
{
1120-
port: (D/d, pac: gpioc),
1132+
port: (D/d, 3, gpioc),
11211133
pins: [
11221134
0 => { reset: Input, afr: L, af: [1, 7] },
11231135
1 => { reset: Input, afr: L, af: [1, 4, 6, 7] },
@@ -1138,7 +1150,7 @@ gpio!({
11381150
],
11391151
},
11401152
{
1141-
port: (E/e, pac: gpioc),
1153+
port: (E/e, 4, gpioc),
11421154
pins: [
11431155
0 => { reset: Input, afr: L, af: [1, 2, 4, 7] },
11441156
1 => { reset: Input, afr: L, af: [1, 4, 7] },
@@ -1159,7 +1171,7 @@ gpio!({
11591171
],
11601172
},
11611173
{
1162-
port: (F/f, pac: gpioc),
1174+
port: (F/f, 5, gpioc),
11631175
pins: [
11641176
0 => { reset: Input, afr: L, af: [4, 6] },
11651177
1 => { reset: Input, afr: L, af: [4] },
@@ -1178,7 +1190,7 @@ gpio!({
11781190
pacs: [gpioa, gpiob, gpioc],
11791191
ports: [
11801192
{
1181-
port: (A/a, pac: gpioa),
1193+
port: (A/a, 0, gpioa),
11821194
pins: [
11831195
0 => { reset: Input, afr: L, af: [1, 3, 7, 15] },
11841196
1 => { reset: Input, afr: L, af: [1, 3, 7, 9, 15] },
@@ -1199,7 +1211,7 @@ gpio!({
11991211
],
12001212
},
12011213
{
1202-
port: (B/b, pac: gpiob),
1214+
port: (B/b, 1, gpiob),
12031215
pins: [
12041216
0 => { reset: Input, afr: L, af: [2, 3, 6, 15] },
12051217
1 => { reset: Input, afr: L, af: [2, 3, 6, 8, 13, 15] },
@@ -1220,7 +1232,7 @@ gpio!({
12201232
],
12211233
},
12221234
{
1223-
port: (C/c, pac: gpioc),
1235+
port: (C/c, 2, gpioc),
12241236
pins: [
12251237
0 => { reset: Input, afr: L, af: [1, 2] },
12261238
1 => { reset: Input, afr: L, af: [1, 2] },
@@ -1241,13 +1253,13 @@ gpio!({
12411253
],
12421254
},
12431255
{
1244-
port: (D/d, pac: gpioc),
1256+
port: (D/d, 3, gpioc),
12451257
pins: [
12461258
2 => { reset: Input, afr: L, af: [1, 2] },
12471259
],
12481260
},
12491261
{
1250-
port: (F/f, pac: gpioc),
1262+
port: (F/f, 5, gpioc),
12511263
pins: [
12521264
0 => { reset: Input, afr: L, af: [6] },
12531265
1 => { reset: Input, afr: L, af: [] },
@@ -1261,7 +1273,7 @@ gpio!({
12611273
pacs: [gpioa, gpiob, gpioc, gpiod],
12621274
ports: [
12631275
{
1264-
port: (A/a, pac: gpioa),
1276+
port: (A/a, 0, gpioa),
12651277
pins: [
12661278
0 => { reset: Input, afr: L, af: [1, 2, 3, 7, 8, 11, 15] },
12671279
1 => { reset: Input, afr: L, af: [0, 1, 2, 3, 6, 7, 9, 11, 15] },
@@ -1282,7 +1294,7 @@ gpio!({
12821294
],
12831295
},
12841296
{
1285-
port: (B/b, pac: gpiob),
1297+
port: (B/b, 1, gpiob),
12861298
pins: [
12871299
0 => { reset: Input, afr: L, af: [2, 3, 5, 10, 15] },
12881300
1 => { reset: Input, afr: L, af: [2, 3, 15] },
@@ -1300,7 +1312,7 @@ gpio!({
13001312
],
13011313
},
13021314
{
1303-
port: (C/c, pac: gpioc),
1315+
port: (C/c, 2, gpioc),
13041316
pins: [
13051317
0 => { reset: Input, afr: L, af: [1, 2] },
13061318
1 => { reset: Input, afr: L, af: [1, 2] },
@@ -1321,7 +1333,7 @@ gpio!({
13211333
],
13221334
},
13231335
{
1324-
port: (D/d, pac: gpiod),
1336+
port: (D/d, 3, gpiod),
13251337
pins: [
13261338
0 => { reset: Input, afr: L, af: [1, 2, 7] },
13271339
1 => { reset: Input, afr: L, af: [1, 2, 7] },
@@ -1342,7 +1354,7 @@ gpio!({
13421354
],
13431355
},
13441356
{
1345-
port: (E/e, pac: gpioc),
1357+
port: (E/e, 4, gpioc),
13461358
pins: [
13471359
0 => { reset: Input, afr: L, af: [1, 2, 7] },
13481360
1 => { reset: Input, afr: L, af: [1, 7] },
@@ -1363,7 +1375,7 @@ gpio!({
13631375
],
13641376
},
13651377
{
1366-
port: (F/f, pac: gpioc),
1378+
port: (F/f, 5, gpioc),
13671379
pins: [
13681380
0 => { reset: Input, afr: L, af: [4] },
13691381
1 => { reset: Input, afr: L, af: [4] },

0 commit comments

Comments
 (0)