/*** * @Author: mbw * @Date: 2024-08-21 09:04:32 * @LastEditors: mbw && 1600520629@qq.com * @LastEditTime: 2024-09-18 10:24:35 * @FilePath: \USART1_Interrupt - RT-Thread\drivers\inc\drv_gpio.h * @Description: * @ * @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. */ #ifndef __DRV_GPIO_H__ #define __DRV_GPIO_H__ #include #include "ciu32l051.h" #ifdef RT_USING_PIN #define __CIU_PORT(port) (GPIO##port##_BASE) #define GET_PIN(port, pin) (rt_base_t)((16 * (((rt_base_t)__CIU_PORT(port) - (rt_base_t)GPIOA_BASE) / (0x0400UL))) + pin) #define __CIU32_PIN(index, gpio, gpio_index) {index, GPIO##gpio, GPIO_PIN_##gpio_index} #define SENSOR_POWER_PIN GET_PIN(A, 7) /*uart1*/ #define UART1_TX_GPIO_PIN GPIO_PIN_11 #define UART1_TX_GPIO_PORT GPIOA #define UART1_RX_GPIO_PIN GPIO_PIN_12 #define UART1_RX_GPIO_PORT GPIOA /*uart2*/ #define UART2_TX_GPIO_PIN GPIO_PIN_6 #define UART2_TX_GPIO_PORT GPIOB #define UART2_RX_GPIO_PIN GPIO_PIN_7 #define UART2_RX_GPIO_PORT GPIOB /* LPUART1*/ #define LPUART1_TX_GPIO_PIN GPIO_PIN_11 #define LPUART1_TX_GPIO_PORT GPIOB #define LPUART1_RX_GPIO_PIN GPIO_PIN_10 #define LPUART1_RX_GPIO_PORT GPIOB /*voice 引脚*/ #define VOICE_CLK_PIN GET_PIN(C, 5) #define VOICE_DATA_PIN GET_PIN(C, 6) #define VOICE_BUSY_PIN GET_PIN(C, 7) /*按键*/ #define BUTTON_0 GET_PIN(A, 13) /*LED*/ #define RED_LED_PIN GET_PIN(B, 3) #define GREEN_LED_PIN GET_PIN(B, 4) #define YELLOW_LED_PIN GET_PIN(B, 5) #define BUZZER_PIN GET_PIN(B, 6) /*联动设备*/ #define EMV_LED_PIN GET_PIN(B, 0) #define FJ_LED_PIN GET_PIN(B, 1) #define EMV_ACT do{\ rt_pin_write(EMV_LED_PIN, PIN_LOW);\ rt_thread_mdelay(100);\ rt_pin_write(EMV_LED_PIN, PIN_HIGH);\ rt_thread_mdelay(100);}while(0)\ #define FJ_ON do{rt_pin_write(FJ_LED_PIN, PIN_HIGH);}while(0) #define FJ_OFF do{rt_pin_write(FJ_LED_PIN, PIN_LOW);}while(0) struct pin_index { int index; GPIO_t *gpio; uint32_t pin; }; #endif #endif // !