gpio.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #include "sdkconfig.h"
  15. #include "esp_err.h"
  16. #include <esp_types.h>
  17. #include <esp_bit_defs.h>
  18. #include "esp_attr.h"
  19. #include "esp_intr_alloc.h"
  20. #include "soc/soc_caps.h"
  21. #include "soc/gpio_periph.h"
  22. #include "hal/gpio_types.h"
  23. // |================================= WARNING ====================================================== |
  24. // | Including ROM header file in a PUBLIC API file will be REMOVED in the next major release (5.x). |
  25. // | User should include "esp_rom_gpio.h" in their code if they have to use those ROM API. |
  26. // |================================================================================================ |
  27. #if CONFIG_IDF_TARGET_ESP32
  28. #include "esp32/rom/gpio.h"
  29. #elif CONFIG_IDF_TARGET_ESP32S2
  30. #include "esp32s2/rom/gpio.h"
  31. #elif CONFIG_IDF_TARGET_ESP32C3
  32. #include "esp32c3/rom/gpio.h"
  33. #endif
  34. #ifdef CONFIG_LEGACY_INCLUDE_COMMON_HEADERS
  35. #include "soc/rtc_io_reg.h"
  36. #endif
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. #define GPIO_PIN_COUNT (SOC_GPIO_PIN_COUNT)
  41. /// Check whether it is a valid GPIO number
  42. #define GPIO_IS_VALID_GPIO(gpio_num) (((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0)
  43. /// Check whether it can be a valid GPIO number of output mode
  44. #define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) (((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0)
  45. typedef intr_handle_t gpio_isr_handle_t;
  46. /**
  47. * @brief GPIO common configuration
  48. *
  49. * Configure GPIO's Mode,pull-up,PullDown,IntrType
  50. *
  51. * @param pGPIOConfig Pointer to GPIO configure struct
  52. *
  53. * @return
  54. * - ESP_OK success
  55. * - ESP_ERR_INVALID_ARG Parameter error
  56. *
  57. */
  58. esp_err_t gpio_config(const gpio_config_t *pGPIOConfig);
  59. /**
  60. * @brief Reset an gpio to default state (select gpio function, enable pullup and disable input and output).
  61. *
  62. * @param gpio_num GPIO number.
  63. *
  64. * @note This function also configures the IOMUX for this pin to the GPIO
  65. * function, and disconnects any other peripheral output configured via GPIO
  66. * Matrix.
  67. *
  68. * @return Always return ESP_OK.
  69. */
  70. esp_err_t gpio_reset_pin(gpio_num_t gpio_num);
  71. /**
  72. * @brief GPIO set interrupt trigger type
  73. *
  74. * @param gpio_num GPIO number. If you want to set the trigger type of e.g. of GPIO16, gpio_num should be GPIO_NUM_16 (16);
  75. * @param intr_type Interrupt type, select from gpio_int_type_t
  76. *
  77. * @return
  78. * - ESP_OK Success
  79. * - ESP_ERR_INVALID_ARG Parameter error
  80. *
  81. */
  82. esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type);
  83. /**
  84. * @brief Enable GPIO module interrupt signal
  85. *
  86. * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi with sleep mode enabled.
  87. * Please refer to the comments of `adc1_get_raw`.
  88. * Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
  89. * As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA),
  90. * but will remove the glitches on GPIO36 and GPIO39.
  91. *
  92. * @param gpio_num GPIO number. If you want to enable an interrupt on e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
  93. *
  94. * @return
  95. * - ESP_OK Success
  96. * - ESP_ERR_INVALID_ARG Parameter error
  97. *
  98. */
  99. esp_err_t gpio_intr_enable(gpio_num_t gpio_num);
  100. /**
  101. * @brief Disable GPIO module interrupt signal
  102. *
  103. * @param gpio_num GPIO number. If you want to disable the interrupt of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
  104. *
  105. * @return
  106. * - ESP_OK success
  107. * - ESP_ERR_INVALID_ARG Parameter error
  108. *
  109. */
  110. esp_err_t gpio_intr_disable(gpio_num_t gpio_num);
  111. /**
  112. * @brief GPIO set output level
  113. *
  114. * @param gpio_num GPIO number. If you want to set the output level of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
  115. * @param level Output level. 0: low ; 1: high
  116. *
  117. * @return
  118. * - ESP_OK Success
  119. * - ESP_ERR_INVALID_ARG GPIO number error
  120. *
  121. */
  122. esp_err_t gpio_set_level(gpio_num_t gpio_num, uint32_t level);
  123. /**
  124. * @brief GPIO get input level
  125. *
  126. * @warning If the pad is not configured for input (or input and output) the returned value is always 0.
  127. *
  128. * @param gpio_num GPIO number. If you want to get the logic level of e.g. pin GPIO16, gpio_num should be GPIO_NUM_16 (16);
  129. *
  130. * @return
  131. * - 0 the GPIO input level is 0
  132. * - 1 the GPIO input level is 1
  133. *
  134. */
  135. int gpio_get_level(gpio_num_t gpio_num);
  136. /**
  137. * @brief GPIO set direction
  138. *
  139. * Configure GPIO direction,such as output_only,input_only,output_and_input
  140. *
  141. * @param gpio_num Configure GPIO pins number, it should be GPIO number. If you want to set direction of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
  142. * @param mode GPIO direction
  143. *
  144. * @return
  145. * - ESP_OK Success
  146. * - ESP_ERR_INVALID_ARG GPIO error
  147. *
  148. */
  149. esp_err_t gpio_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
  150. /**
  151. * @brief Configure GPIO pull-up/pull-down resistors
  152. *
  153. * Only pins that support both input & output have integrated pull-up and pull-down resistors. Input-only GPIOs 34-39 do not.
  154. *
  155. * @param gpio_num GPIO number. If you want to set pull up or down mode for e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
  156. * @param pull GPIO pull up/down mode.
  157. *
  158. * @return
  159. * - ESP_OK Success
  160. * - ESP_ERR_INVALID_ARG : Parameter error
  161. *
  162. */
  163. esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
  164. /**
  165. * @brief Enable GPIO wake-up function.
  166. *
  167. * @param gpio_num GPIO number.
  168. *
  169. * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used.
  170. *
  171. * @return
  172. * - ESP_OK Success
  173. * - ESP_ERR_INVALID_ARG Parameter error
  174. */
  175. esp_err_t gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type);
  176. /**
  177. * @brief Disable GPIO wake-up function.
  178. *
  179. * @param gpio_num GPIO number
  180. *
  181. * @return
  182. * - ESP_OK Success
  183. * - ESP_ERR_INVALID_ARG Parameter error
  184. */
  185. esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num);
  186. /**
  187. * @brief Register GPIO interrupt handler, the handler is an ISR.
  188. * The handler will be attached to the same CPU core that this function is running on.
  189. *
  190. * This ISR function is called whenever any GPIO interrupt occurs. See
  191. * the alternative gpio_install_isr_service() and
  192. * gpio_isr_handler_add() API in order to have the driver support
  193. * per-GPIO ISRs.
  194. *
  195. * @param fn Interrupt handler function.
  196. * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  197. * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  198. * @param arg Parameter for handler function
  199. * @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
  200. *
  201. * \verbatim embed:rst:leading-asterisk
  202. * To disable or remove the ISR, pass the returned handle to the :doc:`interrupt allocation functions </api-reference/system/intr_alloc>`.
  203. * \endverbatim
  204. *
  205. * @return
  206. * - ESP_OK Success ;
  207. * - ESP_ERR_INVALID_ARG GPIO error
  208. * - ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
  209. */
  210. esp_err_t gpio_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, gpio_isr_handle_t *handle);
  211. /**
  212. * @brief Enable pull-up on GPIO.
  213. *
  214. * @param gpio_num GPIO number
  215. *
  216. * @return
  217. * - ESP_OK Success
  218. * - ESP_ERR_INVALID_ARG Parameter error
  219. */
  220. esp_err_t gpio_pullup_en(gpio_num_t gpio_num);
  221. /**
  222. * @brief Disable pull-up on GPIO.
  223. *
  224. * @param gpio_num GPIO number
  225. *
  226. * @return
  227. * - ESP_OK Success
  228. * - ESP_ERR_INVALID_ARG Parameter error
  229. */
  230. esp_err_t gpio_pullup_dis(gpio_num_t gpio_num);
  231. /**
  232. * @brief Enable pull-down on GPIO.
  233. *
  234. * @param gpio_num GPIO number
  235. *
  236. * @return
  237. * - ESP_OK Success
  238. * - ESP_ERR_INVALID_ARG Parameter error
  239. */
  240. esp_err_t gpio_pulldown_en(gpio_num_t gpio_num);
  241. /**
  242. * @brief Disable pull-down on GPIO.
  243. *
  244. * @param gpio_num GPIO number
  245. *
  246. * @return
  247. * - ESP_OK Success
  248. * - ESP_ERR_INVALID_ARG Parameter error
  249. */
  250. esp_err_t gpio_pulldown_dis(gpio_num_t gpio_num);
  251. /**
  252. * @brief Install the driver's GPIO ISR handler service, which allows per-pin GPIO interrupt handlers.
  253. *
  254. * This function is incompatible with gpio_isr_register() - if that function is used, a single global ISR is registered for all GPIO interrupts. If this function is used, the ISR service provides a global GPIO ISR and individual pin handlers are registered via the gpio_isr_handler_add() function.
  255. *
  256. * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  257. * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  258. *
  259. * @return
  260. * - ESP_OK Success
  261. * - ESP_ERR_NO_MEM No memory to install this service
  262. * - ESP_ERR_INVALID_STATE ISR service already installed.
  263. * - ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
  264. * - ESP_ERR_INVALID_ARG GPIO error
  265. */
  266. esp_err_t gpio_install_isr_service(int intr_alloc_flags);
  267. /**
  268. * @brief Uninstall the driver's GPIO ISR service, freeing related resources.
  269. */
  270. void gpio_uninstall_isr_service(void);
  271. /**
  272. * @brief Add ISR handler for the corresponding GPIO pin.
  273. *
  274. * Call this function after using gpio_install_isr_service() to
  275. * install the driver's GPIO ISR handler service.
  276. *
  277. * The pin ISR handlers no longer need to be declared with IRAM_ATTR,
  278. * unless you pass the ESP_INTR_FLAG_IRAM flag when allocating the
  279. * ISR in gpio_install_isr_service().
  280. *
  281. * This ISR handler will be called from an ISR. So there is a stack
  282. * size limit (configurable as "ISR stack size" in menuconfig). This
  283. * limit is smaller compared to a global GPIO interrupt handler due
  284. * to the additional level of indirection.
  285. *
  286. * @param gpio_num GPIO number
  287. * @param isr_handler ISR handler function for the corresponding GPIO number.
  288. * @param args parameter for ISR handler.
  289. *
  290. * @return
  291. * - ESP_OK Success
  292. * - ESP_ERR_INVALID_STATE Wrong state, the ISR service has not been initialized.
  293. * - ESP_ERR_INVALID_ARG Parameter error
  294. */
  295. esp_err_t gpio_isr_handler_add(gpio_num_t gpio_num, gpio_isr_t isr_handler, void *args);
  296. /**
  297. * @brief Remove ISR handler for the corresponding GPIO pin.
  298. *
  299. * @param gpio_num GPIO number
  300. *
  301. * @return
  302. * - ESP_OK Success
  303. * - ESP_ERR_INVALID_STATE Wrong state, the ISR service has not been initialized.
  304. * - ESP_ERR_INVALID_ARG Parameter error
  305. */
  306. esp_err_t gpio_isr_handler_remove(gpio_num_t gpio_num);
  307. /**
  308. * @brief Set GPIO pad drive capability
  309. *
  310. * @param gpio_num GPIO number, only support output GPIOs
  311. * @param strength Drive capability of the pad
  312. *
  313. * @return
  314. * - ESP_OK Success
  315. * - ESP_ERR_INVALID_ARG Parameter error
  316. */
  317. esp_err_t gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t strength);
  318. /**
  319. * @brief Get GPIO pad drive capability
  320. *
  321. * @param gpio_num GPIO number, only support output GPIOs
  322. * @param strength Pointer to accept drive capability of the pad
  323. *
  324. * @return
  325. * - ESP_OK Success
  326. * - ESP_ERR_INVALID_ARG Parameter error
  327. */
  328. esp_err_t gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t *strength);
  329. /**
  330. * @brief Enable gpio pad hold function.
  331. *
  332. * The gpio pad hold function works in both input and output modes, but must be output-capable gpios.
  333. * If pad hold enabled:
  334. * in output mode: the output level of the pad will be force locked and can not be changed.
  335. * in input mode: the input value read will not change, regardless the changes of input signal.
  336. *
  337. * The state of digital gpio cannot be held during Deep-sleep, and it will resume the hold function
  338. * when the chip wakes up from Deep-sleep. If the digital gpio also needs to be held during Deep-sleep,
  339. * `gpio_deep_sleep_hold_en` should also be called.
  340. *
  341. * Power down or call gpio_hold_dis will disable this function.
  342. *
  343. * @param gpio_num GPIO number, only support output-capable GPIOs
  344. *
  345. * @return
  346. * - ESP_OK Success
  347. * - ESP_ERR_NOT_SUPPORTED Not support pad hold function
  348. */
  349. esp_err_t gpio_hold_en(gpio_num_t gpio_num);
  350. /**
  351. * @brief Disable gpio pad hold function.
  352. *
  353. * When the chip is woken up from Deep-sleep, the gpio will be set to the default mode, so, the gpio will output
  354. * the default level if this function is called. If you don't want the level changes, the gpio should be configured to
  355. * a known state before this function is called.
  356. * e.g.
  357. * If you hold gpio18 high during Deep-sleep, after the chip is woken up and `gpio_hold_dis` is called,
  358. * gpio18 will output low level(because gpio18 is input mode by default). If you don't want this behavior,
  359. * you should configure gpio18 as output mode and set it to hight level before calling `gpio_hold_dis`.
  360. *
  361. * @param gpio_num GPIO number, only support output-capable GPIOs
  362. *
  363. * @return
  364. * - ESP_OK Success
  365. * - ESP_ERR_NOT_SUPPORTED Not support pad hold function
  366. */
  367. esp_err_t gpio_hold_dis(gpio_num_t gpio_num);
  368. /**
  369. * @brief Enable all digital gpio pad hold function during Deep-sleep.
  370. *
  371. * When the chip is in Deep-sleep mode, all digital gpio will hold the state before sleep, and when the chip is woken up,
  372. * the status of digital gpio will not be held. Note that the pad hold feature only works when the chip is in Deep-sleep mode,
  373. * when not in sleep mode, the digital gpio state can be changed even you have called this function.
  374. *
  375. * Power down or call gpio_hold_dis will disable this function, otherwise, the digital gpio hold feature works as long as the chip enter Deep-sleep.
  376. */
  377. void gpio_deep_sleep_hold_en(void);
  378. /**
  379. * @brief Disable all digital gpio pad hold function during Deep-sleep.
  380. *
  381. */
  382. void gpio_deep_sleep_hold_dis(void);
  383. /**
  384. * @brief Set pad input to a peripheral signal through the IOMUX.
  385. * @param gpio_num GPIO number of the pad.
  386. * @param signal_idx Peripheral signal id to input. One of the ``*_IN_IDX`` signals in ``soc/gpio_sig_map.h``.
  387. */
  388. void gpio_iomux_in(uint32_t gpio_num, uint32_t signal_idx);
  389. /**
  390. * @brief Set peripheral output to an GPIO pad through the IOMUX.
  391. * @param gpio_num gpio_num GPIO number of the pad.
  392. * @param func The function number of the peripheral pin to output pin.
  393. * One of the ``FUNC_X_*`` of specified pin (X) in ``soc/io_mux_reg.h``.
  394. * @param oen_inv True if the output enable needs to be inverted, otherwise False.
  395. */
  396. void gpio_iomux_out(uint8_t gpio_num, int func, bool oen_inv);
  397. #if SOC_GPIO_SUPPORT_FORCE_HOLD
  398. /**
  399. * @brief Force hold digital and rtc gpio pad.
  400. * @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
  401. * */
  402. esp_err_t gpio_force_hold_all(void);
  403. /**
  404. * @brief Force unhold digital and rtc gpio pad.
  405. * @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
  406. * */
  407. esp_err_t gpio_force_unhold_all(void);
  408. #endif
  409. #if SOC_GPIO_SUPPORT_SLP_SWITCH
  410. /**
  411. * @brief Enable SLP_SEL to change GPIO status automantically in lightsleep.
  412. * @param gpio_num GPIO number of the pad.
  413. *
  414. * @return
  415. * - ESP_OK Success
  416. *
  417. */
  418. esp_err_t gpio_sleep_sel_en(gpio_num_t gpio_num);
  419. /**
  420. * @brief Disable SLP_SEL to change GPIO status automantically in lightsleep.
  421. * @param gpio_num GPIO number of the pad.
  422. *
  423. * @return
  424. * - ESP_OK Success
  425. */
  426. esp_err_t gpio_sleep_sel_dis(gpio_num_t gpio_num);
  427. /**
  428. * @brief GPIO set direction at sleep
  429. *
  430. * Configure GPIO direction,such as output_only,input_only,output_and_input
  431. *
  432. * @param gpio_num Configure GPIO pins number, it should be GPIO number. If you want to set direction of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
  433. * @param mode GPIO direction
  434. *
  435. * @return
  436. * - ESP_OK Success
  437. * - ESP_ERR_INVALID_ARG GPIO error
  438. */
  439. esp_err_t gpio_sleep_set_direction(gpio_num_t gpio_num, gpio_mode_t mode);
  440. /**
  441. * @brief Configure GPIO pull-up/pull-down resistors at sleep
  442. *
  443. * Only pins that support both input & output have integrated pull-up and pull-down resistors. Input-only GPIOs 34-39 do not.
  444. *
  445. * @param gpio_num GPIO number. If you want to set pull up or down mode for e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
  446. * @param pull GPIO pull up/down mode.
  447. *
  448. * @return
  449. * - ESP_OK Success
  450. * - ESP_ERR_INVALID_ARG : Parameter error
  451. */
  452. esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
  453. #if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
  454. /**
  455. * @brief Emulate ESP32S2 behaviour to backup FUN_PU, FUN_PD information
  456. *
  457. * @note Need to be called before sleep.
  458. *
  459. * @return
  460. * - ESP_OK Success
  461. */
  462. esp_err_t gpio_sleep_pupd_config_apply(gpio_num_t gpio_num);
  463. /**
  464. * @brief Emulate ESP32S2 behaviour to restore FUN_PU, FUN_PD information
  465. *
  466. * @note Need to be called after sleep.
  467. *
  468. * @return
  469. * - ESP_OK Success
  470. */
  471. esp_err_t gpio_sleep_pupd_config_unapply(gpio_num_t gpio_num);
  472. #endif
  473. #endif
  474. #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
  475. #define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num & ~SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) == 0)
  476. /**
  477. * @brief Enable GPIO deep-sleep wake-up function.
  478. *
  479. * @param gpio_num GPIO number.
  480. *
  481. * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used.
  482. *
  483. * @note Called by the SDK. User shouldn't call this directly in the APP.
  484. *
  485. * @return
  486. * - ESP_OK Success
  487. * - ESP_ERR_INVALID_ARG Parameter error
  488. */
  489. esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type);
  490. /**
  491. * @brief Disable GPIO deep-sleep wake-up function.
  492. *
  493. * @param gpio_num GPIO number
  494. *
  495. * @return
  496. * - ESP_OK Success
  497. * - ESP_ERR_INVALID_ARG Parameter error
  498. */
  499. esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num);
  500. #endif
  501. #ifdef __cplusplus
  502. }
  503. #endif