| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- /**
- * @file HW_GPIO_ATY.h
- *
- * @param Project DEVICE_GENERAL_ATY_LIB
- *
- * @author ATY
- *
- * @copyright
- * - Copyright 2017 - 2023 MZ-ATY
- * - This code follows:
- * - MZ-ATY Various Contents Joint Statement -
- * <a href="https://mengze.top/MZ-ATY_VCJS">
- * https://mengze.top/MZ-ATY_VCJS</a>
- * - CC 4.0 BY-NC-SA -
- * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
- * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
- * - Your use will be deemed to have accepted the terms of this statement.
- *
- * @brief Familiar definition of GPIO for users
- *
- * @version
- * - 1_01_220602 > ATY
- * -# Preliminary version, first Release
- * - Undone
- ********************************************************************************
- */
- #ifndef __HW_GPIO_ATY_H
- #define __HW_GPIO_ATY_H
- #include "INCLUDE_ATY.h"
- #if defined(__STC51_ATY)
- #define GPIO_SET_H(Port, Pin) Pin = 1
- #define GPIO_SET_L(Port, Pin) Pin = 0
- #define GPIO_GET_H(Port, Pin) Pin == 1
- #define GPIO_GET_L(Port, Pin) Pin == 0
- #define GPIO_SET_IN(Port, Pin) Pin = 1;__NOP_ATY;__NOP_ATY
- #define GPIO_SET_OUT(Port, Pin) Pin = 0
- #elif defined(__HC32_ATY)
- #define GPIO_SET_H(Port, Pin) Gpio_SetIO(Port, Pin)
- #define GPIO_SET_L(Port, Pin) Gpio_ClrIO(Port, Pin)
- #define GPIO_GET_H(Port, Pin) Gpio_GetInputIO(Port, Pin) == 1
- #define GPIO_GET_L(Port, Pin) Gpio_GetInputIO(Port, Pin) == 0
- #elif defined(__STM32_HAL_ATY)
- #define GPIO_SET_H(Port, Pin) HAL_GPIO_WritePin(Port, Pin, GPIO_PIN_SET)
- #define GPIO_SET_L(Port, Pin) HAL_GPIO_WritePin(Port, Pin, GPIO_PIN_RESET)
- #define GPIO_GET_H(Port, Pin) HAL_GPIO_ReadPin(Port, Pin) == GPIO_PIN_SET
- #define GPIO_GET_L(Port, Pin) HAL_GPIO_ReadPin(Port, Pin) == GPIO_PIN_RESET
- #define GPIO_SET_IN(Port, Pin) GPIO_SetIn(Port, Pin)
- #define GPIO_SET_OUT(Port, Pin) GPIO_SetOut(Port, Pin)
- #define GPIO_SetOut(GPIOx, GPIO_Pin) \
- { \
- GPIO_InitTypeDef GPIO_InitStruct; \
- __HAL_RCC_GPIOB_CLK_ENABLE(); \
- GPIO_InitStruct.Pin = GPIO_Pin; \
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; \
- GPIO_InitStruct.Pull = GPIO_NOPULL; \
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; \
- HAL_GPIO_Init(GPIOx, &GPIO_InitStruct); \
- }
- #define GPIO_SetIn(GPIOx, GPIO_Pin) \
- { \
- GPIO_InitTypeDef GPIO_InitStruct; \
- __HAL_RCC_GPIOB_CLK_ENABLE(); \
- GPIO_InitStruct.Pin = GPIO_Pin; \
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT; \
- GPIO_InitStruct.Pull = GPIO_NOPULL; \
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; \
- HAL_GPIO_Init(GPIOx, &GPIO_InitStruct); \
- }
- // void GPIO_SetIn(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
- // void GPIO_SetOut(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
- #endif /* PLATFORM */
- /******************************* For user *************************************/
- #if defined(__STC51_ATY)
- #ifdef __LED_ATY_H
- #ifndef SYSLED_PORT
- #define SYSLED_PORT 0
- #endif
- #ifndef SYSLED_PIN
- #define SYSLED_PIN P34
- #endif
- #endif /* __LED_ATY_H */
- #ifdef PW_PIN
- #define MCU_Off \
- do{ \
- /* power off directely */ \
- PW_PIN = 0; \
- }while(0)
- #endif /* PW_PIN */
- #ifndef __I2C_HARDWARE_ATY
- #define I2C_SCL_PORT 0
- #define I2C_SCL_PIN P32
- #define I2C_SDA_PORT 0
- #define I2C_SDA_PIN P33
- #endif /* __I2C_HARDWARE_ATY */
- // #ifdef __GP22_ATY_H
- #define GP22_RST_PORT 0
- #ifndef GP22_RST_PIN
- #define GP22_RST_PIN P11
- #endif
- #define GP22_CSN_PORT 0
- #ifndef GP22_CSN_PIN
- #define GP22_CSN_PIN P12
- #endif
- #define GP22_INT_PORT 0
- #ifndef GP22_INT_PIN
- #define GP22_INT_PIN P16
- #endif
- #define GP22_EN_PORT 0
- #ifndef GP22_EN_PIN
- #define GP22_EN_PIN P10
- #endif
- #define GP22_SIGNAL_PORT 0
- #ifndef GP22_SIGNAL_PIN
- #define GP22_SIGNAL_PIN 0
- #endif
- #define GP22_SCLK_PIN P15
- #define GP22_MISO_PIN P14
- #define GP22_MOSI_PIN P13
- // #endif /* __GP22_ATY_H */
- #ifdef __MOTOR_STEP_ATY_H
- #define MOTOR_EN_PORT 0
- #ifndef MOTOR_EN_PIN
- #define MOTOR_EN_PIN P24
- #endif
- #define MOTOR_DIR_PORT 0
- #define MOTOR_DIR_PIN P22
- #define MOTOR_STEP_PORT 0
- #define MOTOR_STEP_PIN P23
- #define MOTOR_DIAG_PORT 0
- #define MOTOR_DIAG_PIN P55
- #endif /* __MOTOR_STEP_ATY_H */
- #ifdef __MOTOR_DC_ATY_H
- #define MOTOR_A_PORT 0
- #ifndef MOTOR_A_PIN
- #define MOTOR_A_PIN P54
- #endif /* MOTOR_A_PIN */
- #define MOTOR_B_PORT 0
- #ifndef MOTOR_B_PIN
- #define MOTOR_B_PIN P17
- #endif /* MOTOR_B_PIN */
- #define MOTOR_EN_PORT 0
- #ifndef MOTOR_EN_PIN
- #define MOTOR_EN_PIN P17
- #endif /* MOTOR_EN_PIN */
- #endif /* __MOTOR_DC_ATY_H */
- #ifdef __WS2812_ATY_H
- #define WS2812_PORT 0
- #define WS2812_PIN P12
- #endif /* __WS2812_ATY_H */
- #elif defined(__STM32_HAL_ATY)
- #ifdef __LED_ATY_H
- #if !defined(SYSLED_PORT) && !defined(SYSLED_PIN)
- #define SYSLED_PORT SYSLED_O_GPIO_Port
- #define SYSLED_PIN SYSLED_O_Pin
- #endif /* SYSLED_PORT SYSLED_PIN */
- #endif /* __LED_ATY_H */
- #ifndef __I2C_HARDWARE_ATY
- #define I2C_SCL_PORT I2C_SCL_GPIO_Port
- #define I2C_SCL_PIN I2C_SCL_Pin
- #define I2C_SDA_PORT I2C_SDA_GPIO_Port
- #define I2C_SDA_PIN I2C_SDA_Pin
- #endif /* __I2C_HARDWARE_ATY */
- #ifdef __GP22_ATY_H
- #define GP22_SIGNAL_PORT SPI1_SIGNAL_GPIO_Port
- #define GP22_SIGNAL_PIN SPI1_SIGNAL_Pin
- #define GP22_CSN_PORT SPI1_CSN_GPIO_Port
- #define GP22_CSN_PIN SPI1_CSN_Pin
- #define GP22_RST_PORT SPI1_RST_GPIO_Port
- #define GP22_RST_PIN SPI1_RST_Pin
- #define GP22_INT_PORT SPI1_INT_GPIO_Port
- #define GP22_INT_PIN SPI1_INT_Pin
- #endif /* __GP22_ATY_H */
- #ifdef __MOTOR_STEP_ATY_H
- #define MOTOR_EN_PORT MOTOR_EN_GPIO_Port
- #define MOTOR_EN_PIN MOTOR_EN_Pin
- #define MOTOR_DIR_PORT MOTOR_DIR_GPIO_Port
- #define MOTOR_DIR_PIN MOTOR_DIR_Pin
- #define MOTOR_STEP_PORT MOTOR_STEP_GPIO_Port
- #define MOTOR_STEP_PIN MOTOR_STEP_Pin
- #define MOTOR_DIAG_PORT MOTOR_DIAG_GPIO_Port
- #define MOTOR_DIAG_PIN MOTOR_DIAG_Pin
- #endif /* __MOTOR_STEP_ATY_H */
- #endif /* PLATFORM */
- /******************************************************************************/
- #endif /* __HW_GPIO_ATY_H */
- /******************************** End Of File *********************************/
|