CIU32_L051_M307R/drivers/inc/drv_gpio.h

121 lines
2.9 KiB
C
Raw Normal View History

2024-09-05 10:01:45 +08:00
#ifndef __DRV_GPIO_H__
#define __DRV_GPIO_H__
2024-09-05 10:01:45 +08:00
#include <rtthread.h>
#include "ciu32l051.h"
#ifdef RT_USING_PIN
// #define RT_PIN_ENABLE
2024-09-05 15:30:19 +08:00
#define __CIU_PORT(port) (GPIO##port##_BASE)
2024-09-05 10:01:45 +08:00
2024-09-05 15:30:19 +08:00
#define GET_PIN(port, pin) (rt_base_t)((16 * (((rt_base_t)__CIU_PORT(port) - (rt_base_t)GPIOA_BASE) / (0x0400UL))) + pin)
2024-09-05 10:01:45 +08:00
2024-09-05 15:30:19 +08:00
#define __CIU32_PIN(index, gpio, gpio_index) {index, GPIO##gpio, GPIO_PIN_##gpio_index}
2024-09-05 10:01:45 +08:00
2024-09-14 16:50:58 +08:00
#define SENSOR_POWER_PIN GET_PIN(A, 7)
2024-09-05 15:30:19 +08:00
/*uart1*/
#ifndef RT_PIN_ENABLE
#define UART1_TX_GPIO_PIN GPIO_PIN_11
#define UART1_TX_GPIO_PORT GPIOA
2024-09-05 10:01:45 +08:00
#define UART1_RX_GPIO_PIN GPIO_PIN_12
#define UART1_RX_GPIO_PORT GPIOA
#else
#define UART1_TX_GPIO_PIN GET_PIN(A, 11)
#define UART1_RX_GPIO_PIN GET_PIN(A, 12)
#endif // !
2024-09-05 15:30:19 +08:00
2024-09-14 16:50:58 +08:00
/*uart2*/
#ifndef RT_PIN_ENABLE
#define UART2_TX_GPIO_PIN GPIO_PIN_6
#define UART2_TX_GPIO_PORT GPIOB
2024-09-14 16:50:58 +08:00
#define UART2_RX_GPIO_PIN GPIO_PIN_7
#define UART2_RX_GPIO_PORT GPIOB
#else
#define UART2_TX_GPIO_PIN GET_PIN(B, 6)
#define UART2_RX_GPIO_PIN GET_PIN(B, 7)
#endif // !
/*uart3*/
#ifndef RT_PIN_ENABLE
#define UART3_TX_GPIO_PIN GPIO_PIN_1
#define UART3_TX_GPIO_PORT GPIOD
#define UART3_RX_GPIO_PIN GPIO_PIN_0
#define UART3_RX_GPIO_PORT GPIOD
#else
#define UART3_TX_GPIO_PIN GET_PIN(D, 1)
#define UART3_RX_GPIO_PIN GET_PIN(D, 0)
#endif // !
2024-09-05 15:30:19 +08:00
/* LPUART1*/
#ifndef RT_PIN_ENABLE
#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
#else
#define LPUART1_TX_GPIO_PIN GET_PIN(B, 11)
#define LPUART1_RX_GPIO_PIN GET_PIN(B, 10)
#endif
2024-09-05 15:30:19 +08:00
/*4G 模块控制引脚*/
2024-09-20 14:56:25 +08:00
#define ML307_PWR_PIN GET_PIN(A, 1)
#define ML307_RST_PIN GET_PIN(A, 2)
#define USIM_DECT_PIN GET_PIN(A, 3)
#define ENABLE_3_8_V GET_PIN(A, 5)
2024-09-05 15:30:19 +08:00
/*voice 引脚*/
// #define VOICE_CLK_PIN GET_PIN(B, 12)
// #define VOICE_DATA_PIN GET_PIN(B, 13)
// #define VOICE_BUSY_PIN GET_PIN(B, 14)
2024-09-05 15:30:19 +08:00
/*按键*/
2024-09-14 16:50:58 +08:00
#define BUTTON_0 GET_PIN(A, 13)
2024-09-05 15:30:19 +08:00
/*蜂鸣器*/
#define BUZZER_PIN GET_PIN(B, 2)
2024-09-05 15:30:19 +08:00
/*LED*/
2024-09-14 16:50:58 +08:00
#define RED_LED_PIN GET_PIN(B, 3)
#define GREEN_LED_PIN GET_PIN(B, 4)
#define YELLOW_LED_PIN GET_PIN(B, 5)
2024-09-05 15:30:19 +08:00
/*联动设备*/
#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)
2024-09-14 16:50:58 +08:00
struct pin_index
2024-09-05 10:01:45 +08:00
{
int index;
2024-09-05 15:30:19 +08:00
GPIO_t *gpio;
2024-09-05 10:01:45 +08:00
uint32_t pin;
};
#endif
#endif // !