Permalink
Browse files

Changed MCP2221_GPIO_MODE_ALT numbering to match the datasheet (1-3 i…

…nstead of 0-2)

Be sure to update any of your code that sets GPIO mode!
  • Loading branch information...
zkemble committed Feb 24, 2016
1 parent 88fb4f4 commit 165cc68b8c61191b9f8010864b13f9ac43b4ef93
Showing with 35 additions and 20 deletions.
  1. +5 −2 Changelog.txt
  2. +2 −2 examples/adc/main.c
  3. +6 −6 examples/bunch_of_stuff/main.c
  4. +2 −2 examples/dac/main.c
  5. +2 −2 examples/interrupt/main.c
  6. +9 −3 lib/libmcp2221.h
  7. +9 −3 libmcp2221/libmcp2221.h
View
@@ -1,5 +1,8 @@
2015-08-13 (v1.0.0):
- Initial release
2016-02-24 (v1.0.2):
- Changed MCP2221_GPIO_MODE_ALT numbering to match the datasheet (1-3 instead of 0-2)
2015-08-14 (v1.0.1):
- Fixed some null issues
2015-08-13 (v1.0.0):
- Initial release
View
@@ -53,9 +53,9 @@ int main(void)
gpioConf.conf[0].direction = MCP2221_GPIO_DIR_OUTPUT;
gpioConf.conf[0].value = MCP2221_GPIO_VALUE_LOW;
// Configure GPIO 1, 2 and 3 as alternate function 0, which is ADC
// Configure GPIO 1, 2 and 3 as alternate function 1, which is ADC
gpioConf.conf[1].gpios = MCP2221_GPIO1 | MCP2221_GPIO2 | MCP2221_GPIO3;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT0;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT1;
// Apply config
mcp2221_setGPIOConf(myDev, &gpioConf);
@@ -71,17 +71,17 @@ int main(void)
gpioConf.conf[0].direction = MCP2221_GPIO_DIR_OUTPUT;
gpioConf.conf[0].value = MCP2221_GPIO_VALUE_HIGH;
// Configure GPIO 1 as alternative function 2 (which is interrupt input for GPIO1)
// Configure GPIO 1 as alternative function 3 (which is interrupt input for GPIO1)
gpioConf.conf[1].gpios = MCP2221_GPIO1;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT2;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT3;
// Configure GPIO 2 as alternate function 1 (DAC output)
// Configure GPIO 2 as alternate function 2 (DAC output)
gpioConf.conf[2].gpios = MCP2221_GPIO2;
gpioConf.conf[2].mode = MCP2221_GPIO_MODE_ALT1;
gpioConf.conf[2].mode = MCP2221_GPIO_MODE_ALT2;
// Configure GPIO 3 as as alternate function 0 (which is ADC3 for GPIO3)
// Configure GPIO 3 as as alternate function 1 (which is ADC3 for GPIO3)
gpioConf.conf[3].gpios = MCP2221_GPIO3;
gpioConf.conf[3].mode = MCP2221_GPIO_MODE_ALT0;
gpioConf.conf[3].mode = MCP2221_GPIO_MODE_ALT1;
// Apply config
mcp2221_setGPIOConf(myDev, &gpioConf);
View
@@ -53,9 +53,9 @@ int main(void)
gpioConf.conf[0].direction = MCP2221_GPIO_DIR_OUTPUT;
gpioConf.conf[0].value = MCP2221_GPIO_VALUE_LOW;
// Configure GPIO 2 as alternate function 1, which is DAC
// Configure GPIO 2 as alternate function 2, which is DAC
gpioConf.conf[1].gpios = MCP2221_GPIO2;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT1;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT2;
// Apply config
mcp2221_setGPIOConf(myDev, &gpioConf);
@@ -46,9 +46,9 @@ int main(void)
gpioConf.conf[0].direction = MCP2221_GPIO_DIR_OUTPUT;
gpioConf.conf[0].value = MCP2221_GPIO_VALUE_LOW;
// Configure GPIO 1 as alternate function 2, which is interrupt input
// Configure GPIO 1 as alternate function 3, which is interrupt input
gpioConf.conf[1].gpios = MCP2221_GPIO1;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT2;
gpioConf.conf[1].mode = MCP2221_GPIO_MODE_ALT3;
// Apply config
mcp2221_setGPIOConf(myDev, &gpioConf);
View
@@ -89,17 +89,23 @@ typedef enum
/**
* \enum mcp2221_gpio_mode_t
* \brief GPIO modes (check GP DESIGNATION TABLE in the datasheet for what the dedicated and alternative functions do for each pin)
* \note GP DESIGNATION TABLE has the ALT_FUNC numbered 0-2, should be 1-3 to match the rest of the datasheet
*/
typedef enum
{
MCP2221_GPIO_MODE_GPIO = 0, /**< Normal IO, manually set to input/output, high/low */
MCP2221_GPIO_MODE_DEDI = 1, /**< Dedicated function */
MCP2221_GPIO_MODE_ALT0 = 2, /**< Alternative function 0 */
MCP2221_GPIO_MODE_ALT1 = 3, /**< Alternative function 1 */
MCP2221_GPIO_MODE_ALT2 = 4, /**< Alternative function 2 */
MCP2221_GPIO_MODE_ALT1 = 2, /**< Alternative function 1 */
MCP2221_GPIO_MODE_ALT2 = 3, /**< Alternative function 2 */
MCP2221_GPIO_MODE_ALT3 = 4, /**< Alternative function 3 */
MCP2221_GPIO_MODE_INVALID = 0xff /**< Invalid */
}mcp2221_gpio_mode_t;
#define MCP2221_GPIO_MODE_SSPND MCP2221_GPIO_MODE_DEDI /**< TODO */
#define MCP2221_GPIO_MODE_ADC MCP2221_GPIO_MODE_ALT1 /**< TODO */
#define MCP2221_GPIO_MODE_DAC MCP2221_GPIO_MODE_ALT2 /**< TODO */
#define MCP2221_GPIO_MODE_IOC MCP2221_GPIO_MODE_ALT3 /**< TODO */
/**
* \enum mcp2221_gpio_value_t
* \brief GPIO read values
View
@@ -89,17 +89,23 @@ typedef enum
/**
* \enum mcp2221_gpio_mode_t
* \brief GPIO modes (check GP DESIGNATION TABLE in the datasheet for what the dedicated and alternative functions do for each pin)
* \note GP DESIGNATION TABLE has the ALT_FUNC numbered 0-2, should be 1-3 to match the rest of the datasheet
*/
typedef enum
{
MCP2221_GPIO_MODE_GPIO = 0, /**< Normal IO, manually set to input/output, high/low */
MCP2221_GPIO_MODE_DEDI = 1, /**< Dedicated function */
MCP2221_GPIO_MODE_ALT0 = 2, /**< Alternative function 0 */
MCP2221_GPIO_MODE_ALT1 = 3, /**< Alternative function 1 */
MCP2221_GPIO_MODE_ALT2 = 4, /**< Alternative function 2 */
MCP2221_GPIO_MODE_ALT1 = 2, /**< Alternative function 1 */
MCP2221_GPIO_MODE_ALT2 = 3, /**< Alternative function 2 */
MCP2221_GPIO_MODE_ALT3 = 4, /**< Alternative function 3 */
MCP2221_GPIO_MODE_INVALID = 0xff /**< Invalid */
}mcp2221_gpio_mode_t;
#define MCP2221_GPIO_MODE_SSPND MCP2221_GPIO_MODE_DEDI /**< TODO */
#define MCP2221_GPIO_MODE_ADC MCP2221_GPIO_MODE_ALT1 /**< TODO */
#define MCP2221_GPIO_MODE_DAC MCP2221_GPIO_MODE_ALT2 /**< TODO */
#define MCP2221_GPIO_MODE_IOC MCP2221_GPIO_MODE_ALT3 /**< TODO */
/**
* \enum mcp2221_gpio_value_t
* \brief GPIO read values

0 comments on commit 165cc68

Please sign in to comment.