最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
海南省| 元阳县| 洮南市| 佛山市| 元朗区| 临城县| 忻州市| 漾濞| 苗栗县| 兴海县| 巴中市| 达州市| 宁阳县| 抚松县| 昔阳县| 板桥市| 山东省| 吉木萨尔县| 淮滨县| 磐石市| 钟祥市| 会宁县| 张家界市| 宿迁市| 陆良县| 龙井市| 潜江市| 开远市| 化州市| 茂名市| 峡江县| 荥阳市| 常德市| 东山县| 遂宁市| 柳江县| 淳化县| 嘉义市| 翁源县| 龙泉市| 延安市|