|
PIC24 Support Libraries
|
Go to the source code of this file.
Macros | |
Low-level port configuration macros | |
These macros support low-level pin configuration in the following areas:
| |
| #define | ENABLE_Rxy_ANALOG() _PCFGn = 0 |
| #define | DISABLE_Rxy_ANALOG() _PCFGn = 1 |
| #define | CONFIG_RPy_AS_DIG_PIN() _PCFG = 1 |
| #define | ENABLE_Rxy_OPENDRAIN() _ODCxy = 1 |
| #define | DISABLE_Rxy_OPENDRAIN() _ODCxy = 0 |
| #define | ENABLE_Rxy_PULLUP() _CNmPUE = 1 |
| #define | DISABLE_Rxy_PULLUP() _CNmPUE = 1 |
| #define | ENABLE_Rxy_CN_INTERRUPT() _CNmIE = 1 |
| #define | DISABLE_Rxy_CN_INTERRUPT() _CNmIE = 0 |
Remappable peripheral input support | |
These funcions map an input internal to the PIC to an input pin. For example, CONFIG_INT1_TO_RP(10) maps the INT1 edge-triggered interrupt to port P, pin 10. Not all devices support remappable peripherals. In these cases, the macros below evalaute to nothing: CONFIG_INT1_TO_RP(10) is a valid C statement which does nothing. | |
| #define | CONFIG_INT1_TO_RP(pin) _INT1R = pin |
| #define | CONFIG_INT2_TO_RP(pin) _INT2R = pin |
| #define | CONFIG_T2CK_TO_RP(pin) _T2CKR = pin |
| #define | CONFIG_T3CK_TO_RP(pin) _T3CKR = pin |
| #define | CONFIG_T4CK_TO_RP(pin) _T4CKR = pin |
| #define | CONFIG_T5CK_TO_RP(pin) _T5CKR = pin |
| #define | CONFIG_IC1_TO_RP(pin) _IC1R = pin |
| #define | CONFIG_IC2_TO_RP(pin) _IC2R = pin |
| #define | CONFIG_IC3_TO_RP(pin) _IC3R = pin |
| #define | CONFIG_IC4_TO_RP(pin) _IC4R = pin |
| #define | CONFIG_IC5_TO_RP(pin) _IC5R = pin |
| #define | CONFIG_IC6_TO_RP(pin) _IC6R = pin |
| #define | CONFIG_IC7_TO_RP(pin) _IC7R = pin |
| #define | CONFIG_IC8_TO_RP(pin) _IC8R = pin |
| #define | CONFIG_OCFA_TO_RP(pin) _OCFAR = pin |
| #define | CONFIG_OCFB_TO_RP(pin) _OCFBR = pin |
| #define | CONFIG_U1RX_TO_RP(pin) _U1RXR = pin |
| #define | CONFIG_U1CTS_TO_RP(pin) _U1CTSR = pin |
| #define | CONFIG_U2RX_TO_RP(pin) _U2RXR = pin |
| #define | CONFIG_U2CTS_TO_RP(pin) _U2CTSR = pin |
| #define | CONFIG_SDI1_TO_RP(pin) _SDI1R = pin |
| #define | CONFIG_SCK1IN_TO_RP(pin) _SCK1R = pin |
| #define | CONFIG_SS1IN_TO_RP(pin) _SS1R = pin |
| #define | CONFIG_SDI2_TO_RP(pin) _SDI2R = pin |
| #define | CONFIG_SCK2IN_TO_RP(pin) _SCK2R = pin |
| #define | CONFIG_SS2IN_TO_RP(pin) _SS2R = pin |
| #define | CONFIG_C1RXR_TO_RP(pin) _C1RXR = pin |
| #define | CONFIG_C2RXR_TO_RP(pin) _C2RXR = pin |
Remappable peripheral output support | |
These functions maps an output internal to the PIC to an output pin. For example, CONFIG_C1OUT_TO_RP(10) maps the C1OUT comparator output to port P, pin 10. Not all devices support remappable peripherals. In these cases, the macros below evalaute to nothing: CONFIG_C1OUT_TO_RP(10) is a valid C statement which does nothing. | |
| #define | RPMAP_C1OUT 1 |
| Define peripheral pins. | |
| #define | RPMAP_C2OUT 2 |
| #define | RPMAP_U1TX 3 |
| #define | RPMAP_U1RTS 4 |
| #define | RPMAP_U2TX 5 |
| #define | RPMAP_U2RTS 6 |
| #define | RPMAP_SD01 7 |
| #define | RPMAP_SCK1OUT 8 |
| #define | RPMAP_SS1OUT 9 |
| #define | RPMAP_SDO2 10 |
| #define | RPMAP_SCK2OUT 11 |
| #define | RPMAP_SS2OUT 12 |
| #define | RPMAP_C1TX 16 |
| #define | RPMAP_OC1 18 |
| #define | RPMAP_OC2 19 |
| #define | RPMAP_OC3 20 |
| #define | RPMAP_OC4 21 |
| #define | RPMAP_OC5 22 |
| #define | CONFIG_NULL_TO_RP(pin) _RP##pin##R = 0 |
| #define | CONFIG_C1OUT_TO_RP(pin) _RP##pin##R = RPMAP_C1OUT |
| #define | CONFIG_C2OUT_TO_RP(pin) _RP##pin##R = RPMAP_C2OUT |
| #define | CONFIG_U1TX_TO_RP(pin) _RP##pin##R = RPMAP_U1TX |
| #define | CONFIG_U1RTS_TO_RP(pin) _RP##pin##R = RPMAP_U1RTS |
| #define | CONFIG_U2TX_TO_RP(pin) _RP##pin##R = RPMAP_U2TX |
| #define | CONFIG_U2RTS_TO_RP(pin) _RP##pin##R = RPMAP_U2RTS |
| #define | CONFIG_SDO1_TO_RP(pin) _RP##pin##R = RPMAP_SD01 |
| #define | CONFIG_SCK1OUT_TO_RP(pin) _RP##pin##R = RPMAP_SCK1OUT |
| #define | CONFIG_SS1OUT_TO_RP(pin) _RP##pin##R = RPMAP_SS1OUT |
| #define | CONFIG_SDO2_TO_RP(pin) _RP##pin##R = RPMAP_SDO2 |
| #define | CONFIG_SCK2OUT_TO_RP(pin) _RP##pin##R = RPMAP_SCK2OUT |
| #define | CONFIG_SS2OUT_TO_RP(pin) _RP##pin##R = RPMAP_SS2OUT |
| #define | CONFIG_C1TX_TO_RP(pin) _RP##pin##R = RPMAP_C1TX |
| #define | CONFIG_OC1_TO_RP(pin) _RP##pin##R = RPMAP_OC1 |
| #define | CONFIG_OC2_TO_RP(pin) _RP##pin##R = RPMAP_OC2 |
| #define | CONFIG_OC3_TO_RP(pin) _RP##pin##R = RPMAP_OC3 |
| #define | CONFIG_OC4_TO_RP(pin) _RP##pin##R = RPMAP_OC4 |
| #define | CONFIG_OC5_TO_RP(pin) _RP##pin##R = RPMAP_OC5 |
Functions | |
High-level port configuration | |
These macros choose digital or analog, input or output, open-drain or standard. Use the low-level ENABLE/DISABLE_Rxy_PULLUP() to configure the pullup. | |
| static void | CONFIG_Rxy_AS_DIG_OUTPUT () |
| static void | CONFIG_Rxy_AS_DIG_OD_OUTPUT () |
| static void | CONFIG_Rxy_AS_DIG_INPUT () |
| static void | CONFIG_ANx_AS_ANALOG () |
This file supports configuration of IO ports on the PIC24. Support includes:
The port configuration macros are available in two forms. Higher-level routines completely configure a pin for a specific operation, while low-level routines provide a more readable name for changing the value of a single bit (_PCFGn, _TRISxy, _CNmPU, or _ODCxy).
To reduce the confusing variety of naming schemes for these bits, the macros refer to a pin either by its port letter x plus pin number y (for example, _TRISB3 for the TRIS bit of port B, pin 3) or by the analog input number n (for example, AN0 refers to analog input 0).
The macros provided as "smart" - only functions applicable to that pin are contained in a given macro. For example, CONFIG_RA1_AS_DIG_OUTPUT on the PIC24HJ32GP202 disables the pin's pullup, disables the open-drain driver, disables analog functionality, then sets the pin as an output. CONFIG_RA7_AS_DIG_OUTPUT on the PIC24HJ32GP204 only disables the open-drain driver and sets the pin as an output, because that pin supports neither analog nor pullup functionality.
Definition in file pic24_ports.h.
| #define CONFIG_C1OUT_TO_RP | ( | pin) | _RP##pin##R = RPMAP_C1OUT |
Maps C1OUT to a remappable pin; see remappable peripheral output support for more information.
Definition at line 523 of file pic24_ports.h.
| #define CONFIG_C1RXR_TO_RP | ( | pin) | _C1RXR = pin |
Maps C1RX to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 439 of file pic24_ports.h.
| #define CONFIG_C1TX_TO_RP | ( | pin) | _RP##pin##R = RPMAP_C1TX |
Maps C1TX to a remappable pin; see remappable peripheral output support for more information.
Definition at line 631 of file pic24_ports.h.
| #define CONFIG_C2OUT_TO_RP | ( | pin) | _RP##pin##R = RPMAP_C2OUT |
Maps C2OUT to a remappable pin; see remappable peripheral output support for more information.
Definition at line 532 of file pic24_ports.h.
| #define CONFIG_C2RXR_TO_RP | ( | pin) | _C2RXR = pin |
Maps C2RX to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 448 of file pic24_ports.h.
| #define CONFIG_IC1_TO_RP | ( | pin) | _IC1R = pin |
Maps IC1 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 259 of file pic24_ports.h.
| #define CONFIG_IC2_TO_RP | ( | pin) | _IC2R = pin |
Maps IC2 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 268 of file pic24_ports.h.
| #define CONFIG_IC3_TO_RP | ( | pin) | _IC3R = pin |
Maps IC3 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 277 of file pic24_ports.h.
| #define CONFIG_IC4_TO_RP | ( | pin) | _IC4R = pin |
Maps IC4 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 286 of file pic24_ports.h.
| #define CONFIG_IC5_TO_RP | ( | pin) | _IC5R = pin |
Maps IC5 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 295 of file pic24_ports.h.
| #define CONFIG_IC6_TO_RP | ( | pin) | _IC6R = pin |
Maps IC6 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 304 of file pic24_ports.h.
| #define CONFIG_IC7_TO_RP | ( | pin) | _IC7R = pin |
Maps IC7 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 313 of file pic24_ports.h.
| #define CONFIG_IC8_TO_RP | ( | pin) | _IC8R = pin |
Maps IC8 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 322 of file pic24_ports.h.
| #define CONFIG_INT1_TO_RP | ( | pin) | _INT1R = pin |
Maps INT1 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 205 of file pic24_ports.h.
Referenced by CONFIG_SW1(), and main().
| #define CONFIG_INT2_TO_RP | ( | pin) | _INT2R = pin |
Maps INT2 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 214 of file pic24_ports.h.
| #define CONFIG_NULL_TO_RP | ( | pin) | _RP##pin##R = 0 |
CONFIG_NULL_TO_RP(n) returns RPn to an 'unmapped' state (i.e, the reset condition).
Definition at line 514 of file pic24_ports.h.
| #define CONFIG_OC1_TO_RP | ( | pin) | _RP##pin##R = RPMAP_OC1 |
Maps OC1 to a remappable pin; see remappable peripheral output support for more information.
Definition at line 640 of file pic24_ports.h.
| #define CONFIG_OC2_TO_RP | ( | pin) | _RP##pin##R = RPMAP_OC2 |
Maps OC2 to a remappable pin; see remappable peripheral output support for more information.
Definition at line 649 of file pic24_ports.h.
| #define CONFIG_OC3_TO_RP | ( | pin) | _RP##pin##R = RPMAP_OC3 |
Maps OC3 to a remappable pin; see remappable peripheral output support for more information.
Definition at line 658 of file pic24_ports.h.
| #define CONFIG_OC4_TO_RP | ( | pin) | _RP##pin##R = RPMAP_OC4 |
Maps OC4 to a remappable pin; see remappable peripheral output support for more information.
Definition at line 667 of file pic24_ports.h.
| #define CONFIG_OC5_TO_RP | ( | pin) | _RP##pin##R = RPMAP_OC5 |
Maps OC5 to a remappable pin; see remappable peripheral output support for more information.
Definition at line 676 of file pic24_ports.h.
| #define CONFIG_OCFA_TO_RP | ( | pin) | _OCFAR = pin |
Maps OCFA to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 331 of file pic24_ports.h.
| #define CONFIG_OCFB_TO_RP | ( | pin) | _OCFBR = pin |
Maps OCFB to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 340 of file pic24_ports.h.
| #define CONFIG_RPy_AS_DIG_PIN | ( | ) | _PCFG = 1 |
Makes port P, pin y a digital pin by disabling analog functionality on that pin. This is done by setting the corresponding _PCFGn bit. For example, CONFIG_RP10_AS_DIG_PIN() makes port P, pin 10 a digital pin by disabling analog its functionality.
Definition at line 153 of file pic24_ports.h.
| #define CONFIG_SCK1IN_TO_RP | ( | pin) | _SCK1R = pin |
Maps SCK1 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 394 of file pic24_ports.h.
| #define CONFIG_SCK1OUT_TO_RP | ( | pin) | _RP##pin##R = RPMAP_SCK1OUT |
Maps SCK1OUT to a remappable pin; see remappable peripheral output support for more information.
Definition at line 586 of file pic24_ports.h.
| #define CONFIG_SCK2IN_TO_RP | ( | pin) | _SCK2R = pin |
Maps SCK2 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 421 of file pic24_ports.h.
| #define CONFIG_SCK2OUT_TO_RP | ( | pin) | _RP##pin##R = RPMAP_SCK2OUT |
Maps SCK2OUT to a remappable pin; see remappable peripheral output support for more information.
Definition at line 613 of file pic24_ports.h.
| #define CONFIG_SDI1_TO_RP | ( | pin) | _SDI1R = pin |
Maps SDI1 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 385 of file pic24_ports.h.
| #define CONFIG_SDI2_TO_RP | ( | pin) | _SDI2R = pin |
Maps SDI2 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 412 of file pic24_ports.h.
| #define CONFIG_SDO1_TO_RP | ( | pin) | _RP##pin##R = RPMAP_SD01 |
Maps SDO1 to a remappable pin; see remappable peripheral output support for more information.
Definition at line 577 of file pic24_ports.h.
| #define CONFIG_SDO2_TO_RP | ( | pin) | _RP##pin##R = RPMAP_SDO2 |
Maps SDO2 to a remappable pin; see remappable peripheral output support for more information.
Definition at line 604 of file pic24_ports.h.
| #define CONFIG_SS1IN_TO_RP | ( | pin) | _SS1R = pin |
Maps SS1 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 403 of file pic24_ports.h.
| #define CONFIG_SS1OUT_TO_RP | ( | pin) | _RP##pin##R = RPMAP_SS1OUT |
Maps SS11OUT to a remappable pin; see remappable peripheral output support for more information.
Definition at line 595 of file pic24_ports.h.
| #define CONFIG_SS2IN_TO_RP | ( | pin) | _SS2R = pin |
Maps SS2 to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 430 of file pic24_ports.h.
| #define CONFIG_SS2OUT_TO_RP | ( | pin) | _RP##pin##R = RPMAP_SS2OUT |
Maps SS2OUT to a remappable pin; see remappable peripheral output support for more information.
Definition at line 622 of file pic24_ports.h.
| #define CONFIG_T2CK_TO_RP | ( | pin) | _T2CKR = pin |
Maps T2CK to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 223 of file pic24_ports.h.
| #define CONFIG_T3CK_TO_RP | ( | pin) | _T3CKR = pin |
Maps T3CK to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 232 of file pic24_ports.h.
| #define CONFIG_T4CK_TO_RP | ( | pin) | _T4CKR = pin |
Maps T4CK to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 241 of file pic24_ports.h.
| #define CONFIG_T5CK_TO_RP | ( | pin) | _T5CKR = pin |
Maps T5CK to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 250 of file pic24_ports.h.
| #define CONFIG_U1CTS_TO_RP | ( | pin) | _U1CTSR = pin |
Maps U1CTS to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 358 of file pic24_ports.h.
| #define CONFIG_U1RTS_TO_RP | ( | pin) | _RP##pin##R = RPMAP_U1RTS |
Maps U1RTS to a remappable pin; see remappable peripheral output support for more information.
Definition at line 550 of file pic24_ports.h.
| #define CONFIG_U1RX_TO_RP | ( | pin) | _U1RXR = pin |
Maps U1RX to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 349 of file pic24_ports.h.
Referenced by configUART1().
| #define CONFIG_U1TX_TO_RP | ( | pin) | _RP##pin##R = RPMAP_U1TX |
Maps U1TX to a remappable pin; see remappable peripheral output support for more information.
Definition at line 541 of file pic24_ports.h.
Referenced by configUART1().
| #define CONFIG_U2CTS_TO_RP | ( | pin) | _U2CTSR = pin |
Maps U2CTS to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 376 of file pic24_ports.h.
| #define CONFIG_U2RTS_TO_RP | ( | pin) | _RP##pin##R = RPMAP_U2RTS |
Maps U2RTS to a remappable pin; see remappable peripheral output support for more information.
Definition at line 568 of file pic24_ports.h.
| #define CONFIG_U2RX_TO_RP | ( | pin) | _U2RXR = pin |
Maps U2RX to a remappable pin; see remappable peripheral input support for more informatino.
Definition at line 367 of file pic24_ports.h.
| #define CONFIG_U2TX_TO_RP | ( | pin) | _RP##pin##R = RPMAP_U2TX |
Maps U2TX to a remappable pin; see remappable peripheral output support for more information.
Definition at line 559 of file pic24_ports.h.
| #define DISABLE_Rxy_ANALOG | ( | ) | _PCFGn = 1 |
Disables analog functionality on port x of pin y by setting the corresponding _PCFGn bit. For example, DISABLE_RA10_ANALOG() disables analog functionality on port A pin 10.
Definition at line 146 of file pic24_ports.h.
| #define DISABLE_Rxy_CN_INTERRUPT | ( | ) | _CNmIE = 0 |
Disables the change notification interrupt on port x, pin y. For example, DISABLE_RA10_CN_INTERRUPT() disables the change notification interrupt on port A, pin 10.
Definition at line 185 of file pic24_ports.h.
| #define DISABLE_Rxy_OPENDRAIN | ( | ) | _ODCxy = 0 |
Disables the open-drain driver on port x, pin y. For example, DISABLE_Rxy_OPENDRAIN()
Definition at line 163 of file pic24_ports.h.
| #define DISABLE_Rxy_PULLUP | ( | ) | _CNmPUE = 1 |
Disable the pullup on port x, pin y. For example, DISABLE_RA10_PULLUP() disables the pullup on port A, pin 10.
Definition at line 173 of file pic24_ports.h.
| #define ENABLE_Rxy_ANALOG | ( | ) | _PCFGn = 0 |
Enables analog functionality on port x of pin y by clearing the corresponding _PCFGn bit. For example, ENABLE_RA10_ANALOG() enables analog functionality on port A pin 10.
Definition at line 140 of file pic24_ports.h.
| #define ENABLE_Rxy_CN_INTERRUPT | ( | ) | _CNmIE = 1 |
Enables the change notification interrupt on port x, pin y. For example, ENABLE_RA10_CN_INTERRUPT() enables the change notification interrupt on port A, pin 10.
Definition at line 179 of file pic24_ports.h.
| #define ENABLE_Rxy_OPENDRAIN | ( | ) | _ODCxy = 1 |
Enables the open-drain driver on port x, pin y. For example, ENABLE_Rxy_OPENDRAIN()
Definition at line 158 of file pic24_ports.h.
| #define ENABLE_Rxy_PULLUP | ( | ) | _CNmPUE = 1 |
Enable the pullup on port x, pin y. For example, ENABLE_RA10_PULLUP() enables the pullup on port A, pin 10.
Definition at line 168 of file pic24_ports.h.
|
inlinestatic |
This macro first calls CONFIG_Rxy_AS_DIG_INPUT() to disable pullups on the pin then enables analog functionality on the pin. For example, CONFIG_AN1_AS_ANALOG() makes AN1 an analog input pin.
Definition at line 115 of file pic24_ports.h.
|
inlinestatic |
This macro disables pullups and analog functionality and sets the pin as an input. For example, CONFIG_RA10_AS_DIG_OUTPUT() makes port A, pin 10 a digital input.
Definition at line 109 of file pic24_ports.h.
|
inlinestatic |
This macro enables open-drain, disables pullups, configures port x pin y for digital (not analog) operation, and sets the pin as an output. For example, CONFIG_RA10_AS_DIG_OD_OUTPUT() makes port A, pin 10 a digital output.
Definition at line 103 of file pic24_ports.h.
|
inlinestatic |
This macro disables open-drain and pullups, configures port x pin y for digital (not analog) operation, and sets the pin as an output. For example, CONFIG_RA10_AS_DIG_OUTPUT() makes port A, pin 10 a digital output.
Definition at line 96 of file pic24_ports.h.
1.8.4