gpio.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("AutoChips Software") are
  4. * protected under relevant copyright laws. The information contained herein is
  5. * confidential and proprietary to AutoChips Inc. and/or its licensors. Without
  6. * the prior written permission of AutoChips inc. and/or its licensors, any
  7. * reproduction, modification, use or disclosure of AutoChips Software, and
  8. * information contained herein, in whole or in part, shall be strictly
  9. * prohibited.
  10. *
  11. * AutoChips Inc. (C) 2022. All rights reserved.
  12. *
  13. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  14. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("AUTOCHIPS SOFTWARE")
  15. * RECEIVED FROM AUTOCHIPS AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
  16. * ON AN "AS-IS" BASIS ONLY. AUTOCHIPS EXPRESSLY DISCLAIMS ANY AND ALL
  17. * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
  19. * NONINFRINGEMENT. NEITHER DOES AUTOCHIPS PROVIDE ANY WARRANTY WHATSOEVER WITH
  20. * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
  21. * INCORPORATED IN, OR SUPPLIED WITH THE AUTOCHIPS SOFTWARE, AND RECEIVER AGREES
  22. * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
  23. * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
  24. * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN AUTOCHIPS
  25. * SOFTWARE. AUTOCHIPS SHALL ALSO NOT BE RESPONSIBLE FOR ANY AUTOCHIPS SOFTWARE
  26. * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  27. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND AUTOCHIPS'S
  28. * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE AUTOCHIPS SOFTWARE
  29. * RELEASED HEREUNDER WILL BE, AT AUTOCHIPS'S OPTION, TO REVISE OR REPLACE THE
  30. * AUTOCHIPS SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
  31. * CHARGE PAID BY RECEIVER TO AUTOCHIPS FOR SUCH AUTOCHIPS SOFTWARE AT ISSUE.
  32. */
  33. /******************************************************************************
  34. * @version: V2.0.1 AC7840x Demo
  35. ******************************************************************************/
  36. #ifndef _GPIO_H
  37. #define _GPIO_H
  38. /*!
  39. * @file gpio.h
  40. *
  41. * @brief gpio function definition.
  42. */
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif /* __cplusplus */
  46. /* =========================================== Includes =========================================== */
  47. #include <stdbool.h>
  48. #include <stdint.h>
  49. #include "ac7840x.h"
  50. #include "gpio_drv.h"
  51. #include "port_hw.h"
  52. /* ============================================ Define ============================================ */
  53. //电磁阀输出
  54. #define LED1_PORT (PORTD)
  55. #define LED1_GPIO (GPIOD)
  56. #define LED1_PIN (7)
  57. //433 语音播报输出
  58. #define K0_PORT (PORTA)
  59. #define K0_GPIO (GPIOA)
  60. #define K0_PIN (10)
  61. #define K1_PORT (PORTA)
  62. #define K1_GPIO (GPIOA)
  63. #define K1_PIN (11)
  64. #define K2_PORT (PORTA)
  65. #define K2_GPIO (GPIOA)
  66. #define K2_PIN (12)
  67. #define K3_PORT (PORTA)
  68. #define K3_GPIO (GPIOA)
  69. #define K3_PIN (13)
  70. //设备运行指示灯
  71. #define LED3_PORT (PORTC)
  72. #define LED3_GPIO (GPIOC)
  73. #define LED3_PIN (16)
  74. //底阀开关状态指示灯
  75. #define LED4_PORT (PORTC)
  76. #define LED4_GPIO (GPIOC)
  77. #define LED4_PIN (17)
  78. //底阀开关状态输入
  79. #define KEY3_PORT (PORTD)
  80. #define KEY3_GPIO (GPIOD)
  81. #define KEY3_PIN (6)
  82. //#define KEY4_PORT (PORTE)
  83. //#define KEY4_GPIO (GPIOE)
  84. //#define KEY4_PIN (7)
  85. //#define KEY4_IRQ (PORTE_IRQn)
  86. //#define KEY4_INSTANCE (4)
  87. #define LED1_ON do{GPIO_DRV_WritePin(LED1_GPIO , LED1_PIN, 1);}while(0)
  88. #define LED1_OFF do{GPIO_DRV_WritePin(LED1_GPIO, LED1_PIN, 0);}while(0)
  89. #define LED1_TOGGLE do{GPIO_DRV_TogglePins(LED1_GPIO, (1<<LED1_PIN));}while(0)
  90. //#define LED2_ON do{GPIO_DRV_WritePin(LED2_GPIO , LED2_PIN, 1);}while(0)
  91. //#define LED2_OFF do{GPIO_DRV_WritePin(LED2_GPIO, LED2_PIN, 0);}while(0)
  92. //#define LED2_TOGGLE do{GPIO_DRV_TogglePins(LED2_GPIO, (1<<LED2_PIN));}while(0)
  93. #define K0_ON do{GPIO_DRV_WritePin(K0_GPIO, K0_PIN, 1);}while(0)
  94. #define K0_OFF do{GPIO_DRV_WritePin(K0_GPIO, K0_PIN, 0);}while(0)
  95. #define K1_ON do{GPIO_DRV_WritePin(K1_GPIO, K1_PIN, 1);}while(0)
  96. #define K1_OFF do{GPIO_DRV_WritePin(K1_GPIO, K1_PIN, 0);}while(0)
  97. #define K2_ON do{GPIO_DRV_WritePin(K2_GPIO, K2_PIN, 1);}while(0)
  98. #define K2_OFF do{GPIO_DRV_WritePin(K2_GPIO, K2_PIN, 0);}while(0)
  99. #define K3_ON do{GPIO_DRV_WritePin(K3_GPIO, K3_PIN, 1);}while(0)
  100. #define K3_OFF do{GPIO_DRV_WritePin(K3_GPIO, K3_PIN, 0);}while(0)
  101. #define LED3_ON do{GPIO_DRV_WritePin(LED3_GPIO , LED3_PIN, 0);}while(0)
  102. #define LED3_OFF do{GPIO_DRV_WritePin(LED3_GPIO, LED3_PIN, 1);}while(0)
  103. #define LED3_TOGGLE do{GPIO_DRV_TogglePins(LED3_GPIO, (1<<LED3_PIN));}while(0)
  104. #define LED4_ON do{GPIO_DRV_WritePin(LED4_GPIO, LED4_PIN, 0);}while(0)
  105. #define LED4_OFF do{GPIO_DRV_WritePin(LED4_GPIO, LED4_PIN, 1);}while(0)
  106. #define LED4_TOGGLE do{GPIO_DRV_TogglePins(LED4_GPIO, (1<<LED4_PIN));}while(0)
  107. #define RS485CTRL_PORT (PORTE)
  108. #define RS485CTRL_GPIO (GPIOE)
  109. #define RS485CTRL_PIN (6)
  110. #define RS485_TX_EN do{GPIO_DRV_WritePin(RS485CTRL_GPIO, RS485CTRL_PIN, 1);}while(0)
  111. #define RS485_RX_EN do{GPIO_DRV_WritePin(RS485CTRL_GPIO, RS485CTRL_PIN, 0);}while(0)
  112. #define GET_K3_STS() (GPIO_DRV_ReadPins(KEY3_GPIO)& (1<<KEY3_PIN))
  113. //#define GET_K4_STS() (GPIO_DRV_ReadPins(KEY4_GPIO)& (1<<KEY4_PIN))
  114. #define DIR_IN (0)
  115. #define DIR_OUT (1)
  116. #define LOW (0)
  117. #define HIGH (1)
  118. #define VOICE_ID_0 (0)
  119. #define VOICE_ID_1 (1)
  120. #define VOICE_ID_2 (2)
  121. #define VOICE_ID_3 (3)
  122. /* =========================================== Typedef ============================================ */
  123. /* ========================================== Variables =========================================== */
  124. //extern uint8_t g_key4PressDown_count;
  125. /* ==================================== Functions declaration ===================================== */
  126. extern void GPIO_LedInit(void);
  127. extern void GPIO_KeyInit(void);
  128. void GPIO_Init(void);
  129. void Trigger_VoiceOn(uint8_t voice_id);
  130. void Trigger_VoiceOff();
  131. /* ====================================== Functions define ======================================== */
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* _GPIO_H */
  136. /* ============================================= EOF ============================================== */