#include "pm.h"
Go to the source code of this file.
Defines | |
#define | NUM_DIGITAL_PORTS 1 |
#define | HAS_REMAPPABLE_PINS |
#define | __STATIC__ static |
Enumerations | |
enum | { PORT_A_INDEX = 0, PORT_B_INDEX, PORT_C_INDEX, PORT_D_INDEX, PORT_E_INDEX, PORT_F_INDEX, PORT_G_INDEX } |
Functions | |
Initialization, read/write, and high-level pin configuration functions | |
These functions set up the I/O system, read and write to a pin, and allow configuring an I/O pin using a single function call. | |
PmReturn_t | configDigitalPin (uint16_t u16_port, uint16_t u16_pin, bool_t b_isInput, bool_t b_isOpenDrain, int16_t i16_pullDir) |
PmReturn_t | configAnalogPin (uint16_t u16_analogPin) |
PmReturn_t | setDigitalPin (uint16_t u16_port, uint16_t u16_pin, bool_t b_isHigh) |
PmReturn_t | readDigitalPin (uint16_t u16_port, uint16_t u16_pin, bool_t *pb_isHigh) |
PmReturn_t | readDigitalLatch (uint16_t u16_port, uint16_t u16_pin, bool_t *pb_isHigh) |
low-level pin configuration functions | |
These functions allow low-level configuration of I/O pins. See the low-level pin configuration section for usage. | |
bool_t | digitalPinExists (uint16_t u16_port, uint16_t u16_pin) |
PmReturn_t | setPinIsInput (uint16_t u16_port, uint16_t u16_pin, bool_t b_isInput) |
PmReturn_t | getPinIsInput (uint16_t u16_port, uint16_t u16_pin, bool_t *pb_isInput) |
PmReturn_t | setPinIsDigital (uint16_t u16_port, uint16_t u16_pin, bool_t b_isDigital) |
PmReturn_t | setPinIsOpenDrain (uint16_t u16_port, uint16_t u16_pin, bool_t b_isOpenDrain) |
PmReturn_t | setPinPullDirection (uint16_t u16_port, uint16_t u16_pin, int16_t i16_dir) |
PmReturn_t | unmapPin (uint16_t u16_port, uint16_t u16_pin) |
Bit manipulation functions | |
#define | GET_EXTENDED_BIT(u_bitfield, u16_bit) getBit(*(((uint16_t*) &(u_bitfield)) + ((u16_bit) >> 4)), (u16_bit) & 0x000F) |
#define | SET_EXTENDED_BIT(p_bitfield, u16_bit, b_val) setBit(((uint16_t*) (p_bitfield)) + ((u16_bit) >> 4), (u16_bit) & 0x000F, b_val) |
bool_t | getBit (uint16_t u16_bitfield, uint16_t u16_bit) |
void | setBit (volatile uint16_t *pu16_bitfield, uint16_t u16_bit, bool_t b_val) |
Definition in file pic24_pyports.h.
#define __STATIC__ static |
For unit testing, make some of the static functions visible; otherwise, leave them static. This macro's definition provides this capability.
Definition at line 400 of file pic24_pyports.h.
#define GET_EXTENDED_BIT | ( | u_bitfield, | |||
u16_bit | ) | getBit(*(((uint16_t*) &(u_bitfield)) + ((u16_bit) >> 4)), (u16_bit) & 0x000F) |
Look up a specific bit in an extended (> 16 bit) bitfield.
u_bitfield | Bitfield to access. | |
u16_bit | Bit in bitfield to access |
Definition at line 294 of file pic24_pyports.h.
#define HAS_REMAPPABLE_PINS |
When defined, indicates that this device has remappable pins.
Definition at line 387 of file pic24_pyports.h.
#define NUM_DIGITAL_PORTS 1 |
This macro tells how many digital I/O ports exist on the selected processor.
Definition at line 351 of file pic24_pyports.h.
#define SET_EXTENDED_BIT | ( | p_bitfield, | |||
u16_bit, | |||||
b_val | ) | setBit(((uint16_t*) (p_bitfield)) + ((u16_bit) >> 4), (u16_bit) & 0x000F, b_val) |
Set a specific bit in an extended (> 16 bit) bitfield.
p_bitfield | Pointer to bitfield to modify. | |
u16_bit | Bit in bitfield to access. | |
b_val | True to set the bit, false to clear it. |
Definition at line 310 of file pic24_pyports.h.
anonymous enum |
Map ports to an index.
Definition at line 268 of file pic24_pyports.h.
PmReturn_t configAnalogPin | ( | uint16_t | u16_analogPin | ) |
Configure a pin for analog operation.
u16_analogPin | Pin x (named ANxx on the data sheet) to configure as an analog pin |
Definition at line 2164 of file pic24_pyports.c.
PmReturn_t configDigitalPin | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t | b_isInput, | |||
bool_t | b_isOpenDrain, | |||
int16_t | i16_pullDir | |||
) |
Configures a pin for digital operation. Implementation:
u16_port | The port, consisting of one of PORT_A_INDEX, PORT_B_INDEX, etc. | |
u16_pin | The pin of the port to configure. Must be a number between 0 and 15. | |
b_isInput | True to configure the pin as an input, false to configure the pin as an output. | |
b_isOpenDrain | True to configure the pin's output drivers to be open drain, false to configure the pin's output drivers as a standrard push-pull output. IMPORTANT: Not all pins have open-drain ability; therefore, the only valid selection for this parameter may be false. All pins have standard, push-pull drivers. | |
i16_pullDir | A value > 0 to enable a pull-up resistor on the pin, a value < 0 to enable a pull-down resistor on the pin, or 0 to disable both. IMPORTANT: Not all pins have pull-up or pull-down capability. Valid values for some pins are 0 (neither pull-up nor pull-down resistors are available), or >=0 (only pull-up resistors are available). |
Definition at line 2148 of file pic24_pyports.c.
Determine if the given digitial I/O pin exists.
u16_port | Port, where 0 = A, 1 = B, etc. | |
u16_pin | Pin of the given port; from 0 to 15. |
Definition at line 1720 of file pic24_pyports.c.
Look up a specific bit in a bitfield.
u16_bitfield | Bitfield to access. | |
u16_bit | Bit in bitfield to access. Must be from 0 to 15. |
Definition at line 55 of file pic24_pyports.c.
PmReturn_t getPinIsInput | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t * | pb_isInput | |||
) |
Determine if an I/O pin is an input or an output.
u16_port | I/O port (A = 0, B = 1, etc.) | |
u16_pin | Pin on the I/O port (from 0 to 15) | |
pb_isInput | True if the pin is an input, false if it's an output. |
Definition at line 1770 of file pic24_pyports.c.
PmReturn_t readDigitalLatch | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t * | pb_isHigh | |||
) |
Read the last value written to an I/O pin. Therefore, this returns not the current value on the pin, but the last value written to the pin.
u16_port | The port, consisting of one of PORT_A_INDEX, PORT_B_INDEX, etc. | |
u16_pin | The pin of the port to configure. Must be a number between 0 and 15. | |
pb_isHigh | True if the last write was high, false if low. |
Definition at line 2217 of file pic24_pyports.c.
PmReturn_t readDigitalPin | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t * | pb_isHigh | |||
) |
Read the digital value sensed on an I/O pin. The pin should be configured as a digital input. If it's a digital output, then then this function simple read what's being written.
u16_port | The port, consisting of one of PORT_A_INDEX, PORT_B_INDEX, etc. | |
u16_pin | The pin of the port to configure. Must be a number between 0 and 15. | |
pb_isHigh | True if the pin is high, false if low. |
Definition at line 2205 of file pic24_pyports.c.
Set a specific bit in a bitfield.
pu16_bitfield | Pointer to bitfield to modify. | |
u16_bit | Bit in bitfield to access. Must be from 0 to 15. | |
b_val | True to set the bit, false to clear it. |
Definition at line 63 of file pic24_pyports.c.
PmReturn_t setDigitalPin | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t | b_isHigh | |||
) |
Write to an I/O pin. If the pin is configured as an input, the value will be stored but only appear on the pin when it is changed to an output.
u16_port | The port, consisting of one of PORT_A_INDEX, PORT_B_INDEX, etc. | |
u16_pin | The pin of the port to configure. Must be a number between 0 and 15. | |
b_isHigh | True to set the pin high, false to set it low. |
Definition at line 2193 of file pic24_pyports.c.
PmReturn_t setPinIsDigital | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t | b_isDigital | |||
) |
Configure an I/O pin as either a digital I/O or an analog input. To use an an analog input, this pin must already be configured as an input using setPinIsInput. For use as a digital pin (either as an input or an output), configure this pin in digital mode. See the low-level pin configuration" section for more details.
u16_port | I/O port (A = 0, B = 1, etc.) | |
u16_pin | Pin on the I/O port (from 0 to 15) | |
b_isDigital | True to configure the pin as a digital input, false to configure the pin as an analog input. |
Definition at line 1783 of file pic24_pyports.c.
PmReturn_t setPinIsInput | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t | b_isInput | |||
) |
Set an I/O pin to be either an input or an output. Setting this pin as an output implies that it is a digital output. In contrast, configuring this pint to be an input allows it to be used as either a digital input or an analog input.
u16_port | I/O port (A = 0, B = 1, etc.) | |
u16_pin | Pin on the I/O port (from 0 to 15) | |
b_isInput | True to select the pin as an input, false as an output. |
Definition at line 1757 of file pic24_pyports.c.
PmReturn_t setPinIsOpenDrain | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
bool_t | b_isOpenDrain | |||
) |
Specify the direction (input or output) for an I/O pin.
u16_port | I/O port (A = 0, B = 1, etc.) | |
u16_pin | Pin on the I/O port (from 0 to 15) | |
b_isOpenDrain | True to select an open-drain driver for the pin, false to select a standard push-pull (totem-pole) driver. |
Definition at line 1820 of file pic24_pyports.c.
PmReturn_t setPinPullDirection | ( | uint16_t | u16_port, | |
uint16_t | u16_pin, | |||
int16_t | i16_dir | |||
) |
Specify the pull direction (up, down, or none) for an I/O pin.
u16_port | I/O port (A = 0, B = 1, etc.) | |
u16_pin | Pin on the I/O port (from 0 to 15) | |
i16_dir | Pull direction: 0 = none, negative = pull down, positive = pull up. |
Definition at line 1853 of file pic24_pyports.c.
PmReturn_t unmapPin | ( | uint16_t | u16_port, | |
uint16_t | u16_pin | |||
) |
For chip that support remappable peripherals, unmap any peripherals which take full control of pin from the given pin, freeing the pin for use with general-purpose I/O. if the chip in use does not support remappable I/O, this routine does nothing.
u16_port | I/O port (A = 0, B = 1, etc.) | |
u16_pin | Pin on the I/O port (from 0 to 15) |