Skip to content

Commit e157ca3

Browse files
committed
Merge per-board msel_pins with user_pins
This allows users to modify pins that they are not using for MSEL purposes. Additionally it allows any defined user pin to be used for MSEL purposes. Specifically, this will allow user pin 6 to be used as a fourth drive-select line on the Shugart bus.
1 parent 7251d36 commit e157ca3

9 files changed

Lines changed: 108 additions & 142 deletions

File tree

inc/board.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ struct board_config {
1515
bool_t hs_usb;
1616
bool_t flippy;
1717
const struct pin_mapping *user_pins;
18-
const struct pin_mapping *msel_pins;
1918
};

src/floppy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static void drive_deselect(void)
201201
break;
202202
}
203203

204-
rc = write_mapped_pin(board_config->msel_pins, pin, O_FALSE);
204+
rc = write_mapped_pin(board_config->user_pins, pin, O_FALSE);
205205
ASSERT(rc == ACK_OKAY);
206206

207207
unit_nr = -1;
@@ -237,7 +237,7 @@ static uint8_t drive_select(uint8_t nr)
237237
return ACK_NO_BUS;
238238
}
239239

240-
rc = write_mapped_pin(board_config->msel_pins, pin, O_TRUE);
240+
rc = write_mapped_pin(board_config->user_pins, pin, O_TRUE);
241241
if (rc != ACK_OKAY)
242242
return ACK_BAD_UNIT;
243243

@@ -276,7 +276,7 @@ static uint8_t drive_motor(uint8_t nr, bool_t on)
276276
return ACK_NO_BUS;
277277
}
278278

279-
rc = write_mapped_pin(board_config->msel_pins, pin, on ? O_TRUE : O_FALSE);
279+
rc = write_mapped_pin(board_config->user_pins, pin, on ? O_TRUE : O_FALSE);
280280
if (rc != ACK_OKAY)
281281
return ACK_BAD_UNIT;
282282

src/mcu/at32f4/board.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,14 @@ const static struct core_floppy_pins _core_floppy_pins_v4 = {
2323
.head = 5 /* PB5 */
2424
};
2525

26-
const static struct pin_mapping _msel_pins_v4[] = {
27-
{ 10, _A, 3 },
28-
{ 12, _B, 9 },
29-
{ 14, _A, 4 },
30-
{ 16, _A, 1 },
31-
{ 0, 0, 0 }
32-
};
33-
3426
const static struct pin_mapping _user_pins_v4[] = {
3527
{ 2, _A, 6 },
3628
{ 4, _A, 5 },
3729
{ 6, _A, 7 },
30+
{ 10, _A, 3 },
31+
{ 12, _B, 9 },
32+
{ 14, _A, 4 },
33+
{ 16, _A, 1 },
3834
{ 0, 0, 0 }
3935
};
4036

@@ -49,32 +45,25 @@ const static struct core_floppy_pins _core_floppy_pins_v4_slim = {
4945
.head = 9 /* PB9 */
5046
};
5147

52-
const static struct pin_mapping _msel_pins_v4_slim[] = {
48+
const static struct pin_mapping _user_pins_v4_slim[] = {
5349
{ 10, _B, 4 },
5450
{ 14, _B, 1 },
5551
{ 0, 0, 0 }
5652
};
5753

58-
const static struct pin_mapping _user_pins_v4_slim[] = {
59-
{ 0, 0, 0 }
60-
};
61-
6254
const static struct board_config _board_config[] = {
6355
[F4SM_v4] = {
6456
.hse_mhz = 8,
6557
.flippy = TRUE,
66-
.user_pins = _user_pins_v4,
67-
.msel_pins = _msel_pins_v4 },
58+
.user_pins = _user_pins_v4 },
6859
[F4SM_v4_slim] = {
6960
.hse_mhz = 16,
7061
.hse_byp = TRUE,
71-
.user_pins = _user_pins_v4_slim,
72-
.msel_pins = _msel_pins_v4_slim },
62+
.user_pins = _user_pins_v4_slim },
7363
[F4SM_v4_1] = {
7464
.hse_mhz = 8,
7565
.flippy = TRUE,
76-
.user_pins = _user_pins_v4,
77-
.msel_pins = _msel_pins_v4 },
66+
.user_pins = _user_pins_v4 }
7867
};
7968

8069
const struct core_floppy_pins *core_floppy_pins;

src/mcu/at32f4/floppy.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ static void fpec_extend_sram(bool_t extend)
8686

8787
static void floppy_mcu_init(void)
8888
{
89-
const struct pin_mapping *mpin;
9089
const struct pin_mapping *upin;
9190
unsigned int avail_kb;
9291

@@ -118,12 +117,6 @@ static void floppy_mcu_init(void)
118117
GPO_bus);
119118
}
120119

121-
/* Configure SELECT/MOTOR lines. */
122-
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++) {
123-
gpio_configure_pin(gpio_from_id(mpin->gpio_bank), mpin->gpio_pin,
124-
GPO_bus);
125-
}
126-
127120
/* Set up EXTI mapping for INDEX: PB[11:8] -> EXT[11:8] */
128121
afio->exticr3 = 0x1111;
129122
}

