at32f413_gpio.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /**
  2. **************************************************************************
  3. * @file at32f413_gpio.c
  4. * @brief contains all the functions for the gpio firmware library
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. #include "at32f413_conf.h"
  25. /** @addtogroup AT32F413_periph_driver
  26. * @{
  27. */
  28. /** @defgroup GPIO
  29. * @brief GPIO driver modules
  30. * @{
  31. */
  32. #ifdef GPIO_MODULE_ENABLED
  33. /** @defgroup GPIO_private_functions
  34. * @{
  35. */
  36. /**
  37. * @brief reset the gpio register
  38. * @param gpio_x: to select the gpio peripheral.
  39. * this parameter can be one of the following values:
  40. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  41. * @retval none
  42. */
  43. void gpio_reset(gpio_type *gpio_x)
  44. {
  45. if(gpio_x == GPIOA)
  46. {
  47. crm_periph_reset(CRM_GPIOA_PERIPH_RESET, TRUE);
  48. crm_periph_reset(CRM_GPIOA_PERIPH_RESET, FALSE);
  49. }
  50. else if(gpio_x == GPIOB)
  51. {
  52. crm_periph_reset(CRM_GPIOB_PERIPH_RESET, TRUE);
  53. crm_periph_reset(CRM_GPIOB_PERIPH_RESET, FALSE);
  54. }
  55. else if(gpio_x == GPIOC)
  56. {
  57. crm_periph_reset(CRM_GPIOC_PERIPH_RESET, TRUE);
  58. crm_periph_reset(CRM_GPIOC_PERIPH_RESET, FALSE);
  59. }
  60. else if(gpio_x == GPIOD)
  61. {
  62. crm_periph_reset(CRM_GPIOD_PERIPH_RESET, TRUE);
  63. crm_periph_reset(CRM_GPIOD_PERIPH_RESET, FALSE);
  64. }
  65. else if(gpio_x == GPIOF)
  66. {
  67. crm_periph_reset(CRM_GPIOF_PERIPH_RESET, TRUE);
  68. crm_periph_reset(CRM_GPIOF_PERIPH_RESET, FALSE);
  69. }
  70. }
  71. /**
  72. * @brief reset the mux functions (remap, event control
  73. and exint configuration) registers to their default values.
  74. * @param none
  75. * @retval none
  76. */
  77. void gpio_iomux_reset(void)
  78. {
  79. crm_periph_reset(CRM_IOMUX_PERIPH_RESET, TRUE);
  80. crm_periph_reset(CRM_IOMUX_PERIPH_RESET, FALSE);
  81. }
  82. /**
  83. * @brief initialize the gpio peripheral.
  84. * @param gpio_x: to select the gpio peripheral.
  85. * this parameter can be one of the following values:
  86. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  87. * @param gpio_init_struct: pointer to gpio init structure.
  88. * @retval none
  89. */
  90. void gpio_init(gpio_type *gpio_x, gpio_init_type *gpio_init_struct)
  91. {
  92. uint32_t temp;
  93. uint16_t pinx_value, pin_index;
  94. pin_index = (uint16_t)gpio_init_struct->gpio_pins;
  95. /* pinx_value indecate pin grounp bit[3:0] from modey[1:0] confy[1:0] */
  96. /* pin input analog config */
  97. if(gpio_init_struct->gpio_mode == GPIO_MODE_ANALOG)
  98. {
  99. pinx_value = 0x00;
  100. }
  101. /* pin input config */
  102. else if(gpio_init_struct->gpio_mode == GPIO_MODE_INPUT)
  103. {
  104. pinx_value = gpio_init_struct->gpio_pull & 0x0F;
  105. if(gpio_init_struct->gpio_pull == GPIO_PULL_UP)
  106. {
  107. gpio_x->scr = pin_index;
  108. }
  109. else if(gpio_init_struct->gpio_pull == GPIO_PULL_DOWN)
  110. {
  111. gpio_x->clr = pin_index;
  112. }
  113. }
  114. else
  115. {
  116. pinx_value = (gpio_init_struct->gpio_mode & 0x08) | (gpio_init_struct->gpio_out_type & 0x04) | \
  117. (gpio_init_struct->gpio_drive_strength & 0x03);
  118. }
  119. /* pin 0~7 config */
  120. if(((uint32_t)pin_index & ((uint32_t)0x00FF)) != 0x00)
  121. {
  122. for(temp = 0; temp < 0x08; temp++)
  123. {
  124. if((1 << temp) & pin_index)
  125. {
  126. gpio_x->cfglr &= (uint32_t)~(0x0F << (temp * 4));
  127. gpio_x->cfglr |= (uint32_t)(pinx_value << (temp * 4));
  128. }
  129. }
  130. }
  131. /* pin 8~15 config */
  132. if(pin_index > 0x00ff)
  133. {
  134. pin_index = pin_index >> 8;
  135. for(temp = 0; temp < 0x8; temp++)
  136. {
  137. if((1 << temp) & pin_index)
  138. {
  139. gpio_x->cfghr &= (uint32_t)~(0xf << (temp * 4));
  140. gpio_x->cfghr |= (uint32_t)(pinx_value << (temp * 4));
  141. }
  142. }
  143. }
  144. }
  145. /**
  146. * @brief fill each gpio_init_type member with its default value.
  147. * @param gpio_init_struct : pointer to a gpio_init_type structure which will be initialized.
  148. * @retval none
  149. */
  150. void gpio_default_para_init(gpio_init_type *gpio_init_struct)
  151. {
  152. /* reset gpio init structure parameters values */
  153. gpio_init_struct->gpio_pins = GPIO_PINS_ALL;
  154. gpio_init_struct->gpio_mode = GPIO_MODE_INPUT;
  155. gpio_init_struct->gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
  156. gpio_init_struct->gpio_pull = GPIO_PULL_NONE;
  157. gpio_init_struct->gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
  158. }
  159. /**
  160. * @brief read the specified input port pin.
  161. * @param gpio_x: to select the gpio peripheral.
  162. * this parameter can be one of the following values:
  163. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  164. * @param pins: gpio pin number
  165. * this parameter can be one of the following values:
  166. * - GPIO_PINS_0
  167. * - GPIO_PINS_1
  168. * - GPIO_PINS_2
  169. * - GPIO_PINS_3
  170. * - GPIO_PINS_4
  171. * - GPIO_PINS_5
  172. * - GPIO_PINS_6
  173. * - GPIO_PINS_7
  174. * - GPIO_PINS_8
  175. * - GPIO_PINS_9
  176. * - GPIO_PINS_10
  177. * - GPIO_PINS_11
  178. * - GPIO_PINS_12
  179. * - GPIO_PINS_13
  180. * - GPIO_PINS_14
  181. * - GPIO_PINS_15
  182. * @retval flag_status (SET or RESET)
  183. */
  184. flag_status gpio_input_data_bit_read(gpio_type *gpio_x, uint16_t pins)
  185. {
  186. flag_status status = RESET;
  187. if(pins != (pins & gpio_x->idt))
  188. {
  189. status = RESET;
  190. }
  191. else
  192. {
  193. status = SET;
  194. }
  195. return status;
  196. }
  197. /**
  198. * @brief read the specified gpio input data port.
  199. * @param gpio_x: to select the gpio peripheral.
  200. * this parameter can be one of the following values:
  201. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  202. * @retval gpio input data port value.
  203. */
  204. uint16_t gpio_input_data_read(gpio_type *gpio_x)
  205. {
  206. return ((uint16_t)(gpio_x->idt));
  207. }
  208. /**
  209. * @brief read the specified output port pin.
  210. * @param gpio_x: to select the gpio peripheral.
  211. * this parameter can be one of the following values:
  212. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  213. * @param pins: gpio pin number
  214. * this parameter can be one of the following values:
  215. * - GPIO_PINS_0
  216. * - GPIO_PINS_1
  217. * - GPIO_PINS_2
  218. * - GPIO_PINS_3
  219. * - GPIO_PINS_4
  220. * - GPIO_PINS_5
  221. * - GPIO_PINS_6
  222. * - GPIO_PINS_7
  223. * - GPIO_PINS_8
  224. * - GPIO_PINS_9
  225. * - GPIO_PINS_10
  226. * - GPIO_PINS_11
  227. * - GPIO_PINS_12
  228. * - GPIO_PINS_13
  229. * - GPIO_PINS_14
  230. * - GPIO_PINS_15
  231. * @retval flag_status (SET or RESET)
  232. */
  233. flag_status gpio_output_data_bit_read(gpio_type *gpio_x, uint16_t pins)
  234. {
  235. flag_status status = RESET;
  236. if((gpio_x->odt & pins) != RESET)
  237. {
  238. status = SET;
  239. }
  240. else
  241. {
  242. status = RESET;
  243. }
  244. return status;
  245. }
  246. /**
  247. * @brief read the specified gpio ouput data port.
  248. * @param gpio_x: to select the gpio peripheral.
  249. * this parameter can be one of the following values:
  250. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  251. * @retval gpio input data port value.
  252. */
  253. uint16_t gpio_output_data_read(gpio_type *gpio_x)
  254. {
  255. return ((uint16_t)(gpio_x->odt));
  256. }
  257. /**
  258. * @brief set the selected data port bits.
  259. * @param gpio_x: to select the gpio peripheral.
  260. * this parameter can be one of the following values:
  261. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  262. * @param pins: gpio pin number
  263. * parameter can be any combination of gpio_pin_x, gpio_pin_x as following values:
  264. * - GPIO_PINS_0
  265. * - GPIO_PINS_1
  266. * - GPIO_PINS_2
  267. * - GPIO_PINS_3
  268. * - GPIO_PINS_4
  269. * - GPIO_PINS_5
  270. * - GPIO_PINS_6
  271. * - GPIO_PINS_7
  272. * - GPIO_PINS_8
  273. * - GPIO_PINS_9
  274. * - GPIO_PINS_10
  275. * - GPIO_PINS_11
  276. * - GPIO_PINS_12
  277. * - GPIO_PINS_13
  278. * - GPIO_PINS_14
  279. * - GPIO_PINS_15
  280. * - GPIO_PINS_ALL
  281. * @retval none
  282. */
  283. void gpio_bits_set(gpio_type *gpio_x, uint16_t pins)
  284. {
  285. gpio_x->scr = pins;
  286. }
  287. /**
  288. * @brief clear the selected data port bits.
  289. * @param gpio_x: to select the gpio peripheral.
  290. * this parameter can be one of the following values:
  291. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  292. * @param pins: gpio pin number
  293. * parameter can be any combination of gpio_pin_x, gpio_pin_x as following values:
  294. * - GPIO_PINS_0
  295. * - GPIO_PINS_1
  296. * - GPIO_PINS_2
  297. * - GPIO_PINS_3
  298. * - GPIO_PINS_4
  299. * - GPIO_PINS_5
  300. * - GPIO_PINS_6
  301. * - GPIO_PINS_7
  302. * - GPIO_PINS_8
  303. * - GPIO_PINS_9
  304. * - GPIO_PINS_10
  305. * - GPIO_PINS_11
  306. * - GPIO_PINS_12
  307. * - GPIO_PINS_13
  308. * - GPIO_PINS_14
  309. * - GPIO_PINS_15
  310. * - GPIO_PINS_ALL
  311. * @retval none
  312. */
  313. void gpio_bits_reset(gpio_type *gpio_x, uint16_t pins)
  314. {
  315. gpio_x->clr = pins;
  316. }
  317. /**
  318. * @brief set or clear the selected data port bit.
  319. * @param gpio_x: to select the gpio peripheral.
  320. * this parameter can be one of the following values:
  321. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  322. * @param pins: gpio pin number
  323. * parameter can be any combination of gpio_pin_x, gpio_pin_x as following values:
  324. * - GPIO_PINS_0
  325. * - GPIO_PINS_1
  326. * - GPIO_PINS_2
  327. * - GPIO_PINS_3
  328. * - GPIO_PINS_4
  329. * - GPIO_PINS_5
  330. * - GPIO_PINS_6
  331. * - GPIO_PINS_7
  332. * - GPIO_PINS_8
  333. * - GPIO_PINS_9
  334. * - GPIO_PINS_10
  335. * - GPIO_PINS_11
  336. * - GPIO_PINS_12
  337. * - GPIO_PINS_13
  338. * - GPIO_PINS_14
  339. * - GPIO_PINS_15
  340. * - GPIO_PINS_ALL
  341. * @param bit_state: specifies the value to be written to the selected bit (TRUE or FALSE).
  342. * @retval none
  343. */
  344. void gpio_bits_write(gpio_type *gpio_x, uint16_t pins, confirm_state bit_state)
  345. {
  346. if(bit_state != FALSE)
  347. {
  348. gpio_x->scr = pins;
  349. }
  350. else
  351. {
  352. gpio_x->clr = pins;
  353. }
  354. }
  355. /**
  356. * @brief write data to the specified gpio data port.
  357. * @param gpio_x: to select the gpio peripheral.
  358. * this parameter can be one of the following values:
  359. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  360. * @param port_value: specifies the value to be written to the port output data register.
  361. * @retval none
  362. */
  363. void gpio_port_write(gpio_type *gpio_x, uint16_t port_value)
  364. {
  365. gpio_x->odt = port_value;
  366. }
  367. /**
  368. * @brief write protect gpio pins configuration registers.
  369. * @param gpio_x: to select the gpio peripheral.
  370. * this parameter can be one of the following values:
  371. * GPIOA, GPIOB, GPIOC, GPIOD, GPIOF.
  372. * @param pins: gpio pin number
  373. * this parameter can be any combination of the following:
  374. * - GPIO_PINS_0
  375. * - GPIO_PINS_1
  376. * - GPIO_PINS_2
  377. * - GPIO_PINS_3
  378. * - GPIO_PINS_4
  379. * - GPIO_PINS_5
  380. * - GPIO_PINS_6
  381. * - GPIO_PINS_7
  382. * - GPIO_PINS_8
  383. * - GPIO_PINS_9
  384. * - GPIO_PINS_10
  385. * - GPIO_PINS_11
  386. * - GPIO_PINS_12
  387. * - GPIO_PINS_13
  388. * - GPIO_PINS_14
  389. * - GPIO_PINS_15
  390. * - GPIO_PINS_ALL
  391. * @retval none
  392. */
  393. void gpio_pin_wp_config(gpio_type *gpio_x, uint16_t pins)
  394. {
  395. uint32_t temp = 0x00010000;
  396. temp |= pins;
  397. /* set wpen bit */
  398. gpio_x->wpr = temp;
  399. /* reset wpen bit */
  400. gpio_x->wpr = pins;
  401. /* set wpen bit */
  402. gpio_x->wpr = temp;
  403. /* read wpen bit*/
  404. temp = gpio_x->wpr;
  405. /* read wpen bit*/
  406. temp = gpio_x->wpr;
  407. }
  408. /**
  409. * @brief select the gpio pin used as event output.
  410. * @param gpio_port_source: select the gpio port to be used as source
  411. * for event output.
  412. * this parameter can be one of the following values:
  413. * - GPIO_PORT_SOURCE_GPIOA
  414. * - GPIO_PORT_SOURCE_GPIOB
  415. * - GPIO_PORT_SOURCE_GPIOC
  416. * - GPIO_PORT_SOURCE_GPIOD
  417. * - GPIO_PORT_SOURCE_GPIOF
  418. * @param gpio_pin_source: specifies the pin for the event output.
  419. * this parameter can be one of the following values:
  420. * - GPIO_PINS_SOURCE0
  421. * - GPIO_PINS_SOURCE1
  422. * - GPIO_PINS_SOURCE2
  423. * - GPIO_PINS_SOURCE3
  424. * - GPIO_PINS_SOURCE4
  425. * - GPIO_PINS_SOURCE5
  426. * - GPIO_PINS_SOURCE6
  427. * - GPIO_PINS_SOURCE7
  428. * - GPIO_PINS_SOURCE8
  429. * - GPIO_PINS_SOURCE9
  430. * - GPIO_PINS_SOURCE10
  431. * - GPIO_PINS_SOURCE11
  432. * - GPIO_PINS_SOURCE12
  433. * - GPIO_PINS_SOURCE13
  434. * - GPIO_PINS_SOURCE14
  435. * - GPIO_PINS_SOURCE15
  436. * @retval none
  437. */
  438. void gpio_event_output_config(gpio_port_source_type gpio_port_source, gpio_pins_source_type gpio_pin_source)
  439. {
  440. uint32_t tmpreg = 0x00;
  441. tmpreg = IOMUX->evtout;
  442. /* clear the port[6:4] and pin[3:0] bits */
  443. tmpreg &= 0x80;
  444. tmpreg |= (uint32_t)gpio_port_source << 0x04;
  445. tmpreg |= gpio_pin_source;
  446. IOMUX->evtout = tmpreg;
  447. }
  448. /**
  449. * @brief enable or disable the event output.
  450. * @param confirm_state: new state of the event output.
  451. * this parameter can be: TRUE or FALSE.
  452. * @retval none
  453. */
  454. void gpio_event_output_enable(confirm_state new_state)
  455. {
  456. IOMUX->evtout_bit.evoen = new_state;
  457. }
  458. /**
  459. * @brief iomux remap and debug i/o configuration.
  460. * @param gpio_remap: select the pin to remap.
  461. * this parameter can be one of the following values:
  462. * - SPI1_MUX_01 - I2C1_MUX - USART1_MUX - USART3_MUX_01
  463. * - TMR1_MUX_01 - TMR2_MUX_01 - TMR2_MUX_10 - TMR2_MUX_11
  464. * - TMR3_MUX_10 - TMR3_MUX_11 - CAN_MUX_10 - PD01_MUX
  465. * - TMR5CH4_MUX - ADC1_EXTRGPRE_MUX - ADC1_EXTRGORD_MUX - ADC2_EXTRGPRE_MUX
  466. * - ADC2_EXTRGORD_MUX - SWJTAG_CONF_001 - SWJTAG_CONF_010 - SWJTAG_CONF_100
  467. * - EXT_SPIM_EN_MUX - TMR9_GMUX - TMR10_GMUX - TMR11_GMUX
  468. * - TMR1_GMUX_0001 - TMR2_GMUX_001 - TMR2_GMUX_010 - TMR2_GMUX_011
  469. * - TMR2ITR1_GMUX - TMR3_GMUX_0010 - TMR3_GMUX_0011 - TMR5_GMUX_001
  470. * - TMR5CH4_GMUX - I2C1_GMUX_0001 - I2C1_GMUX_0011 - I2C2_GMUX_0001
  471. * - I2C2_GMUX_0010 - I2C2_GMUX_0011 - SPI1_GMUX_0001 - SPI2_GMUX_0001
  472. * - CAN1_GMUX_0010 - CAN2_GMUX_0001 - SDIO1_GMUX_0100 - SDIO1_GMUX_0101
  473. * - SDIO1_GMUX_0110 - SDIO1_GMUX_0111 - USART1_GMUX_0001 - USART3_GMUX_0001
  474. * - UART4_GMUX_0001 - EXT_SPIM_GMUX_1000 - EXT_SPIM_GMUX_1001 - ADC1_ETP_GMUX
  475. * - ADC1_ETO_GMUX - ADC2_ETP_GMUX - ADC2_ETO_GMUX - SWJTAG_GMUX_001
  476. * - SWJTAG_GMUX_010 - SWJTAG_GMUX_100 - PD01_GMUX
  477. * @param new_state: (TRUE or FALSE)
  478. * @retval none
  479. */
  480. void gpio_pin_remap_config(uint32_t gpio_remap, confirm_state new_state)
  481. {
  482. uint32_t reg_addr, remap_mask;
  483. uint8_t bit_offset, bit_num, bit_val;
  484. /* get register address, bit offset, bit number and remap value */
  485. reg_addr = IOMUX_BASE + (gpio_remap >> 24);
  486. bit_offset = (gpio_remap >> 16) & 0xFF;
  487. bit_num = (gpio_remap >> 8) & 0xFF;
  488. bit_val = gpio_remap & 0xFF;
  489. /* get remap mask value */
  490. remap_mask = 0xFFFFFFFF << (32 - bit_num - bit_offset);
  491. remap_mask = remap_mask >> (32 - bit_num - bit_offset);
  492. remap_mask = remap_mask >> bit_offset;
  493. remap_mask = remap_mask << bit_offset;
  494. /* clear remap value */
  495. *(uint32_t*)reg_addr &= ~remap_mask;
  496. if(new_state != FALSE)
  497. {
  498. /* set remap value */
  499. *(uint32_t*)reg_addr |= (uint32_t)(bit_val << bit_offset);
  500. }
  501. }
  502. /**
  503. * @brief select the gpio pin used as exint line.
  504. * @param gpio_port_source: select the gpio port to be used as source for exint.
  505. * this parameter can be one of the following values:
  506. * - GPIO_PORT_SOURCE_GPIOA
  507. * - GPIO_PORT_SOURCE_GPIOB
  508. * - GPIO_PORT_SOURCE_GPIOC
  509. * - GPIO_PORT_SOURCE_GPIOD
  510. * - GPIO_PORT_SOURCE_GPIOF
  511. * @param gpio_pin_source: specifies the pin for the event output.
  512. * this parameter can be one of the following values:
  513. * - GPIO_PINS_SOURCE0
  514. * - GPIO_PINS_SOURCE1
  515. * - GPIO_PINS_SOURCE2
  516. * - GPIO_PINS_SOURCE3
  517. * - GPIO_PINS_SOURCE4
  518. * - GPIO_PINS_SOURCE5
  519. * - GPIO_PINS_SOURCE6
  520. * - GPIO_PINS_SOURCE7
  521. * - GPIO_PINS_SOURCE8
  522. * - GPIO_PINS_SOURCE9
  523. * - GPIO_PINS_SOURCE10
  524. * - GPIO_PINS_SOURCE11
  525. * - GPIO_PINS_SOURCE12
  526. * - GPIO_PINS_SOURCE13
  527. * - GPIO_PINS_SOURCE14
  528. * - GPIO_PINS_SOURCE15
  529. * @retval none
  530. */
  531. void gpio_exint_line_config(gpio_port_source_type gpio_port_source, gpio_pins_source_type gpio_pin_source)
  532. {
  533. uint32_t tmp = 0x00;
  534. tmp = ((uint32_t)0x0F) << (0x04 * (gpio_pin_source & (uint8_t)0x03));
  535. switch (gpio_pin_source >> 0x02)
  536. {
  537. case 0:
  538. IOMUX->exintc1 &= ~tmp;
  539. IOMUX->exintc1 |= (((uint32_t)gpio_port_source) << (0x04 * (gpio_pin_source & (uint8_t)0x03)));
  540. break;
  541. case 1:
  542. IOMUX->exintc2 &= ~tmp;
  543. IOMUX->exintc2 |= (((uint32_t)gpio_port_source) << (0x04 * (gpio_pin_source & (uint8_t)0x03)));
  544. break;
  545. case 2:
  546. IOMUX->exintc3 &= ~tmp;
  547. IOMUX->exintc3 |= (((uint32_t)gpio_port_source) << (0x04 * (gpio_pin_source & (uint8_t)0x03)));
  548. break;
  549. case 3:
  550. IOMUX->exintc4 &= ~tmp;
  551. IOMUX->exintc4 |= (((uint32_t)gpio_port_source) << (0x04 * (gpio_pin_source & (uint8_t)0x03)));
  552. break;
  553. default:
  554. break;
  555. }
  556. }
  557. /**
  558. * @}
  559. */
  560. #endif
  561. /**
  562. * @}
  563. */
  564. /**
  565. * @}
  566. */