123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #define gpio_led gpiob
- #define pin_led 13
- const static struct pin_mapping _msel_pins[] = {
- { 10, _A, 3 },
- { 12, _B, 9 },
- { 14, _A, 4 },
- { 16, _A, 1 },
- { 0, 0, 0 }
- };
- const static struct pin_mapping _user_pins[] = {
- { 2, _A, 6 },
- { 4, _A, 5 },
- { 6, _A, 7 },
- { 0, 0, 0 }
- };
- const static struct board_config _board_config = {
- .flippy = TRUE,
- .user_pins = _user_pins,
- .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;
-
- 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);
- gpio_pull_up_pins(gpiob, 0x1803);
- gpio_pull_up_pins(gpioc, 0xffff);
-
- gpio_configure_pin(gpiob, 14, GPO_pushpull(IOSPD_LOW, LOW));
-
- gpio_configure_pin(gpiob, 15, GPI_floating);
- }
|