src/mcu/stm32f1/board.c

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,42 @@
1212
#define gpio_led gpioc
1313
#define pin_led 13
1414

15-
const static struct pin_mapping _msel_pins_std[] = {
16-
{ 10, _B, 11 },
17-
{ 14, _B, 10 },
18-
{ 0, 0, 0 }
19-
};
20-
21-
const static struct pin_mapping _msel_pins_f1_plus[] = {
22-
{ 10, _B, 11 },
23-
{ 12, _B, 0 },
24-
{ 14, _B, 10 },
25-
{ 16, _B, 1 },
26-
{ 0, 0, 0 }
27-
};
28-
2915
const static struct pin_mapping _user_pins_std[] = {
30-
{ 2, _B, 9, _OD },
31-
{ 0, 0, 0, _OD } };
16+
{ 2, _B, 9, _OD },
17+
{ 10, _B, 11, _OD },
18+
{ 14, _B, 10, _OD },
19+
{ 0, 0, 0, _OD } };
20+
3221
const static struct pin_mapping _user_pins_f1_plus[] = {
33-
{ 2, _B, 9, _PP },
34-
{ 4, _A, 3, _PP },
35-
{ 6, _A, 1, _PP },
36-
{ 0, 0, 0, _PP } };
22+
{ 2, _B, 9, _PP },
23+
{ 4, _A, 3, _PP },
24+
{ 6, _A, 1, _PP },
25+
{ 10, _B, 11, _PP },
26+
{ 12, _B, 0, _PP },
27+
{ 14, _B, 10, _PP },
28+
{ 16, _B, 1, _PP },
29+
{ 0, 0, 0, _PP } };
30+
3731
const static struct pin_mapping _user_pins_f1_plus_unbuffered[] = {
38-
{ 2, _B, 9, _OD },
39-
{ 4, _A, 3, _OD },
40-
{ 6, _A, 1, _OD },
41-
{ 0, 0, 0, _OD } };
32+
{ 2, _B, 9, _OD },
33+
{ 4, _A, 3, _OD },
34+
{ 6, _A, 1, _OD },
35+
{ 10, _B, 11, _OD },
36+
{ 12, _B, 0, _OD },
37+
{ 14, _B, 10, _OD },
38+
{ 16, _B, 1, _OD },
39+
{ 0, 0, 0, _OD } };
4240

4341
const static struct board_config _board_config[] = {
4442
[F1SM_basic] = {
4543
.flippy = FALSE,
46-
.user_pins = _user_pins_std,
47-
.msel_pins = _msel_pins_std },
44+
.user_pins = _user_pins_std },
4845
[F1SM_plus] = {
4946
.flippy = TRUE,
50-
.user_pins = _user_pins_f1_plus,
51-
.msel_pins = _msel_pins_f1_plus },
47+
.user_pins = _user_pins_f1_plus },
5248
[F1SM_plus_unbuffered] = {
5349
.flippy = TRUE,
54-
.user_pins = _user_pins_f1_plus_unbuffered,
55-
.msel_pins = _msel_pins_f1_plus }
50+
.user_pins = _user_pins_f1_plus_unbuffered }
5651
};
5752

5853
/* Blink the activity LED to indicate fatal error. */
@@ -121,15 +116,10 @@ static void mcu_board_init(void)
121116
[_B] = 0x0e27, /* PB0-2,5,9-11 */
122117
[_C] = 0xffff, /* PC0-15 */
123118
};
124-
const struct pin_mapping *mpin;
125119
const struct pin_mapping *upin;
126120

127121
identify_board_config();
128122

129-
/* MSEL pins: do not default these pins to pull-up mode. */
130-
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++)
131-
pu[mpin->gpio_bank] &= ~(1u << mpin->gpio_pin);
132-
133123
/* User pins: do not default these pins to pull-up mode. */
134124
for (upin = board_config->user_pins; upin->pin_id != 0; upin++)
135125
pu[upin->gpio_bank] &= ~(1u << upin->gpio_pin);

src/mcu/stm32f1/floppy.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static unsigned int U_BUF_SZ;
5959

6060
static void floppy_mcu_init(void)
6161
{
62-
const struct pin_mapping *mpin;
6362
const struct pin_mapping *upin;
6463
unsigned int avail_kb;
6564

@@ -100,12 +99,6 @@ static void floppy_mcu_init(void)
10099
GPO_bus = upin->push_pull ? GPO_bus_pp : GPO_bus_od;
101100
AFO_bus = upin->push_pull ? AFO_bus_pp : AFO_bus_od;
102101

103-
/* Configure SELECT/MOTOR lines. */
104-
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++) {
105-
gpio_configure_pin(gpio_from_id(mpin->gpio_bank), mpin->gpio_pin,
106-
GPO_bus);
107-
}
108-
109102
/* Set up EXTI mapping for INDEX: PB[15:0] -> EXT[15:0] */
110103
afio->exticr1 = afio->exticr2 = afio->exticr3 = afio->exticr4 = 0x1111;
111104
}

0 commit comments

Comments
 (0)