#include "pic24_all.h"
#include "pyFuncsInC.h"
#include "pyToC.h"
#include <pps.h>
Go to the source code of this file.
Classes | |
struct | anCnMap_t |
Defines | |
#define | __FILE_ID__ 0x70 |
#define | UNDEF_AN_PIN 255 |
#define | UNDEF_CN_PIN 255 |
#define | IO_PORT_CONTROL_OFFSET 4 |
#define | UNMAP_PIN(u16_port, u16_pin) PM_RET_OK |
Functions | |
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) |
__STATIC__ bool_t | digitalPinInBounds (uint16_t u16_port, uint16_t u16_pin) |
bool_t | digitalPinExists (uint16_t u16_port, uint16_t u16_pin) |
__STATIC__ bool_t | digitalOpenDrainPinExists (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 | 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) |
Variables | |
static const uint16_t | u16_digitalPinPresent [NUM_DIGITAL_PORTS] |
static const uint16_t | u16_digitalPinOpenDrainPresent [NUM_DIGITAL_PORTS] |
static const anCnMap_t | anCnMap [NUM_DIGITAL_PORTS *16] = { AN_CN_MAP } |
static const uint32_t | u32_isRemappable |
Definition in file pic24_pyports.c.
#define IO_PORT_CONTROL_OFFSET 4 |
This values gives the number of words between I/O port control registers. For example, &TRISA = 0x02C0 and &TRISB = 0x2C8, a difference of four words.
Definition at line 1754 of file pic24_pyports.c.
#define UNDEF_AN_PIN 255 |
The values state that a given digital I/O pin does not have analog capability. It is used in anCnMap.
Definition at line 1565 of file pic24_pyports.c.
#define UNDEF_CN_PIN 255 |
The values state that a given digital I/O pin does not have change notification capability. It is used in anCnMap.
Definition at line 1570 of file pic24_pyports.c.
#define UNMAP_PIN | ( | u16_port, | |||
u16_pin | ) | PM_RET_OK |
Define a "function" for devices without remappable I/O which returns OK -- all pins are automatically unmapped.
Definition at line 2144 of file pic24_pyports.c.
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 open-drain 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 1737 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.
Make sure the given pin is within bounds.
u16_port | Port, where 0 = A, 1 = B, etc. | |
u16_pin | Pin of the given port; from 0 to 15. |
Definition at line 1707 of file pic24_pyports.c.
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.
An array of the anCnMap_t structure with an entry for each of the (up to) 16 pins on each digitial I/O port for this device.
Definition at line 1590 of file pic24_pyports.c.
const uint16_t u16_digitalPinOpenDrainPresent[NUM_DIGITAL_PORTS] [static] |
This variable stores a bitmap describing which digitial I/O pins can be configured as open-drain outputs on the current processor. Port A is stored at [0], B at [1], etc. A value of 1 for a gvien bit indicates the corresponding pin of that port can be made open-drain. For example, 0x0001 indicates that only pin 0 of the selected port can be made, open-drain, while pins 1-15 operator only in the standard, totem-pole output configuration.
Definition at line 464 of file pic24_pyports.c.
const uint16_t u16_digitalPinPresent[NUM_DIGITAL_PORTS] [static] |
This variable stores a bitmap describing which digitial I/O pins exist on the current processor. Port A is stored at [0], B at [1], etc. A value of 1 for a gvien bit indicates the corresponding pin of that port exists. For example, 0x0001 indicates that only pin 0 of the selected port exists, while pins 1-15 do not.
Definition at line 81 of file pic24_pyports.c.
const uint32_t u32_isRemappable [static] |
This bitfield indicates which remappable pins exist on this device. Each bit is true if the corresponding remappable pin exists. In particular, bit 0 = RP0, bit 1 = RP1, etc.
Definition at line 1597 of file pic24_pyports.c.