|
@@ -33,6 +33,68 @@ const static struct board_config _board_config = {
|
|
|
.msel_pins = _msel_pins
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+void early_fatal(int blinks)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ rcc->apb2enr |= RCC_APB2ENR_IOPBEN;
|
|
|
+ delay_ticks(10);
|
|
|
+ gpio_configure_pin(gpio_led, pin_led, GPO_pushpull(IOSPD_LOW, HIGH));
|
|
|
+ for (;;) {
|
|
|
+ for (i = 0; i < blinks; i++) {
|
|
|
+ gpio_write_pin(gpiob, 13, LOW);
|
|
|
+ early_delay_ms(150);
|
|
|
+ gpio_write_pin(gpiob, 13, HIGH);
|
|
|
+ early_delay_ms(150);
|
|
|
+ }
|
|
|
+ early_delay_ms(2000);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void identify_board_config(void)
|
|
|
+{
|
|
|
+ uint16_t low, high;
|
|
|
+ uint8_t id = 0;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ rcc->apb2enr |= RCC_APB2ENR_IOPCEN;
|
|
|
+ early_delay_us(2);
|
|
|
+
|
|
|
+
|
|
|
+ for (i = 0; i < 3; i++)
|
|
|
+ gpio_configure_pin(gpioc, 13+i, GPI_pull_down);
|
|
|
+ early_delay_us(10);
|
|
|
+ high = (gpioc->idr >> 13) & 7;
|
|
|
+
|
|
|
+
|
|
|
+ for (i = 0; i < 3; i++)
|
|
|
+ gpio_configure_pin(gpioc, 13+i, GPI_pull_up);
|
|
|
+ early_delay_us(10);
|
|
|
+ low = (~gpioc->idr >> 13) & 7;
|
|
|
+
|
|
|
+
|
|
|
+ * We build a 3^3 ID space from the resulting three-trit ID. */
|
|
|
+ for (i = 0; i < 3; i++) {
|
|
|
+ id *= 3;
|
|
|
+ switch ((high>>1&2) | (low>>2&1)) {
|
|
|
+ case 0: break;
|
|
|
+ case 1: id += 1; break;
|
|
|
+ case 2: id += 2; break;
|
|
|
+ case 3: early_fatal(1);
|
|
|
+ }
|
|
|
+ high <<= 1;
|
|
|
+ low <<= 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (id != 0)
|
|
|
+ early_fatal(2);
|
|
|
+
|
|
|
+
|
|
|
+ gw_info.hw_submodel = id;
|
|
|
+ board_config = &_board_config;
|
|
|
+}
|
|
|
+
|
|
|
static void mcu_board_init(void)
|
|
|
{
|
|
|
gpio_pull_up_pins(gpioa, 0x0101);
|
|
@@ -44,9 +106,6 @@ static void mcu_board_init(void)
|
|
|
|
|
|
|
|
|
gpio_configure_pin(gpiob, 15, GPI_floating);
|
|
|
-
|
|
|
-
|
|
|
- board_config = &_board_config;
|
|
|
}
|
|
|
|
|
|
|