1 /* --COPYRIGHT--,BSD 2 * Copyright (c) 2017, Texas Instruments Incorporated 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the name of Texas Instruments Incorporated nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * --/COPYRIGHT--*/ 32 #ifndef __GPIO_H__ 33 #define __GPIO_H__ 34 35 //***************************************************************************** 36 // 37 //! \addtogroup gpio_api 38 //! @{ 39 // 40 //***************************************************************************** 41 42 //***************************************************************************** 43 // 44 // If building with a C++ compiler, make all of the definitions in this header 45 // have a C binding. 46 // 47 //***************************************************************************** 48 #ifdef __cplusplus 49 extern "C" 50 { 51 #endif 52 53 #include <ti/devices/msp432p4xx/inc/msp.h> 54 #include <stdint.h> 55 56 #define GPIO_PORT_P1 1 57 #define GPIO_PORT_P2 2 58 #define GPIO_PORT_P3 3 59 #define GPIO_PORT_P4 4 60 #define GPIO_PORT_P5 5 61 #define GPIO_PORT_P6 6 62 #define GPIO_PORT_P7 7 63 #define GPIO_PORT_P8 8 64 #define GPIO_PORT_P9 9 65 #define GPIO_PORT_P10 10 66 #define GPIO_PORT_PA 1 67 #define GPIO_PORT_PB 3 68 #define GPIO_PORT_PC 5 69 #define GPIO_PORT_PD 7 70 #define GPIO_PORT_PE 9 71 #define GPIO_PORT_PJ 11 72 73 74 #define GPIO_PIN0 (0x0001) 75 #define GPIO_PIN1 (0x0002) 76 #define GPIO_PIN2 (0x0004) 77 #define GPIO_PIN3 (0x0008) 78 #define GPIO_PIN4 (0x0010) 79 #define GPIO_PIN5 (0x0020) 80 #define GPIO_PIN6 (0x0040) 81 #define GPIO_PIN7 (0x0080) 82 #define GPIO_PIN8 (0x0100) 83 #define GPIO_PIN9 (0x0200) 84 #define GPIO_PIN10 (0x0400) 85 #define GPIO_PIN11 (0x0800) 86 #define GPIO_PIN12 (0x1000) 87 #define GPIO_PIN13 (0x2000) 88 #define GPIO_PIN14 (0x4000) 89 #define GPIO_PIN15 (0x8000) 90 #define PIN_ALL8 (0xFF) 91 #define PIN_ALL16 (0xFFFF) 92 93 #define GPIO_PRIMARY_MODULE_FUNCTION (0x01) 94 #define GPIO_SECONDARY_MODULE_FUNCTION (0x02) 95 #define GPIO_TERTIARY_MODULE_FUNCTION (0x03) 96 97 #define GPIO_HIGH_TO_LOW_TRANSITION (0x01) 98 #define GPIO_LOW_TO_HIGH_TRANSITION (0x00) 99 100 #define GPIO_INPUT_PIN_HIGH (0x01) 101 #define GPIO_INPUT_PIN_LOW (0x00) 102 103 /* DriverLib internal GPIO register offset for optimized performance */ 104 #define OFS_LIB_PAIN ((uint32_t)&P1->IN - (uint32_t)P1) 105 #define OFS_LIB_PAOUT ((uint32_t)&P1->OUT - (uint32_t)P1) 106 #define OFS_LIB_PADIR ((uint32_t)&P1->DIR - (uint32_t)P1) 107 #define OFS_LIB_PAREN ((uint32_t)&P1->REN - (uint32_t)P1) 108 #define OFS_LIB_PADS ((uint32_t)&P1->DS - (uint32_t)P1) 109 #define OFS_LIB_PASEL0 ((uint32_t)&P1->SEL0 - (uint32_t)P1) 110 #define OFS_LIB_PASEL1 ((uint32_t)&P1->SEL1 - (uint32_t)P1) 111 #define OFS_LIB_PAIE ((uint32_t)&P1->IE - (uint32_t)P1) 112 #define OFS_LIB_PAIES ((uint32_t)&P1->IES - (uint32_t)P1) 113 #define OFS_LIB_PAIFG ((uint32_t)&P1->IFG - (uint32_t)P1) 114 #define OFS_LIB_P1IE ((uint32_t)&P1->IE - (uint32_t)P1) 115 #define OFS_LIB_P2IE OFS_LIB_P1IE 116 117 //***************************************************************************** 118 // 119 // Prototypes for the APIs. 120 // 121 //***************************************************************************** 122 123 //***************************************************************************** 124 // 125 //! \brief This function configures the selected Pin as output pin 126 //! 127 //! This function selected pins on a selected port as output pins. 128 //! 129 //! \param selectedPort is the selected port. 130 //! Valid values are: 131 //! - \b GPIO_PORT_P1 132 //! - \b GPIO_PORT_P2 133 //! - \b GPIO_PORT_P3 134 //! - \b GPIO_PORT_P4 135 //! - \b GPIO_PORT_P5 136 //! - \b GPIO_PORT_P6 137 //! - \b GPIO_PORT_P7 138 //! - \b GPIO_PORT_P8 139 //! - \b GPIO_PORT_P9 140 //! - \b GPIO_PORT_P10 141 //! - \b GPIO_PORT_P11 142 //! - \b GPIO_PORT_PJ 143 //! \param selectedPins is the specified pin in the selected port. 144 //! Mask value is the logical OR of any of the following: 145 //! - \b GPIO_PIN0 146 //! - \b GPIO_PIN1 147 //! - \b GPIO_PIN2 148 //! - \b GPIO_PIN3 149 //! - \b GPIO_PIN4 150 //! - \b GPIO_PIN5 151 //! - \b GPIO_PIN6 152 //! - \b GPIO_PIN7 153 //! - \b GPIO_PIN8 154 //! - \b GPIO_PIN9 155 //! - \b GPIO_PIN10 156 //! - \b GPIO_PIN11 157 //! - \b GPIO_PIN12 158 //! - \b GPIO_PIN13 159 //! - \b GPIO_PIN14 160 //! - \b GPIO_PIN15 161 //! 162 //! Modified bits of \b PxDIR register and bits of \b PxSEL register. 163 //! 164 //! \return None 165 // 166 //***************************************************************************** 167 extern void GPIO_setAsOutputPin(uint_fast8_t selectedPort, 168 uint_fast16_t selectedPins); 169 170 //***************************************************************************** 171 // 172 //! \brief This function configures the selected Pin as input pin 173 //! 174 //! This function selected pins on a selected port as input pins. 175 //! 176 //! \param selectedPort is the selected port. 177 //! Valid values are: 178 //! - \b GPIO_PORT_P1 179 //! - \b GPIO_PORT_P2 180 //! - \b GPIO_PORT_P3 181 //! - \b GPIO_PORT_P4 182 //! - \b GPIO_PORT_P5 183 //! - \b GPIO_PORT_P6 184 //! - \b GPIO_PORT_P7 185 //! - \b GPIO_PORT_P8 186 //! - \b GPIO_PORT_P9 187 //! - \b GPIO_PORT_P10 188 //! - \b GPIO_PORT_P11 189 //! - \b GPIO_PORT_PJ 190 //! \param selectedPins is the specified pin in the selected port. 191 //! Mask value is the logical OR of any of the following: 192 //! - \b GPIO_PIN0 193 //! - \b GPIO_PIN1 194 //! - \b GPIO_PIN2 195 //! - \b GPIO_PIN3 196 //! - \b GPIO_PIN4 197 //! - \b GPIO_PIN5 198 //! - \b GPIO_PIN6 199 //! - \b GPIO_PIN7 200 //! - \b GPIO_PIN8 201 //! - \b GPIO_PIN9 202 //! - \b GPIO_PIN10 203 //! - \b GPIO_PIN11 204 //! - \b GPIO_PIN12 205 //! - \b GPIO_PIN13 206 //! - \b GPIO_PIN14 207 //! - \b GPIO_PIN15 208 //! 209 //! Modified bits of \b PxDIR register, bits of \b PxREN register and bits of 210 //! \b PxSEL register. 211 //! 212 //! \return None 213 // 214 //***************************************************************************** 215 extern void GPIO_setAsInputPin(uint_fast8_t selectedPort, 216 uint_fast16_t selectedPins); 217 218 //***************************************************************************** 219 // 220 //! \brief This function configures the peripheral module function in the 221 //! output direction for the selected pin for either primary, secondary or 222 //! ternary module function modes 223 //! 224 //! This function configures the peripheral module function in the output 225 //! direction for the selected pin for either primary, secondary or ternary 226 //! module function modes. Accepted values for mode are 227 //! GPIO_PRIMARY_MODULE_FUNCTION, GPIO_SECONDARY_MODULE_FUNCTION, and 228 //! GPIO_TERTIARY_MODULE_FUNCTION 229 //! 230 //! \param selectedPort is the selected port. 231 //! Valid values are: 232 //! - \b GPIO_PORT_P1 233 //! - \b GPIO_PORT_P2 234 //! - \b GPIO_PORT_P3 235 //! - \b GPIO_PORT_P4 236 //! - \b GPIO_PORT_P5 237 //! - \b GPIO_PORT_P6 238 //! - \b GPIO_PORT_P7 239 //! - \b GPIO_PORT_P8 240 //! - \b GPIO_PORT_P9 241 //! - \b GPIO_PORT_P10 242 //! - \b GPIO_PORT_P11 243 //! - \b GPIO_PORT_PJ 244 //! \param selectedPins is the specified pin in the selected port. 245 //! Mask value is the logical OR of any of the following: 246 //! - \b GPIO_PIN0 247 //! - \b GPIO_PIN1 248 //! - \b GPIO_PIN2 249 //! - \b GPIO_PIN3 250 //! - \b GPIO_PIN4 251 //! - \b GPIO_PIN5 252 //! - \b GPIO_PIN6 253 //! - \b GPIO_PIN7 254 //! - \b GPIO_PIN8 255 //! - \b GPIO_PIN9 256 //! - \b GPIO_PIN10 257 //! - \b GPIO_PIN11 258 //! - \b GPIO_PIN12 259 //! - \b GPIO_PIN13 260 //! - \b GPIO_PIN14 261 //! - \b GPIO_PIN15 262 //! \param mode is the specified mode that the pin should be configured for the 263 //! module function. 264 //! Valid values are: 265 //! - \b GPIO_PRIMARY_MODULE_FUNCTION 266 //! - \b GPIO_SECONDARY_MODULE_FUNCTION 267 //! - \b GPIO_TERTIARY_MODULE_FUNCTION 268 //! 269 //! Modified bits of \b PxDIR register and bits of \b PxSEL register. 270 //! 271 //! \return None 272 // 273 //***************************************************************************** 274 extern void GPIO_setAsPeripheralModuleFunctionOutputPin( 275 uint_fast8_t selectedPort, uint_fast16_t selectedPins, 276 uint_fast8_t mode); 277 278 //***************************************************************************** 279 // 280 //! \brief This function configures the peripheral module function in the input 281 //! direction for the selected pin for either primary, secondary or ternary 282 //! module function modes. 283 //! 284 //! This function configures the peripheral module function in the input 285 //! direction for the selected pin for either primary, secondary or ternary 286 //! module function modes. Accepted values for mode are 287 //! GPIO_PRIMARY_MODULE_FUNCTION, GPIO_SECONDARY_MODULE_FUNCTION, and 288 //! GPIO_TERTIARY_MODULE_FUNCTION 289 //! 290 //! \param selectedPort is the selected port. 291 //! Valid values are: 292 //! - \b GPIO_PORT_P1 293 //! - \b GPIO_PORT_P2 294 //! - \b GPIO_PORT_P3 295 //! - \b GPIO_PORT_P4 296 //! - \b GPIO_PORT_P5 297 //! - \b GPIO_PORT_P6 298 //! - \b GPIO_PORT_P7 299 //! - \b GPIO_PORT_P8 300 //! - \b GPIO_PORT_P9 301 //! - \b GPIO_PORT_P10 302 //! - \b GPIO_PORT_P11 303 //! - \b GPIO_PORT_PJ 304 //! \param selectedPins is the specified pin in the selected port. 305 //! Mask value is the logical OR of any of the following: 306 //! - \b GPIO_PIN0 307 //! - \b GPIO_PIN1 308 //! - \b GPIO_PIN2 309 //! - \b GPIO_PIN3 310 //! - \b GPIO_PIN4 311 //! - \b GPIO_PIN5 312 //! - \b GPIO_PIN6 313 //! - \b GPIO_PIN7 314 //! - \b GPIO_PIN8 315 //! - \b GPIO_PIN9 316 //! - \b GPIO_PIN10 317 //! - \b GPIO_PIN11 318 //! - \b GPIO_PIN12 319 //! - \b GPIO_PIN13 320 //! - \b GPIO_PIN14 321 //! - \b GPIO_PIN15 322 //! \param mode is the specified mode that the pin should be configured for the 323 //! module function. 324 //! Valid values are: 325 //! - \b GPIO_PRIMARY_MODULE_FUNCTION 326 //! - \b GPIO_SECONDARY_MODULE_FUNCTION 327 //! - \b GPIO_TERTIARY_MODULE_FUNCTION 328 //! 329 //! Modified bits of \b PxDIR register and bits of \b PxSEL register. 330 //! 331 //! \return None 332 // 333 //***************************************************************************** 334 extern void GPIO_setAsPeripheralModuleFunctionInputPin( 335 uint_fast8_t selectedPort, uint_fast16_t selectedPins, 336 uint_fast8_t mode); 337 338 //***************************************************************************** 339 // 340 //! \brief This function sets output HIGH on the selected Pin 341 //! 342 //! This function sets output HIGH on the selected port's pin. 343 //! 344 //! \param selectedPort is the selected port. 345 //! Valid values are: 346 //! - \b GPIO_PORT_P1 347 //! - \b GPIO_PORT_P2 348 //! - \b GPIO_PORT_P3 349 //! - \b GPIO_PORT_P4 350 //! - \b GPIO_PORT_P5 351 //! - \b GPIO_PORT_P6 352 //! - \b GPIO_PORT_P7 353 //! - \b GPIO_PORT_P8 354 //! - \b GPIO_PORT_P9 355 //! - \b GPIO_PORT_P10 356 //! - \b GPIO_PORT_P11 357 //! - \b GPIO_PORT_PJ 358 //! \param selectedPins is the specified pin in the selected port. 359 //! Mask value is the logical OR of any of the following: 360 //! - \b GPIO_PIN0 361 //! - \b GPIO_PIN1 362 //! - \b GPIO_PIN2 363 //! - \b GPIO_PIN3 364 //! - \b GPIO_PIN4 365 //! - \b GPIO_PIN5 366 //! - \b GPIO_PIN6 367 //! - \b GPIO_PIN7 368 //! - \b GPIO_PIN8 369 //! - \b GPIO_PIN9 370 //! - \b GPIO_PIN10 371 //! - \b GPIO_PIN11 372 //! - \b GPIO_PIN12 373 //! - \b GPIO_PIN13 374 //! - \b GPIO_PIN14 375 //! - \b GPIO_PIN15 376 //! 377 //! Modified bits of \b PxOUT register. 378 //! 379 //! \return None 380 // 381 //***************************************************************************** 382 extern void GPIO_setOutputHighOnPin(uint_fast8_t selectedPort, 383 uint_fast16_t selectedPins); 384 385 //***************************************************************************** 386 // 387 //! \brief This function sets output LOW on the selected Pin 388 //! 389 //! This function sets output LOW on the selected port's pin. 390 //! 391 //! \param selectedPort is the selected port. 392 //! Valid values are: 393 //! - \b GPIO_PORT_P1 394 //! - \b GPIO_PORT_P2 395 //! - \b GPIO_PORT_P3 396 //! - \b GPIO_PORT_P4 397 //! - \b GPIO_PORT_P5 398 //! - \b GPIO_PORT_P6 399 //! - \b GPIO_PORT_P7 400 //! - \b GPIO_PORT_P8 401 //! - \b GPIO_PORT_P9 402 //! - \b GPIO_PORT_P10 403 //! - \b GPIO_PORT_P11 404 //! - \b GPIO_PORT_PJ 405 //! \param selectedPins is the specified pin in the selected port. 406 //! Mask value is the logical OR of any of the following: 407 //! - \b GPIO_PIN0 408 //! - \b GPIO_PIN1 409 //! - \b GPIO_PIN2 410 //! - \b GPIO_PIN3 411 //! - \b GPIO_PIN4 412 //! - \b GPIO_PIN5 413 //! - \b GPIO_PIN6 414 //! - \b GPIO_PIN7 415 //! - \b GPIO_PIN8 416 //! - \b GPIO_PIN9 417 //! - \b GPIO_PIN10 418 //! - \b GPIO_PIN11 419 //! - \b GPIO_PIN12 420 //! - \b GPIO_PIN13 421 //! - \b GPIO_PIN14 422 //! - \b GPIO_PIN15 423 //! 424 //! \return None 425 // 426 //***************************************************************************** 427 extern void GPIO_setOutputLowOnPin(uint_fast8_t selectedPort, 428 uint_fast16_t selectedPins); 429 430 //***************************************************************************** 431 // 432 //! \brief This function toggles the output on the selected Pin 433 //! 434 //! This function toggles the output on the selected port's pin. 435 //! 436 //! \param selectedPort is the selected port. 437 //! Valid values are: 438 //! - \b GPIO_PORT_P1 439 //! - \b GPIO_PORT_P2 440 //! - \b GPIO_PORT_P3 441 //! - \b GPIO_PORT_P4 442 //! - \b GPIO_PORT_P5 443 //! - \b GPIO_PORT_P6 444 //! - \b GPIO_PORT_P7 445 //! - \b GPIO_PORT_P8 446 //! - \b GPIO_PORT_P9 447 //! - \b GPIO_PORT_P10 448 //! - \b GPIO_PORT_P11 449 //! - \b GPIO_PORT_PJ 450 //! \param selectedPins is the specified pin in the selected port. 451 //! Mask value is the logical OR of any of the following: 452 //! - \b GPIO_PIN0 453 //! - \b GPIO_PIN1 454 //! - \b GPIO_PIN2 455 //! - \b GPIO_PIN3 456 //! - \b GPIO_PIN4 457 //! - \b GPIO_PIN5 458 //! - \b GPIO_PIN6 459 //! - \b GPIO_PIN7 460 //! - \b GPIO_PIN8 461 //! - \b GPIO_PIN9 462 //! - \b GPIO_PIN10 463 //! - \b GPIO_PIN11 464 //! - \b GPIO_PIN12 465 //! - \b GPIO_PIN13 466 //! - \b GPIO_PIN14 467 //! - \b GPIO_PIN15 468 //! 469 //! Modified bits of \b PxOUT register. 470 //! 471 //! \return None 472 // 473 //***************************************************************************** 474 extern void GPIO_toggleOutputOnPin(uint_fast8_t selectedPort, 475 uint_fast16_t selectedPins); 476 477 //***************************************************************************** 478 // 479 //! \brief This function sets the selected Pin in input Mode with Pull Down 480 //! resistor 481 //! 482 //! This function sets the selected Pin in input Mode with Pull Down resistor. 483 //! 484 //! \param selectedPort is the selected port. 485 //! Valid values are: 486 //! - \b GPIO_PORT_P1 487 //! - \b GPIO_PORT_P2 488 //! - \b GPIO_PORT_P3 489 //! - \b GPIO_PORT_P4 490 //! - \b GPIO_PORT_P5 491 //! - \b GPIO_PORT_P6 492 //! - \b GPIO_PORT_P7 493 //! - \b GPIO_PORT_P8 494 //! - \b GPIO_PORT_P9 495 //! - \b GPIO_PORT_P10 496 //! - \b GPIO_PORT_P11 497 //! - \b GPIO_PORT_PJ 498 //! \param selectedPins is the specified pin in the selected port. 499 //! Mask value is the logical OR of any of the following: 500 //! - \b GPIO_PIN0 501 //! - \b GPIO_PIN1 502 //! - \b GPIO_PIN2 503 //! - \b GPIO_PIN3 504 //! - \b GPIO_PIN4 505 //! - \b GPIO_PIN5 506 //! - \b GPIO_PIN6 507 //! - \b GPIO_PIN7 508 //! - \b GPIO_PIN8 509 //! - \b GPIO_PIN9 510 //! - \b GPIO_PIN10 511 //! - \b GPIO_PIN11 512 //! - \b GPIO_PIN12 513 //! - \b GPIO_PIN13 514 //! - \b GPIO_PIN14 515 //! - \b GPIO_PIN15 516 //! 517 //! Modified bits of \b PxDIR register, bits of \b PxOUT register and bits of 518 //! \b PxREN register. 519 //! 520 //! \return None 521 // 522 //***************************************************************************** 523 extern void GPIO_setAsInputPinWithPullDownResistor(uint_fast8_t selectedPort, 524 uint_fast16_t selectedPins); 525 526 //***************************************************************************** 527 // 528 //! \brief This function sets the selected Pin in input Mode with Pull Up 529 //! resistor 530 //! 531 //! This function sets the selected Pin in input Mode with Pull Up resistor. 532 //! 533 //! \param selectedPort is the selected port. 534 //! Valid values are: 535 //! - \b GPIO_PORT_P1 536 //! - \b GPIO_PORT_P2 537 //! - \b GPIO_PORT_P3 538 //! - \b GPIO_PORT_P4 539 //! - \b GPIO_PORT_P5 540 //! - \b GPIO_PORT_P6 541 //! - \b GPIO_PORT_P7 542 //! - \b GPIO_PORT_P8 543 //! - \b GPIO_PORT_P9 544 //! - \b GPIO_PORT_P10 545 //! - \b GPIO_PORT_P11 546 //! - \b GPIO_PORT_PJ 547 //! \param selectedPins is the specified pin in the selected port. 548 //! Mask value is the logical OR of any of the following: 549 //! - \b GPIO_PIN0 550 //! - \b GPIO_PIN1 551 //! - \b GPIO_PIN2 552 //! - \b GPIO_PIN3 553 //! - \b GPIO_PIN4 554 //! - \b GPIO_PIN5 555 //! - \b GPIO_PIN6 556 //! - \b GPIO_PIN7 557 //! - \b GPIO_PIN8 558 //! - \b GPIO_PIN9 559 //! - \b GPIO_PIN10 560 //! - \b GPIO_PIN11 561 //! - \b GPIO_PIN12 562 //! - \b GPIO_PIN13 563 //! - \b GPIO_PIN14 564 //! - \b GPIO_PIN15 565 //! 566 //! Modified bits of \b PxDIR register, bits of \b PxOUT register and bits of 567 //! \b PxREN register. 568 //! 569 //! \return None 570 // 571 //***************************************************************************** 572 extern void GPIO_setAsInputPinWithPullUpResistor(uint_fast8_t selectedPort, 573 uint_fast16_t selectedPins); 574 575 //***************************************************************************** 576 // 577 //! \brief This function gets the input value on the selected pin 578 //! 579 //! This function gets the input value on the selected pin. 580 //! 581 //! \param selectedPort is the selected port. 582 //! Valid values are: 583 //! - \b GPIO_PORT_P1 584 //! - \b GPIO_PORT_P2 585 //! - \b GPIO_PORT_P3 586 //! - \b GPIO_PORT_P4 587 //! - \b GPIO_PORT_P5 588 //! - \b GPIO_PORT_P6 589 //! - \b GPIO_PORT_P7 590 //! - \b GPIO_PORT_P8 591 //! - \b GPIO_PORT_P9 592 //! - \b GPIO_PORT_P10 593 //! - \b GPIO_PORT_P11 594 //! - \b GPIO_PORT_PJ 595 //! \param selectedPins is the specified pin in the selected port. 596 //! Valid values are: 597 //! - \b GPIO_PIN0 598 //! - \b GPIO_PIN1 599 //! - \b GPIO_PIN2 600 //! - \b GPIO_PIN3 601 //! - \b GPIO_PIN4 602 //! - \b GPIO_PIN5 603 //! - \b GPIO_PIN6 604 //! - \b GPIO_PIN7 605 //! - \b GPIO_PIN8 606 //! - \b GPIO_PIN9 607 //! - \b GPIO_PIN10 608 //! - \b GPIO_PIN11 609 //! - \b GPIO_PIN12 610 //! - \b GPIO_PIN13 611 //! - \b GPIO_PIN14 612 //! - \b GPIO_PIN15 613 //! 614 //! \return One of the following: 615 //! - \b GPIO_INPUT_PIN_HIGH 616 //! - \b GPIO_INPUT_PIN_LOW 617 //! \n indicating the status of the pin 618 // 619 //***************************************************************************** 620 extern uint8_t GPIO_getInputPinValue(uint_fast8_t selectedPort, 621 uint_fast16_t selectedPins); 622 623 //***************************************************************************** 624 // 625 //! \brief This function enables the port interrupt on the selected pin 626 //! 627 //! This function enables the port interrupt on the selected pin. Note that 628 //! only Port 1,2, A have this capability. 629 //! 630 //! \param selectedPort is the selected port. 631 //! Valid values are: 632 //! - \b GPIO_PORT_P1 633 //! - \b GPIO_PORT_P2 634 //! - \b GPIO_PORT_PA 635 //! \param selectedPins is the specified pin in the selected port. 636 //! Mask value is the logical OR of any of the following: 637 //! - \b GPIO_PIN0 638 //! - \b GPIO_PIN1 639 //! - \b GPIO_PIN2 640 //! - \b GPIO_PIN3 641 //! - \b GPIO_PIN4 642 //! - \b GPIO_PIN5 643 //! - \b GPIO_PIN6 644 //! - \b GPIO_PIN7 645 //! - \b GPIO_PIN8 646 //! - \b GPIO_PIN9 647 //! - \b GPIO_PIN10 648 //! - \b GPIO_PIN11 649 //! - \b GPIO_PIN12 650 //! - \b GPIO_PIN13 651 //! - \b GPIO_PIN14 652 //! - \b GPIO_PIN15 653 //! 654 //! Modified bits of \b PxIE register. 655 //! 656 //! \return None 657 // 658 //***************************************************************************** 659 extern void GPIO_enableInterrupt(uint_fast8_t selectedPort, 660 uint_fast16_t selectedPins); 661 662 //***************************************************************************** 663 // 664 //! \brief This function disables the port interrupt on the selected pin 665 //! 666 //! This function disables the port interrupt on the selected pin. Note that 667 //! only Port 1,2, A have this capability. 668 //! 669 //! \param selectedPort is the selected port. 670 //! Valid values are: 671 //! - \b GPIO_PORT_P1 672 //! - \b GPIO_PORT_P2 673 //! - \b GPIO_PORT_PA 674 //! \param selectedPins is the specified pin in the selected port. 675 //! Mask value is the logical OR of any of the following: 676 //! - \b GPIO_PIN0 677 //! - \b GPIO_PIN1 678 //! - \b GPIO_PIN2 679 //! - \b GPIO_PIN3 680 //! - \b GPIO_PIN4 681 //! - \b GPIO_PIN5 682 //! - \b GPIO_PIN6 683 //! - \b GPIO_PIN7 684 //! - \b GPIO_PIN8 685 //! - \b GPIO_PIN9 686 //! - \b GPIO_PIN10 687 //! - \b GPIO_PIN11 688 //! - \b GPIO_PIN12 689 //! - \b GPIO_PIN13 690 //! - \b GPIO_PIN14 691 //! - \b GPIO_PIN15 692 //! 693 //! Modified bits of \b PxIE register. 694 //! 695 //! \return None 696 // 697 //***************************************************************************** 698 extern void GPIO_disableInterrupt(uint_fast8_t selectedPort, 699 uint_fast16_t selectedPins); 700 701 //***************************************************************************** 702 // 703 //! \brief This function gets the interrupt status of the selected pin 704 //! 705 //! This function gets the interrupt status of the selected pin. 706 //! 707 //! \param selectedPort is the selected port. 708 //! Valid values are: 709 //! - \b GPIO_PORT_P1 710 //! - \b GPIO_PORT_P2 711 //! - \b GPIO_PORT_PA 712 //! \param selectedPins is the specified pin in the selected port. 713 //! Mask value is the logical OR of any of the following: 714 //! - \b GPIO_PIN0 715 //! - \b GPIO_PIN1 716 //! - \b GPIO_PIN2 717 //! - \b GPIO_PIN3 718 //! - \b GPIO_PIN4 719 //! - \b GPIO_PIN5 720 //! - \b GPIO_PIN6 721 //! - \b GPIO_PIN7 722 //! - \b GPIO_PIN8 723 //! - \b GPIO_PIN9 724 //! - \b GPIO_PIN10 725 //! - \b GPIO_PIN11 726 //! - \b GPIO_PIN12 727 //! - \b GPIO_PIN13 728 //! - \b GPIO_PIN14 729 //! - \b GPIO_PIN15 730 //! 731 //! \return Logical OR of any of the following: 732 //! - \b GPIO_PIN0 733 //! - \b GPIO_PIN1 734 //! - \b GPIO_PIN2 735 //! - \b GPIO_PIN3 736 //! - \b GPIO_PIN4 737 //! - \b GPIO_PIN5 738 //! - \b GPIO_PIN6 739 //! - \b GPIO_PIN7 740 //! - \b GPIO_PIN8 741 //! - \b GPIO_PIN9 742 //! - \b GPIO_PIN10 743 //! - \b GPIO_PIN11 744 //! - \b GPIO_PIN12 745 //! - \b GPIO_PIN13 746 //! - \b GPIO_PIN14 747 //! - \b GPIO_PIN15 748 //! \n indicating the interrupt status of the selected pins [Default: 749 //! 0] 750 // 751 //***************************************************************************** 752 extern uint_fast16_t GPIO_getInterruptStatus(uint_fast8_t selectedPort, 753 uint_fast16_t selectedPins); 754 755 //***************************************************************************** 756 // 757 //! \brief This function clears the interrupt flag on the selected pin 758 //! 759 //! This function clears the interrupt flag on the selected pin. 760 //! 761 //! \param selectedPort is the selected port. 762 //! Valid values are: 763 //! - \b GPIO_PORT_P1 764 //! - \b GPIO_PORT_P2 765 //! - \b GPIO_PORT_PA 766 //! \param selectedPins is the specified pin in the selected port. 767 //! Mask value is the logical OR of any of the following: 768 //! - \b GPIO_PIN0 769 //! - \b GPIO_PIN1 770 //! - \b GPIO_PIN2 771 //! - \b GPIO_PIN3 772 //! - \b GPIO_PIN4 773 //! - \b GPIO_PIN5 774 //! - \b GPIO_PIN6 775 //! - \b GPIO_PIN7 776 //! - \b GPIO_PIN8 777 //! - \b GPIO_PIN9 778 //! - \b GPIO_PIN10 779 //! - \b GPIO_PIN11 780 //! - \b GPIO_PIN12 781 //! - \b GPIO_PIN13 782 //! - \b GPIO_PIN14 783 //! - \b GPIO_PIN15 784 //! 785 //! Modified bits of \b PxIFG register. 786 //! 787 //! \return None 788 // 789 //***************************************************************************** 790 extern void GPIO_clearInterruptFlag(uint_fast8_t selectedPort, 791 uint_fast16_t selectedPins); 792 793 //***************************************************************************** 794 // 795 //! \brief This function selects on what edge the port interrupt flag should be 796 //! set for a transition 797 //! 798 //! This function selects on what edge the port interrupt flag should be set 799 //! for a transition. Values for edgeSelect should be 800 //! GPIO_LOW_TO_HIGH_TRANSITION or GPIO_HIGH_TO_LOW_TRANSITION. 801 //! 802 //! \param selectedPort is the selected port. 803 //! Valid values are: 804 //! - \b GPIO_PORT_P1 805 //! - \b GPIO_PORT_P2 806 //! - \b GPIO_PORT_P3 807 //! - \b GPIO_PORT_P4 808 //! - \b GPIO_PORT_P5 809 //! - \b GPIO_PORT_P6 810 //! - \b GPIO_PORT_P7 811 //! - \b GPIO_PORT_P8 812 //! - \b GPIO_PORT_P9 813 //! - \b GPIO_PORT_P10 814 //! - \b GPIO_PORT_P11 815 //! - \b GPIO_PORT_PJ 816 //! \param selectedPins is the specified pin in the selected port. 817 //! Mask value is the logical OR of any of the following: 818 //! - \b GPIO_PIN0 819 //! - \b GPIO_PIN1 820 //! - \b GPIO_PIN2 821 //! - \b GPIO_PIN3 822 //! - \b GPIO_PIN4 823 //! - \b GPIO_PIN5 824 //! - \b GPIO_PIN6 825 //! - \b GPIO_PIN7 826 //! - \b GPIO_PIN8 827 //! - \b GPIO_PIN9 828 //! - \b GPIO_PIN10 829 //! - \b GPIO_PIN11 830 //! - \b GPIO_PIN12 831 //! - \b GPIO_PIN13 832 //! - \b GPIO_PIN14 833 //! - \b GPIO_PIN15 834 //! \param edgeSelect specifies what transition sets the interrupt flag 835 //! Valid values are: 836 //! - \b GPIO_HIGH_TO_LOW_TRANSITION 837 //! - \b GPIO_LOW_TO_HIGH_TRANSITION 838 //! 839 //! Modified bits of \b PxIES register. 840 //! 841 //! \return None 842 // 843 //***************************************************************************** 844 extern void GPIO_interruptEdgeSelect(uint_fast8_t selectedPort, 845 uint_fast16_t selectedPins, uint_fast8_t edgeSelect); 846 847 //***************************************************************************** 848 // 849 //! \brief This function gets the interrupt status of the provided PIN and 850 //! masks it with the interrupts that are actually enabled. This is 851 //! useful for inside ISRs where the status of only the enabled 852 //! interrupts needs to be checked. 853 //! 854 //! \param selectedPort is the selected port. 855 //! Valid values are: 856 //! - \b GPIO_PORT_P1 857 //! - \b GPIO_PORT_P2 858 //! - \b GPIO_PORT_P3 859 //! - \b GPIO_PORT_P4 860 //! - \b GPIO_PORT_P5 861 //! - \b GPIO_PORT_P6 862 //! - \b GPIO_PORT_P7 863 //! - \b GPIO_PORT_P8 864 //! - \b GPIO_PORT_P9 865 //! - \b GPIO_PORT_P10 866 //! - \b GPIO_PORT_P11 867 //! - \b GPIO_PORT_PJ 868 //! 869 //! \return Logical OR of any of the following: 870 //! - \b GPIO_PIN0 871 //! - \b GPIO_PIN1 872 //! - \b GPIO_PIN2 873 //! - \b GPIO_PIN3 874 //! - \b GPIO_PIN4 875 //! - \b GPIO_PIN5 876 //! - \b GPIO_PIN6 877 //! - \b GPIO_PIN7 878 //! - \b GPIO_PIN8 879 //! - \b GPIO_PIN9 880 //! - \b GPIO_PIN10 881 //! - \b GPIO_PIN11 882 //! - \b GPIO_PIN12 883 //! - \b GPIO_PIN13 884 //! - \b GPIO_PIN14 885 //! - \b GPIO_PIN15, 886 //! - \b PIN_ALL8, 887 //! - \b PIN_ALL16 888 //! \n indicating the interrupt status of the selected pins [Default: 889 //! 0] 890 // 891 //***************************************************************************** 892 extern uint_fast16_t GPIO_getEnabledInterruptStatus(uint_fast8_t selectedPort); 893 894 895 //***************************************************************************** 896 // 897 //! Registers an interrupt handler for the port interrupt. 898 //! 899 //! \param selectedPort is the port to register the interrupt handler 900 //! 901 //! \param intHandler is a pointer to the function to be called when the port 902 //! interrupt occurs. 903 //! 904 //! This function registers the handler to be called when a port 905 //! interrupt occurs. This function enables the global interrupt in the 906 //! interrupt controller; specific GPIO interrupts must be enabled 907 //! via GPIO_enableInterrupt(). It is the interrupt handler's responsibility to 908 //! clear the interrupt source via GPIO_clearInterruptFlag(). 909 //! 910 //! Clock System can generate interrupts when 911 //! 912 //! \sa Interrupt_registerInterrupt() for important information about 913 //! registering interrupt handlers. 914 //! 915 //! \return None. 916 // 917 //***************************************************************************** 918 extern void GPIO_registerInterrupt(uint_fast8_t selectedPort, 919 void (*intHandler)(void)); 920 921 //***************************************************************************** 922 // 923 //! Unregisters the interrupt handler for the port. 924 //! 925 //! \param selectedPort is the port to unregister the interrupt handler 926 //! 927 //! This function unregisters the handler to be called when a port 928 //! interrupt occurs. This function also masks off the interrupt in the 929 //! interrupt controller so that the interrupt handler no longer is called. 930 //! 931 //! \sa Interrupt_registerInterrupt() for important information about 932 //! registering interrupt handlers. 933 //! 934 //! \return None. 935 // 936 //***************************************************************************** 937 extern void GPIO_unregisterInterrupt(uint_fast8_t selectedPort); 938 939 //***************************************************************************** 940 // 941 //! This function sets the drive strength to high for the selected port 942 //! 943 //! 944 //! \param selectedPort is the selected port. 945 //! Valid values are: 946 //! - \b GPIO_PORT_P1, 947 //! - \b GPIO_PORT_P2, 948 //! - \b GPIO_PORT_P3, 949 //! - \b GPIO_PORT_P4, 950 //! - \b GPIO_PORT_P5, 951 //! - \b GPIO_PORT_P6, 952 //! - \b GPIO_PORT_P7, 953 //! - \b GPIO_PORT_P8, 954 //! - \b GPIO_PORT_P9, 955 //! - \b GPIO_PORT_P10, 956 //! - \b GPIO_PORT_PJ 957 //! \param selectedPins is the specified pin in the selected port. 958 //! Valid values are: 959 //! - \b GPIO_PIN0, 960 //! - \b GPIO_PIN1, 961 //! - \b GPIO_PIN2, 962 //! - \b GPIO_PIN3, 963 //! - \b GPIO_PIN4, 964 //! - \b GPIO_PIN5, 965 //! - \b GPIO_PIN6, 966 //! - \b GPIO_PIN7, 967 //! - \b GPIO_PIN8, 968 //! - \b PIN_ALL8, 969 //! 970 //! \return None 971 // 972 //***************************************************************************** 973 extern void GPIO_setDriveStrengthHigh(uint_fast8_t selectedPort, 974 uint_fast8_t selectedPins); 975 976 //***************************************************************************** 977 // 978 //! This function sets the drive strength to low for the selected port 979 //! 980 //! 981 //! \param selectedPort is the selected port. 982 //! Valid values are: 983 //! - \b GPIO_PORT_P1, 984 //! - \b GPIO_PORT_P2, 985 //! - \b GPIO_PORT_P3, 986 //! - \b GPIO_PORT_P4, 987 //! - \b GPIO_PORT_P5, 988 //! - \b GPIO_PORT_P6, 989 //! - \b GPIO_PORT_P7, 990 //! - \b GPIO_PORT_P8, 991 //! - \b GPIO_PORT_P9, 992 //! - \b GPIO_PORT_P10, 993 //! - \b GPIO_PORT_PJ 994 //! \param selectedPins is the specified pin in the selected port. 995 //! Valid values are: 996 //! - \b GPIO_PIN0, 997 //! - \b GPIO_PIN1, 998 //! - \b GPIO_PIN2, 999 //! - \b GPIO_PIN3, 1000 //! - \b GPIO_PIN4, 1001 //! - \b GPIO_PIN5, 1002 //! - \b GPIO_PIN6, 1003 //! - \b GPIO_PIN7, 1004 //! - \b GPIO_PIN8, 1005 //! - \b PIN_ALL8, 1006 //! 1007 //! \return None 1008 // 1009 //***************************************************************************** 1010 extern void GPIO_setDriveStrengthLow(uint_fast8_t selectedPort, 1011 uint_fast8_t selectedPins); 1012 1013 /* Backwards Compatibility Layer */ 1014 #define GPIO_selectInterruptEdge GPIO_interruptEdgeSelect 1015 #define GPIO_clearInterrupt GPIO_clearInterruptFlag 1016 1017 //***************************************************************************** 1018 // 1019 // Mark the end of the C bindings section for C++ compilers. 1020 // 1021 //***************************************************************************** 1022 #ifdef __cplusplus 1023 } 1024 #endif 1025 1026 //***************************************************************************** 1027 // 1028 // Close the Doxygen group. 1029 //! @} 1030 // 1031 //***************************************************************************** 1032 1033 #endif // __GPIO_H__ 1034