12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "at32f403a_407.h"
- #include "mux.h"
- //
- void mux_gpio_init(void)
- {
- gpio_init_type gpio_initstructure;
-
-
- crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE);
- crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE);
- crm_periph_clock_enable(CRM_GPIOE_PERIPH_CLOCK, TRUE);
-
- // LED_COL
- // COL_1 - PD6
- // COL_2 - PD7
- // COL_3 - PB6
- // COL_4 - PB7
- gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
- gpio_initstructure.gpio_pull = GPIO_PULL_NONE;
- gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT;
- gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
- gpio_initstructure.gpio_pins = GPIO_PINS_6 | GPIO_PINS_7;
- gpio_init(GPIOB, &gpio_initstructure);
- gpio_initstructure.gpio_pins = GPIO_PINS_6 | GPIO_PINS_7;
- gpio_init(GPIOD, &gpio_initstructure);
-
- gpio_bits_reset(GPIOB, GPIO_PINS_6 | GPIO_PINS_7);
- gpio_bits_reset(GPIOD, GPIO_PINS_6 | GPIO_PINS_7);
-
- // LED_LINE
- // LINE_0 - PE3
- // LINE_1 - PE2
- // LINE_2 - PB9
- gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
- gpio_initstructure.gpio_pull = GPIO_PULL_NONE;
- gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT;
- gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
- gpio_initstructure.gpio_pins = GPIO_PINS_2 | GPIO_PINS_3;
- gpio_init(GPIOE, &gpio_initstructure);
- gpio_initstructure.gpio_pins = GPIO_PINS_9;
- gpio_init(GPIOB, &gpio_initstructure);
-
- gpio_bits_reset(GPIOE, GPIO_PINS_2 | GPIO_PINS_3);
- gpio_bits_reset(GPIOB, GPIO_PINS_9);
- }
- //
- void mux_test(void)
- {
- // INP_1
- gpio_bits_set(GPIOE, GPIO_PINS_2 | GPIO_PINS_3);
- gpio_bits_set(GPIOB, GPIO_PINS_9);
-
- gpio_bits_set(GPIOD, GPIO_PINS_6);
-
- vTaskDelay(1);
-
- // INP_2
- gpio_bits_set(GPIOE, GPIO_PINS_2);
- gpio_bits_reset(GPIOE, GPIO_PINS_3);
- gpio_bits_set(GPIOB, GPIO_PINS_9);
-
- gpio_bits_set(GPIOD, GPIO_PINS_7);
-
- vTaskDelay(1);
-
-
- }
|