LTlib LaurTec Library
4.0.1
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
|
#include "LTlib.h"
Go to the source code of this file.
Functions | |
void | MCP2300x_initialize (unsigned int baud_rate_KHz) |
signed char | MCP2300x_set_register (unsigned char device_address, unsigned char register_add, unsigned char data) |
unsigned char | MCP2300x_get_register (unsigned char device_address, unsigned char register_add) |
signed char | MCP2300x_set_port_direction (unsigned char device_address, unsigned char direction) |
unsigned char | MCP2300x_get_port_value (unsigned char device_address) |
signed char | MCP2300x_set_port_value (unsigned char device_address, unsigned char value) |
signed char | MCP2300x_set_port_polarity (unsigned char device_address, unsigned char value) |
signed char | MCP2300x_set_port_pull_up_resistor (unsigned char device_address, unsigned char value) |
signed char | MCP2300x_set_port_interrupt (unsigned char device_address, unsigned char value) |
signed char | MCP2300x_set_port_configuration (unsigned char device_address, unsigned char value) |
signed char | MCP2300x_set_interrupt_compare_value (unsigned char device_address, unsigned char value) |
signed char | MCP2300x_set_interrupt_compare_enable (unsigned char device_address, unsigned char value) |
unsigned char | MCP2300x_get_port_interrupt_flag (unsigned char device_address) |
unsigned char | MCP2300x_get_port_interrupt_capture (unsigned char device_address) |
#define get_port_interrupt_capture_MCP2300x MCP2300x_get_port_interrupt_capture |
Definition at line 371 of file MCP2300x.h.
#define get_port_interrupt_flag_MCP2300x MCP2300x_get_port_interrupt_flag |
Definition at line 354 of file MCP2300x.h.
#define get_port_value_MCP2300x MCP2300x_get_port_value |
Definition at line 197 of file MCP2300x.h.
#define get_register_MCP2300x MCP2300x_get_register |
Definition at line 163 of file MCP2300x.h.
#define initialize_MC2300x MCP2300x_initialize |
Definition at line 124 of file MCP2300x.h.
#define MCP2300x_CLEAR_REG 0b00000000 |
Definition at line 108 of file MCP2300x.h.
#define MCP2300x_DEFVAL 0x03 |
Definition at line 92 of file MCP2300x.h.
#define MCP2300x_DISSLW 0b00010000 |
Definition at line 103 of file MCP2300x.h.
#define MCP2300x_GPINTEN 0x02 |
Definition at line 91 of file MCP2300x.h.
#define MCP2300x_GPIO 0x09 |
Definition at line 98 of file MCP2300x.h.
#define MCP2300x_GPPU 0x06 |
Definition at line 95 of file MCP2300x.h.
#define MCP2300x_HAEN 0b00001000 |
Definition at line 104 of file MCP2300x.h.
#define MCP2300X_I2C_baud_rate I2C1_baud_rate |
Definition at line 67 of file MCP2300x.h.
#define MCP2300X_I2C_MODULE_1 |
Definition at line 62 of file MCP2300x.h.
#define MCP2300X_I2C_open I2C1_open |
Definition at line 66 of file MCP2300x.h.
#define MCP2300X_I2C_read_byte_from_external_device I2C1_read_byte_from_external_device |
Definition at line 69 of file MCP2300x.h.
#define MCP2300X_I2C_write_byte_to_external_device I2C1_write_byte_to_external_device |
Definition at line 68 of file MCP2300x.h.
#define MCP2300x_INTCAP 0x08 |
Definition at line 97 of file MCP2300x.h.
#define MCP2300x_INTCON 0x04 |
Definition at line 93 of file MCP2300x.h.
#define MCP2300X_INTERNAL_ADDRESS 0x40 |
Definition at line 83 of file MCP2300x.h.
#define MCP2300x_INTF 0x07 |
Definition at line 96 of file MCP2300x.h.
#define MCP2300x_INTPOL 0b00000010 |
Definition at line 106 of file MCP2300x.h.
#define MCP2300x_IOCON 0x05 |
Definition at line 94 of file MCP2300x.h.
#define MCP2300x_IODIR 0x00 |
Definition at line 89 of file MCP2300x.h.
#define MCP2300x_IPOL 0x01 |
Definition at line 90 of file MCP2300x.h.
#define MCP2300x_ODR 0b00000100 |
Definition at line 105 of file MCP2300x.h.
#define MCP2300x_OLAT 0x0A |
Definition at line 99 of file MCP2300x.h.
#define MCP2300x_SEQOP 0b00100000 |
Definition at line 102 of file MCP2300x.h.
#define set_interrupt_compare_enable_MCP2300x MCP2300x_set_interrupt_compare_enable |
Definition at line 339 of file MCP2300x.h.
#define set_interrupt_compare_value_MCP2300x MCP2300x_set_interrupt_compare_value |
Definition at line 319 of file MCP2300x.h.
#define set_port_configuration_MCP2300x MCP2300x_set_port_configuration |
Definition at line 299 of file MCP2300x.h.
#define set_port_direction_MCP2300x MCP2300x_set_port_direction |
Definition at line 183 of file MCP2300x.h.
#define set_port_interrupt_MCP2300x MCP2300x_set_port_interrupt |
Definition at line 278 of file MCP2300x.h.
#define set_port_polarity_MCP2300x MCP2300x_set_port_polarity |
Definition at line 235 of file MCP2300x.h.
#define set_port_pull_up_resistor_MCP2300x MCP2300x_set_port_pull_up_resistor |
Definition at line 255 of file MCP2300x.h.
#define set_port_value_MCP2300x MCP2300x_set_port_value |
Definition at line 217 of file MCP2300x.h.
#define set_register_MCP2300x MCP2300x_set_register |
Definition at line 146 of file MCP2300x.h.
unsigned char MCP2300x_get_port_interrupt_capture | ( | 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 179 of file MCP2300x.c.
References get_register_MCP2300x, and MCP2300x_INTCAP.
unsigned char MCP2300x_get_port_interrupt_flag | ( | 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 170 of file MCP2300x.c.
References get_register_MCP2300x, and MCP2300x_INTF.
unsigned char MCP2300x_get_port_value | ( | 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 119 of file MCP2300x.c.
References get_register_MCP2300x, and MCP2300x_GPIO.
unsigned char MCP2300x_get_register | ( | 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 71 of file MCP2300x.c.
References MCP2300X_I2C_read_byte_from_external_device, and MCP2300X_INTERNAL_ADDRESS.
void MCP2300x_initialize | ( | unsigned int | baud_rate_KHz | ) |
This function initialize the I2C module accordingly to the clock and baud rate.
baud_rate_KHz | Baud rate expressed in KHz |
Definition at line 46 of file MCP2300x.c.
References I2C_MASTER, MCP2300X_I2C_baud_rate, and MCP2300X_I2C_open.
signed char MCP2300x_set_interrupt_compare_enable | ( | 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 161 of file MCP2300x.c.
References MCP2300x_INTCON, and set_register_MCP2300x.
signed char MCP2300x_set_interrupt_compare_value | ( | 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 152 of file MCP2300x.c.
References MCP2300x_DEFVAL, and set_register_MCP2300x.
signed char MCP2300x_set_port_configuration | ( | 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 145 of file MCP2300x.c.
References MCP2300x_IOCON, and set_register_MCP2300x.
signed char MCP2300x_set_port_direction | ( | 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 83 of file MCP2300x.c.
References MCP2300x_IODIR, and set_register_MCP2300x.
signed char MCP2300x_set_port_interrupt | ( | 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 129 of file MCP2300x.c.
References get_register_MCP2300x, MCP2300x_GPINTEN, MCP2300x_GPIO, and set_register_MCP2300x.
signed char MCP2300x_set_port_polarity | ( | 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 101 of file MCP2300x.c.
References MCP2300x_IPOL, and set_register_MCP2300x.
signed char MCP2300x_set_port_pull_up_resistor | ( | 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 110 of file MCP2300x.c.
References MCP2300x_GPPU, and set_register_MCP2300x.
signed char MCP2300x_set_port_value | ( | 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 92 of file MCP2300x.c.
References MCP2300x_GPIO, and set_register_MCP2300x.
signed char MCP2300x_set_register | ( | 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 56 of file MCP2300x.c.
References MCP2300X_I2C_write_byte_to_external_device, and MCP2300X_INTERNAL_ADDRESS.