PIC18 LaurTec Library
3.2.0
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
|
#include "MCP2300x.h"
Go to the source code of this file.
Functions | |
void | initialize_MC2300x (unsigned char crystal_frequency_MHz, unsigned int baud_rate_KHz) |
signed char | set_register_MCP2300x (unsigned char device_address, unsigned char register_add, unsigned char data) |
unsigned char | get_register_MCP2300x (unsigned char device_address, unsigned char register_add) |
signed char | set_port_direction_MCP2300x (unsigned char device_address, unsigned char direction) |
signed char | set_port_value_MCP2300x (unsigned char device_address, unsigned char value) |
signed char | set_port_polarity_MCP2300x (unsigned char device_address, unsigned char value) |
signed char | set_port_pull_up_resistor_MCP2300x (unsigned char device_address, unsigned char value) |
unsigned char | get_port_value_MCP2300x (unsigned char device_address) |
signed char | set_port_interrupt_MCP2300x (unsigned char device_address, unsigned char value) |
signed char | set_port_configuration_MCP2300x (unsigned char device_address, unsigned char value) |
signed char | set_interrupt_compare_value_MCP2300x (unsigned char device_address, unsigned char value) |
signed char | set_interrupt_compare_enable_MCP2300x (unsigned char device_address, unsigned char value) |
unsigned char | get_port_interrupt_flag_MCP2300x (unsigned char device_address) |
unsigned char | get_port_interrupt_capture_MCP2300x (unsigned char device_address) |
unsigned char get_port_interrupt_capture_MCP2300x | ( | unsigned char | device_address | ) |
This function reads from the INTCAP register, enabling the read of the pin flags that caused the interrupt. In particular INTCAP register it captures the value at the time of the interrupt so it may differ from the value of INTF register.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
Definition at line 187 of file MCP2300x.c.
References get_register_MCP2300x(), and INTCAP.
unsigned char get_port_interrupt_flag_MCP2300x | ( | unsigned char | device_address | ) |
This function reads from the INTF register, enabling the read of the pin flags that caused the interrupt.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
Definition at line 178 of file MCP2300x.c.
References get_register_MCP2300x(), and INTF.
unsigned char get_port_value_MCP2300x | ( | unsigned char | device_address | ) |
This function reads from the GPIO register, which is equivalent to read the value of the external pins.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
Definition at line 127 of file MCP2300x.c.
References get_register_MCP2300x(), and GPIO.
unsigned char get_register_MCP2300x | ( | unsigned char | device_address, |
unsigned char | register_add | ||
) |
This function reads from any register of the MCP2300x device.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
register_add | Address of the register that must be written. |
Definition at line 79 of file MCP2300x.c.
References INTERNAL_ADDRESS.
void initialize_MC2300x | ( | unsigned char | crystal_frequency_MHz, |
unsigned int | baud_rate_KHz | ||
) |
This function initialize the I2C module accordingly to the clock and baud rate.
crystal_frequency_MHz | Clock frequency expressed in MHz |
baud_rate_KHz | Baud rate expressed in KHz |
Definition at line 53 of file MCP2300x.c.
signed char set_interrupt_compare_enable_MCP2300x | ( | unsigned char | device_address, |
unsigned char | value | ||
) |
This function writes into INTCON register, which is equivalent to select the interrupt modality. A zero sets an interrupt on pin change, while a 1 enable the comparison with the DEFVAL Register.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
value | Value that enables the pins where the comparison must be activated. |
Definition at line 169 of file MCP2300x.c.
References INTCON, and set_register_MCP2300x().
signed char set_interrupt_compare_value_MCP2300x | ( | unsigned char | device_address, |
unsigned char | value | ||
) |
This function writes into DEFVAL register, which is equivalent to set the value for the interrupt comparison. If bit 2 is set to 1 a 0 into pin 2 will trigger the interrupt.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
value | Byte that reflects the value of interest to be used for the comparison. |
Definition at line 160 of file MCP2300x.c.
References DEFVAL, and set_register_MCP2300x().
signed char set_port_configuration_MCP2300x | ( | unsigned char | device_address, |
unsigned char | value | ||
) |
This function writes into IOCON register, enabling some internal configurations. SEQOP, DISSLW, ODR, INTPOL
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
value | Value that reflects the pins where the comparison must be enabled. |
Definition at line 153 of file MCP2300x.c.
References IOCON, and set_register_MCP2300x().
signed char set_port_direction_MCP2300x | ( | unsigned char | device_address, |
unsigned char | direction | ||
) |
This function writes into IODIR register, defining the direction of the pin. A 1 in a bit is equivalent to set the corresponding pin as input, while a 0 sets it to Output.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
direction | Value that defines the direction of each pin. |
Definition at line 91 of file MCP2300x.c.
References IODIR, and set_register_MCP2300x().
signed char set_port_interrupt_MCP2300x | ( | unsigned char | device_address, |
unsigned char | value | ||
) |
This function writes into GPINTEN register, which is equivalent to activate the interrupts. A bit set to 1 enables the interrupt to the corresponding pin. This option affects only pins that are set as inputs.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
value | Value to enable the pins where the interrupt must be activated. |
Definition at line 137 of file MCP2300x.c.
References get_register_MCP2300x(), GPINTEN, GPIO, and set_register_MCP2300x().
signed char set_port_polarity_MCP2300x | ( | unsigned char | device_address, |
unsigned char | value | ||
) |
This function writes into IPOL register, which defines the polarity of the input pins.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
value | The value sets the corresponding pin with an inverting value (input only). |
Definition at line 109 of file MCP2300x.c.
References IPOL, and set_register_MCP2300x().
signed char set_port_pull_up_resistor_MCP2300x | ( | unsigned char | device_address, |
unsigned char | value | ||
) |
This function writes into GPPU register, which is equivalent to activate the pull-up resistor. A bit set to 1 enables the pull-up resistor to the corresponding pin. This option affect only the pins that are set as inputs.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
value | Value to enable the pins where the pull-up resistor must be activated. |
Definition at line 118 of file MCP2300x.c.
References GPPU, and set_register_MCP2300x().
signed char set_port_value_MCP2300x | ( | unsigned char | device_address, |
unsigned char | value | ||
) |
This function writes into the GPIO register, which is equivalent to write to the output port.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
value | Value that must be written to the output port. |
Definition at line 100 of file MCP2300x.c.
References GPIO, and set_register_MCP2300x().
signed char set_register_MCP2300x | ( | unsigned char | device_address, |
unsigned char | register_add, | ||
unsigned char | data | ||
) |
This function writes into any register of the MCP2300x device.
device_address | Hardware Address of the device (A0, A1, A2 only) [min: 0, max: 7]. |
register_add | Address of the register that must be written. |
data | Data that must be written into the register. |
Definition at line 64 of file MCP2300x.c.
References INTERNAL_ADDRESS.