无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

AT32學習筆記-GPIO.md

2022-11-27 09:14 作者:繁花cloud  | 我要投稿

GPIO

初始化

```c

// 創(chuàng)建GPIO INIT參數(shù)結(jié)構(gòu)體

gpio_init_type gpio_init_struct;


// 開啟GPIO外設時鐘

crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);


/* 設置結(jié)構(gòu)體默認的值 */

gpio_default_para_init(&gpio_init_struct);


/* 配置IO口 */

// 驅(qū)動強度,選強

gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;

// GPIO輸出模式 GPIO_OUTPUT_PUSH_PULL 推挽輸出 GPIO_OUTPUT_OPEN_DRAIN 開漏輸出

gpio_init_struct.gpio_out_type? = GPIO_OUTPUT_PUSH_PULL;

// GPIO模式 GPIO_MODE_INPUT 輸入 GPIO_MODE_OUTPUT 輸出 GPIO_MODE_MUX IOMUX,至片上外設

// GPIO_MODE_ANALOG 模擬輸入/輸出

gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;

// GPIO引腳 GPIO_PINS_0-15 GPIO_PINS_ALL,支持|操作,例如 GPIO_PINS_0 | GPIO_PINS_1

gpio_init_struct.gpio_pins = GPIO_PINS_1;

// 內(nèi)部上拉,一般用于輸入的時候

gpio_init_struct.gpio_pull = GPIO_PULL_NONE;

// 初始化

gpio_init(GPIOA, &gpio_init_struct);

```

設置高低電平

置1

```c

/**

? * @brief? set the selected data port bits.

? * @param? gpio_x: to select the gpio peripheral.

? *? ? ? ? ?this parameter can be one of the following values:

? *? ? ? ? ?GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.

? * @param? pins: gpio pin number

? *? ? ? ? ?parameter can be any combination of gpio_pin_x, gpio_pin_x as following values:

? *? ? ? ? ?- GPIO_PINS_0

? *? ? ? ? ?- GPIO_PINS_1

? *? ? ? ? ?- GPIO_PINS_2

? *? ? ? ? ?- GPIO_PINS_3

? *? ? ? ? ?- GPIO_PINS_4

? *? ? ? ? ?- GPIO_PINS_5

? *? ? ? ? ?- GPIO_PINS_6

? *? ? ? ? ?- GPIO_PINS_7

? *? ? ? ? ?- GPIO_PINS_8

? *? ? ? ? ?- GPIO_PINS_9

? *? ? ? ? ?- GPIO_PINS_10

? *? ? ? ? ?- GPIO_PINS_11

? *? ? ? ? ?- GPIO_PINS_12

? *? ? ? ? ?- GPIO_PINS_13

? *? ? ? ? ?- GPIO_PINS_14

? *? ? ? ? ?- GPIO_PINS_15

? *? ? ? ? ?- GPIO_PINS_ALL

? * @retval none

? */

void gpio_bits_set(gpio_type *gpio_x, uint16_t pins);

```

置0

```c

/**

? * @brief? clear the selected data port bits.

? * @param? gpio_x: to select the gpio peripheral.

? *? ? ? ? ?this parameter can be one of the following values:

? *? ? ? ? ?GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.

? * @param? pins: gpio pin number

? *? ? ? ? ?parameter can be any combination of gpio_pin_x, gpio_pin_x as following values:

? *? ? ? ? ?- GPIO_PINS_0

? *? ? ? ? ?- GPIO_PINS_1

? *? ? ? ? ?- GPIO_PINS_2

? *? ? ? ? ?- GPIO_PINS_3

? *? ? ? ? ?- GPIO_PINS_4

? *? ? ? ? ?- GPIO_PINS_5

? *? ? ? ? ?- GPIO_PINS_6

? *? ? ? ? ?- GPIO_PINS_7

? *? ? ? ? ?- GPIO_PINS_8

? *? ? ? ? ?- GPIO_PINS_9

? *? ? ? ? ?- GPIO_PINS_10

? *? ? ? ? ?- GPIO_PINS_11

? *? ? ? ? ?- GPIO_PINS_12

? *? ? ? ? ?- GPIO_PINS_13

? *? ? ? ? ?- GPIO_PINS_14

? *? ? ? ? ?- GPIO_PINS_15

? *? ? ? ? ?- GPIO_PINS_ALL

? * @retval none

? */

void gpio_bits_reset(gpio_type *gpio_x, uint16_t pins);

```

