mirror of
https://github.com/keirf/greaseweazle-firmware.git
synced 2026-07-10 15:13:25 -07:00
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.
This commit is contained in:
@@ -15,5 +15,4 @@ struct board_config {
|
||||
bool_t hs_usb;
|
||||
bool_t flippy;
|
||||
const struct pin_mapping *user_pins;
|
||||
const struct pin_mapping *msel_pins;
|
||||
};
|
||||
|
||||
+3
-3
@@ -201,7 +201,7 @@ static void drive_deselect(void)
|
||||
break;
|
||||
}
|
||||
|
||||
rc = write_mapped_pin(board_config->msel_pins, pin, O_FALSE);
|
||||
rc = write_mapped_pin(board_config->user_pins, pin, O_FALSE);
|
||||
ASSERT(rc == ACK_OKAY);
|
||||
|
||||
unit_nr = -1;
|
||||
@@ -237,7 +237,7 @@ static uint8_t drive_select(uint8_t nr)
|
||||
return ACK_NO_BUS;
|
||||
}
|
||||
|
||||
rc = write_mapped_pin(board_config->msel_pins, pin, O_TRUE);
|
||||
rc = write_mapped_pin(board_config->user_pins, pin, O_TRUE);
|
||||
if (rc != ACK_OKAY)
|
||||
return ACK_BAD_UNIT;
|
||||
|
||||
@@ -276,7 +276,7 @@ static uint8_t drive_motor(uint8_t nr, bool_t on)
|
||||
return ACK_NO_BUS;
|
||||
}
|
||||
|
||||
rc = write_mapped_pin(board_config->msel_pins, pin, on ? O_TRUE : O_FALSE);
|
||||
rc = write_mapped_pin(board_config->user_pins, pin, on ? O_TRUE : O_FALSE);
|
||||
if (rc != ACK_OKAY)
|
||||
return ACK_BAD_UNIT;
|
||||
|
||||
|
||||
+8
-19
@@ -23,18 +23,14 @@ const static struct core_floppy_pins _core_floppy_pins_v4 = {
|
||||
.head = 5 /* PB5 */
|
||||
};
|
||||
|
||||
const static struct pin_mapping _msel_pins_v4[] = {
|
||||
{ 10, _A, 3 },
|
||||
{ 12, _B, 9 },
|
||||
{ 14, _A, 4 },
|
||||
{ 16, _A, 1 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const static struct pin_mapping _user_pins_v4[] = {
|
||||
{ 2, _A, 6 },
|
||||
{ 4, _A, 5 },
|
||||
{ 6, _A, 7 },
|
||||
{ 10, _A, 3 },
|
||||
{ 12, _B, 9 },
|
||||
{ 14, _A, 4 },
|
||||
{ 16, _A, 1 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -49,32 +45,25 @@ const static struct core_floppy_pins _core_floppy_pins_v4_slim = {
|
||||
.head = 9 /* PB9 */
|
||||
};
|
||||
|
||||
const static struct pin_mapping _msel_pins_v4_slim[] = {
|
||||
const static struct pin_mapping _user_pins_v4_slim[] = {
|
||||
{ 10, _B, 4 },
|
||||
{ 14, _B, 1 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const static struct pin_mapping _user_pins_v4_slim[] = {
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const static struct board_config _board_config[] = {
|
||||
[F4SM_v4] = {
|
||||
.hse_mhz = 8,
|
||||
.flippy = TRUE,
|
||||
.user_pins = _user_pins_v4,
|
||||
.msel_pins = _msel_pins_v4 },
|
||||
.user_pins = _user_pins_v4 },
|
||||
[F4SM_v4_slim] = {
|
||||
.hse_mhz = 16,
|
||||
.hse_byp = TRUE,
|
||||
.user_pins = _user_pins_v4_slim,
|
||||
.msel_pins = _msel_pins_v4_slim },
|
||||
.user_pins = _user_pins_v4_slim },
|
||||
[F4SM_v4_1] = {
|
||||
.hse_mhz = 8,
|
||||
.flippy = TRUE,
|
||||
.user_pins = _user_pins_v4,
|
||||
.msel_pins = _msel_pins_v4 },
|
||||
.user_pins = _user_pins_v4 }
|
||||
};
|
||||
|
||||
const struct core_floppy_pins *core_floppy_pins;
|
||||
|
||||
@@ -86,7 +86,6 @@ static void fpec_extend_sram(bool_t extend)
|
||||
|
||||
static void floppy_mcu_init(void)
|
||||
{
|
||||
const struct pin_mapping *mpin;
|
||||
const struct pin_mapping *upin;
|
||||
unsigned int avail_kb;
|
||||
|
||||
@@ -118,12 +117,6 @@ static void floppy_mcu_init(void)
|
||||
GPO_bus);
|
||||
}
|
||||
|
||||
/* Configure SELECT/MOTOR lines. */
|
||||
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++) {
|
||||
gpio_configure_pin(gpio_from_id(mpin->gpio_bank), mpin->gpio_pin,
|
||||
GPO_bus);
|
||||
}
|
||||
|
||||
/* Set up EXTI mapping for INDEX: PB[11:8] -> EXT[11:8] */
|
||||
afio->exticr3 = 0x1111;
|
||||
}
|
||||
|
||||
+25
-35
@@ -12,47 +12,42 @@
|
||||
#define gpio_led gpioc
|
||||
#define pin_led 13
|
||||
|
||||
const static struct pin_mapping _msel_pins_std[] = {
|
||||
{ 10, _B, 11 },
|
||||
{ 14, _B, 10 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const static struct pin_mapping _msel_pins_f1_plus[] = {
|
||||
{ 10, _B, 11 },
|
||||
{ 12, _B, 0 },
|
||||
{ 14, _B, 10 },
|
||||
{ 16, _B, 1 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const static struct pin_mapping _user_pins_std[] = {
|
||||
{ 2, _B, 9, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
{ 2, _B, 9, _OD },
|
||||
{ 10, _B, 11, _OD },
|
||||
{ 14, _B, 10, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
|
||||
const static struct pin_mapping _user_pins_f1_plus[] = {
|
||||
{ 2, _B, 9, _PP },
|
||||
{ 4, _A, 3, _PP },
|
||||
{ 6, _A, 1, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
{ 2, _B, 9, _PP },
|
||||
{ 4, _A, 3, _PP },
|
||||
{ 6, _A, 1, _PP },
|
||||
{ 10, _B, 11, _PP },
|
||||
{ 12, _B, 0, _PP },
|
||||
{ 14, _B, 10, _PP },
|
||||
{ 16, _B, 1, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
|
||||
const static struct pin_mapping _user_pins_f1_plus_unbuffered[] = {
|
||||
{ 2, _B, 9, _OD },
|
||||
{ 4, _A, 3, _OD },
|
||||
{ 6, _A, 1, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
{ 2, _B, 9, _OD },
|
||||
{ 4, _A, 3, _OD },
|
||||
{ 6, _A, 1, _OD },
|
||||
{ 10, _B, 11, _OD },
|
||||
{ 12, _B, 0, _OD },
|
||||
{ 14, _B, 10, _OD },
|
||||
{ 16, _B, 1, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
|
||||
const static struct board_config _board_config[] = {
|
||||
[F1SM_basic] = {
|
||||
.flippy = FALSE,
|
||||
.user_pins = _user_pins_std,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_std },
|
||||
[F1SM_plus] = {
|
||||
.flippy = TRUE,
|
||||
.user_pins = _user_pins_f1_plus,
|
||||
.msel_pins = _msel_pins_f1_plus },
|
||||
.user_pins = _user_pins_f1_plus },
|
||||
[F1SM_plus_unbuffered] = {
|
||||
.flippy = TRUE,
|
||||
.user_pins = _user_pins_f1_plus_unbuffered,
|
||||
.msel_pins = _msel_pins_f1_plus }
|
||||
.user_pins = _user_pins_f1_plus_unbuffered }
|
||||
};
|
||||
|
||||
/* Blink the activity LED to indicate fatal error. */
|
||||
@@ -121,15 +116,10 @@ static void mcu_board_init(void)
|
||||
[_B] = 0x0e27, /* PB0-2,5,9-11 */
|
||||
[_C] = 0xffff, /* PC0-15 */
|
||||
};
|
||||
const struct pin_mapping *mpin;
|
||||
const struct pin_mapping *upin;
|
||||
|
||||
identify_board_config();
|
||||
|
||||
/* MSEL pins: do not default these pins to pull-up mode. */
|
||||
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++)
|
||||
pu[mpin->gpio_bank] &= ~(1u << mpin->gpio_pin);
|
||||
|
||||
/* User pins: do not default these pins to pull-up mode. */
|
||||
for (upin = board_config->user_pins; upin->pin_id != 0; upin++)
|
||||
pu[upin->gpio_bank] &= ~(1u << upin->gpio_pin);
|
||||
|
||||
@@ -59,7 +59,6 @@ static unsigned int U_BUF_SZ;
|
||||
|
||||
static void floppy_mcu_init(void)
|
||||
{
|
||||
const struct pin_mapping *mpin;
|
||||
const struct pin_mapping *upin;
|
||||
unsigned int avail_kb;
|
||||
|
||||
@@ -100,12 +99,6 @@ static void floppy_mcu_init(void)
|
||||
GPO_bus = upin->push_pull ? GPO_bus_pp : GPO_bus_od;
|
||||
AFO_bus = upin->push_pull ? AFO_bus_pp : AFO_bus_od;
|
||||
|
||||
/* Configure SELECT/MOTOR lines. */
|
||||
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++) {
|
||||
gpio_configure_pin(gpio_from_id(mpin->gpio_bank), mpin->gpio_pin,
|
||||
GPO_bus);
|
||||
}
|
||||
|
||||
/* Set up EXTI mapping for INDEX: PB[15:0] -> EXT[15:0] */
|
||||
afio->exticr1 = afio->exticr2 = afio->exticr3 = afio->exticr4 = 0x1111;
|
||||
}
|
||||
|
||||
+72
-61
@@ -12,93 +12,109 @@
|
||||
#define gpio_led gpiob
|
||||
#define pin_led 13
|
||||
|
||||
const static struct pin_mapping _msel_pins_std[] = {
|
||||
{ 10, _B, 1 },
|
||||
{ 12, _B, 0 },
|
||||
{ 14, _B, 11 },
|
||||
{ 16, _B, 10 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const static struct pin_mapping _msel_pins_f7_slim[] = {
|
||||
{ 10, _B, 1 },
|
||||
{ 14, _B, 11 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_v1[] = {
|
||||
{ 2, _B, 12, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
{ 2, _B, 12, _OD },
|
||||
{ 10, _B, 1, _OD },
|
||||
{ 12, _B, 0, _OD },
|
||||
{ 14, _B, 11, _OD },
|
||||
{ 16, _B, 10, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_ant_goffart_f7_plus_v1[] = {
|
||||
{ 2, _B, 12, _OD }, /* board bug: B12 isn't buffered */
|
||||
{ 4, _C, 6, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
{ 2, _B, 12, _OD }, /* board bug: B12 isn't buffered */
|
||||
{ 4, _C, 6, _PP },
|
||||
{ 10, _B, 1, _PP },
|
||||
{ 12, _B, 0, _PP },
|
||||
{ 14, _B, 11, _PP },
|
||||
{ 16, _B, 10, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_lightning[] = {
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _E, 15, _PP },
|
||||
{ 6, _E, 14, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _E, 15, _PP },
|
||||
{ 6, _E, 14, _PP },
|
||||
{ 10, _B, 1, _PP },
|
||||
{ 12, _B, 0, _PP },
|
||||
{ 14, _B, 11, _PP },
|
||||
{ 16, _B, 10, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_v2[] = {
|
||||
{ 2, _B, 12, _OD },
|
||||
{ 4, _C, 8, _OD },
|
||||
{ 6, _C, 7, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
{ 2, _B, 12, _OD },
|
||||
{ 4, _C, 8, _OD },
|
||||
{ 6, _C, 7, _OD },
|
||||
{ 10, _B, 1, _OD },
|
||||
{ 12, _B, 0, _OD },
|
||||
{ 14, _B, 11, _OD },
|
||||
{ 16, _B, 10, _OD },
|
||||
{ 0, 0, 0, _OD } };
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_ant_goffart_f7_plus_v2[] = {
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _C, 8, _PP },
|
||||
{ 6, _C, 7, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _C, 8, _PP },
|
||||
{ 6, _C, 7, _PP },
|
||||
{ 10, _B, 1, _PP },
|
||||
{ 12, _B, 0, _PP },
|
||||
{ 14, _B, 11, _PP },
|
||||
{ 16, _B, 10, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_lightning_plus[] = {
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _E, 15, _PP },
|
||||
{ 6, _E, 14, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _E, 15, _PP },
|
||||
{ 6, _E, 14, _PP },
|
||||
{ 10, _B, 1, _PP },
|
||||
{ 12, _B, 0, _PP },
|
||||
{ 14, _B, 11, _PP },
|
||||
{ 16, _B, 10, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_slim[] = {
|
||||
{ 0, 0, 0, _PP } };
|
||||
{ 10, _B, 1, _PP },
|
||||
{ 14, _B, 11, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
|
||||
const static struct pin_mapping _user_pins_F7SM_v3[] = {
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _C, 8, _PP },
|
||||
{ 6, _C, 7, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
{ 2, _B, 12, _PP },
|
||||
{ 4, _C, 8, _PP },
|
||||
{ 6, _C, 7, _PP },
|
||||
{ 10, _B, 1, _PP },
|
||||
{ 12, _B, 0, _PP },
|
||||
{ 14, _B, 11, _PP },
|
||||
{ 16, _B, 10, _PP },
|
||||
{ 0, 0, 0, _PP } };
|
||||
|
||||
const static struct board_config _board_config[] = {
|
||||
[F7SM_v1] = {
|
||||
.hse_mhz = 8,
|
||||
.user_pins = _user_pins_F7SM_v1,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_F7SM_v1 },
|
||||
[F7SM_ant_goffart_f7_plus_v1] = {
|
||||
.hse_mhz = 8,
|
||||
.user_pins = _user_pins_F7SM_ant_goffart_f7_plus_v1,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_F7SM_ant_goffart_f7_plus_v1 },
|
||||
[F7SM_lightning] = {
|
||||
.hse_mhz = 16,
|
||||
.hs_usb = TRUE,
|
||||
.user_pins = _user_pins_F7SM_lightning,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_F7SM_lightning },
|
||||
[F7SM_v2] = {
|
||||
.hse_mhz = 8,
|
||||
.user_pins = _user_pins_F7SM_v2,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_F7SM_v2 },
|
||||
[F7SM_ant_goffart_f7_plus_v2] = {
|
||||
.hse_mhz = 8,
|
||||
.user_pins = _user_pins_F7SM_ant_goffart_f7_plus_v2,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_F7SM_ant_goffart_f7_plus_v2 },
|
||||
[F7SM_lightning_plus] = {
|
||||
.hse_mhz = 16,
|
||||
.hse_byp = TRUE,
|
||||
.hs_usb = TRUE,
|
||||
.flippy = TRUE,
|
||||
.user_pins = _user_pins_F7SM_lightning_plus,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_F7SM_lightning_plus },
|
||||
[F7SM_slim] = {
|
||||
.hse_mhz = 16,
|
||||
.hse_byp = TRUE,
|
||||
.user_pins = _user_pins_F7SM_slim,
|
||||
.msel_pins = _msel_pins_f7_slim },
|
||||
.user_pins = _user_pins_F7SM_slim },
|
||||
[F7SM_v3] = {
|
||||
.hse_mhz = 8,
|
||||
.flippy = TRUE,
|
||||
.user_pins = _user_pins_F7SM_v3,
|
||||
.msel_pins = _msel_pins_std },
|
||||
.user_pins = _user_pins_F7SM_v3 }
|
||||
};
|
||||
|
||||
/* Blink the activity LED to indicate fatal error. */
|
||||
@@ -179,7 +195,6 @@ static void mcu_board_init(void)
|
||||
[_I] = 0xffff, /* PI0-15 */
|
||||
};
|
||||
uint32_t ahb1enr = rcc->ahb1enr;
|
||||
const struct pin_mapping *mpin;
|
||||
const struct pin_mapping *upin;
|
||||
|
||||
/* Enable all GPIO bank register clocks to configure unused pins. */
|
||||
@@ -194,10 +209,6 @@ static void mcu_board_init(void)
|
||||
RCC_AHB1ENR_GPIOIEN);
|
||||
peripheral_clock_delay();
|
||||
|
||||
/* MSEL pins: do not default these pins to pull-up mode. */
|
||||
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++)
|
||||
pu[mpin->gpio_bank] &= ~(1u << mpin->gpio_pin);
|
||||
|
||||
/* Keep clock enabled for all banks containing user-modifiable pins.
|
||||
* Also do not default these pins to pull-up mode. */
|
||||
for (upin = board_config->user_pins; upin->pin_id != 0; upin++) {
|
||||
|
||||
@@ -59,7 +59,6 @@ void IRQ_8(void) __attribute__((alias("IRQ_INDEX_changed"))); /* EXTI2 */
|
||||
|
||||
static void floppy_mcu_init(void)
|
||||
{
|
||||
const struct pin_mapping *mpin;
|
||||
const struct pin_mapping *upin;
|
||||
|
||||
/* Enable clock for Timer 2. */
|
||||
@@ -81,12 +80,6 @@ static void floppy_mcu_init(void)
|
||||
GPO_bus = upin->push_pull ? GPO_bus_pp : GPO_bus_od;
|
||||
AFO_bus = upin->push_pull ? AFO_bus_pp : AFO_bus_od;
|
||||
|
||||
/* Configure SELECT/MOTOR lines. */
|
||||
for (mpin = board_config->msel_pins; mpin->pin_id != 0; mpin++) {
|
||||
gpio_configure_pin(gpio_from_id(mpin->gpio_bank), mpin->gpio_pin,
|
||||
GPO_bus);
|
||||
}
|
||||
|
||||
/* Set up EXTI mapping for INDEX: PB[3:0] -> EXT[3:0] */
|
||||
syscfg->exticr1 = 0x1111;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ static void testmode_set_pin(unsigned int pin, bool_t level)
|
||||
{
|
||||
int rc;
|
||||
rc = write_mapped_pin(testmode_out_pins, pin, level);
|
||||
if (rc != ACK_OKAY)
|
||||
rc = write_mapped_pin(board_config->msel_pins, pin, level);
|
||||
if (rc != ACK_OKAY)
|
||||
rc = write_mapped_pin(board_config->user_pins, pin, level);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user