設置,傳入0 1

```c

/**

? * @brief? set or clear the selected data port bit.

? * @param? gpio_x: to select the gpio peripheral.

? *? ? ? ? ?this parameter can be one of the following values:

? *? ? ? ? ?GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.

? * @param? pins: gpio pin number

? *? ? ? ? ?parameter can be any combination of gpio_pin_x, gpio_pin_x as following values:

? *? ? ? ? ?- GPIO_PINS_0

? *? ? ? ? ?- GPIO_PINS_1

? *? ? ? ? ?- GPIO_PINS_2

? *? ? ? ? ?- GPIO_PINS_3

? *? ? ? ? ?- GPIO_PINS_4

? *? ? ? ? ?- GPIO_PINS_5

? *? ? ? ? ?- GPIO_PINS_6

? *? ? ? ? ?- GPIO_PINS_7

? *? ? ? ? ?- GPIO_PINS_8

? *? ? ? ? ?- GPIO_PINS_9

? *? ? ? ? ?- GPIO_PINS_10

? *? ? ? ? ?- GPIO_PINS_11

? *? ? ? ? ?- GPIO_PINS_12

? *? ? ? ? ?- GPIO_PINS_13

? *? ? ? ? ?- GPIO_PINS_14

? *? ? ? ? ?- GPIO_PINS_15

? *? ? ? ? ?- GPIO_PINS_ALL

? * @param? bit_state: specifies the value to be written to the selected bit (TRUE or FALSE).

? * @retval none

? */

void gpio_bits_write(gpio_type *gpio_x, uint16_t pins, confirm_state bit_state);

```

位段操作

同時對某一個GPIO做操作,port_value按照位傳入

```c

/**

? * @brief? write data to the specified gpio data port.

? * @param? gpio_x: to select the gpio peripheral.

? *? ? ? ? ?this parameter can be one of the following values:

? *? ? ? ? ?GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.

? * @param? port_value: specifies the value to be written to the port output data register.

? * @retval none

? */

void gpio_port_write(gpio_type *gpio_x, uint16_t port_value);

```

## 重置GPIO寄存器

初始化的時候,如果有需求可以重置??

```c

/**

? * @brief? reset the gpio register

? * @param? gpio_x: to select the gpio peripheral.

? *? ? ? ? ?this parameter can be one of the following values:

? *? ? ? ? ?GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.

? * @retval none

? */

void gpio_reset(gpio_type *gpio_x);

```


點燈

```c

gpio_init_type gpio_init_struct;


/* enable the led clock */

crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);


/* set default parameter */

gpio_default_para_init(&gpio_init_struct);


/* configure the led gpio */

gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;

gpio_init_struct.gpio_out_type? = GPIO_OUTPUT_PUSH_PULL;

gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;

gpio_init_struct.gpio_pins = GPIO_PINS_1;

gpio_init_struct.gpio_pull = GPIO_PULL_NONE;

gpio_init(GPIOA, &gpio_init_struct);


i = !i;

if(i){

? ? gpio_bits_set(GPIOA, GPIO_PINS_1);

}else{

? ? gpio_bits_reset(GPIOA, GPIO_PINS_1);

}

```


AT32學習筆記-GPIO.md的評論 (共 條)

分享到微博請遵守國家法律
株洲县| 班戈县| 鹿邑县| 宁海县| 尼勒克县| 葫芦岛市| 扎兰屯市| 深泽县| 林西县| 永善县| 芜湖市| 神木县| 凤山市| 乌兰浩特市| 兰西县| 海宁市| 富裕县| 富民县| 榕江县| 普兰店市| 曲水县| 荣成市| 霍山县| 黄骅市| 松潘县| 长宁区| 九寨沟县| 陆川县| 庄浪县| 枣庄市| 汉阴县| 靖西县| 平南县| 新野县| 义马市| 田林县| 抚顺市| 乐亭县| 万全县| 当阳市| 德江县|