Skip to content

Commit

Permalink
fix(PeriphDrivers): Fix Unusable MAX32690 I2C Pins (#958)
Browse files Browse the repository at this point in the history
Co-authored-by: Sihyung Woo <[email protected]>
  • Loading branch information
Jake-Carter and sihyung-maxim authored Mar 21, 2024
1 parent 7ee1fd3 commit 7db1d20
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Libraries/CMSIS/Device/Maxim/GCC/mxc_version.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
##############################################################################
# Autogenerated version info for build system.
MSDK_VERSION_STRING := v2024_02-25-g36ccc483ba
MSDK_VERSION_STRING := v2024_02-22-g61823d75cf
MSDK_VERSION_YEAR := 2024
MSDK_VERSION_MONTH := 2

Expand Down
8 changes: 7 additions & 1 deletion Libraries/PeriphDrivers/Include/MAX32690/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,17 @@ typedef int (*mxc_i2c_slave_handler_t)(mxc_i2c_regs_t *i2c, mxc_i2c_slave_event_

/**
* @brief Initialize and enable I2C peripheral.
* Note the ME18 assigns the same alternate function to multiple sets
* of pins. The drivers will enable both sets so that either can be used.
* Users should ensure the unused set is left unconnected.
*
* See MAX32690 Rev A2 Errata #16:
* https://www.analog.com/media/en/technical-documentation/data-sheets/max32690_a2_errata_rev2.pdf
*
* @note On default this function enables I2C peripheral clock and i2c gpio pins.
* if you wish to manage clock and gpio related things in upper level instead of here.
* Define MSDK_NO_GPIO_CLK_INIT flag in project.mk file.
* By this flag this function will remove clock and gpio related codes from file
* By this flag this function will remove clock and gpio related codes from file.
*
* @param i2c Pointer to I2C registers (selects the I2C block used.)
* @param masterMode Whether to put the device in master or slave mode. Use
Expand Down
3 changes: 3 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32690/mxc_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
// Predefined GPIO Configurations
extern const mxc_gpio_cfg_t gpio_cfg_extclk;
extern const mxc_gpio_cfg_t gpio_cfg_i2c0;
extern const mxc_gpio_cfg_t gpio_cfg_i2c0a;
extern const mxc_gpio_cfg_t gpio_cfg_i2c1;
extern const mxc_gpio_cfg_t gpio_cfg_i2c1a;
extern const mxc_gpio_cfg_t gpio_cfg_i2c2;
extern const mxc_gpio_cfg_t gpio_cfg_i2c2c;

extern const mxc_gpio_cfg_t gpio_cfg_uart0;
extern const mxc_gpio_cfg_t gpio_cfg_uart0_flow;
Expand Down
10 changes: 10 additions & 0 deletions Libraries/PeriphDrivers/Source/I2C/i2c_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,25 @@ int MXC_I2C_Init(mxc_i2c_regs_t *i2c, int masterMode, unsigned int slaveAddr)
#ifndef MSDK_NO_GPIO_CLK_INIT
MXC_I2C_Shutdown(i2c); // Clear everything out

/* Note: The ME18 assigns the same alternate function to multiple sets
* of pins. The drivers will enable both sets so that either can be used.
* Users should ensure the unused set is left unconnected.
*
* See MAX32690 Rev A2 Errata #16:
* https://www.analog.com/media/en/technical-documentation/data-sheets/max32690_a2_errata_rev2.pdf
*/
if (i2c == MXC_I2C0) {
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_I2C0);
MXC_GPIO_Config(&gpio_cfg_i2c0);
MXC_GPIO_Config(&gpio_cfg_i2c0a);
} else if (i2c == MXC_I2C1) {
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_I2C1);
MXC_GPIO_Config(&gpio_cfg_i2c1);
MXC_GPIO_Config(&gpio_cfg_i2c1a);
} else if (i2c == MXC_I2C2) {
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_I2C2);
MXC_GPIO_Config(&gpio_cfg_i2c2);
MXC_GPIO_Config(&gpio_cfg_i2c2c);
} else {
return E_NO_DEVICE;
}
Expand Down
14 changes: 14 additions & 0 deletions Libraries/PeriphDrivers/Source/SYS/pins_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,26 @@
const mxc_gpio_cfg_t gpio_cfg_extclk = { MXC_GPIO0, (MXC_GPIO_PIN_23), MXC_GPIO_FUNC_IN,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };

/* Note: The ME18 has assigned the same alternate function to multiple pins. Therefore, when I2C is
* enabled it will be enabled on both sets of pins simultaneously. The ME18 driver layer also does
* this intentionally so that either set of pins can be used. Users should ensure the unused pin set
* is left unconnected.
*
* See MAX32690 Rev A2 Errata #16
* https://www.analog.com/media/en/technical-documentation/data-sheets/max32690_a2_errata_rev2.pdf
* */
const mxc_gpio_cfg_t gpio_cfg_i2c0 = { MXC_GPIO2, (MXC_GPIO_PIN_7 | MXC_GPIO_PIN_8), MXC_GPIO_FUNC_ALT1,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };
const mxc_gpio_cfg_t gpio_cfg_i2c0a = { MXC_GPIO0, (MXC_GPIO_PIN_30 | MXC_GPIO_PIN_31), MXC_GPIO_FUNC_ALT1,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };
const mxc_gpio_cfg_t gpio_cfg_i2c1 = { MXC_GPIO0, (MXC_GPIO_PIN_11 | MXC_GPIO_PIN_12), MXC_GPIO_FUNC_ALT1,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };
const mxc_gpio_cfg_t gpio_cfg_i2c1a = { MXC_GPIO2, (MXC_GPIO_PIN_17 | MXC_GPIO_PIN_18), MXC_GPIO_FUNC_ALT1,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };
const mxc_gpio_cfg_t gpio_cfg_i2c2 = { MXC_GPIO1, (MXC_GPIO_PIN_7 | MXC_GPIO_PIN_8), MXC_GPIO_FUNC_ALT3,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };
const mxc_gpio_cfg_t gpio_cfg_i2c2c = { MXC_GPIO0, (MXC_GPIO_PIN_13 | MXC_GPIO_PIN_14), MXC_GPIO_FUNC_ALT3,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };

const mxc_gpio_cfg_t gpio_cfg_uart0 = { MXC_GPIO2, (MXC_GPIO_PIN_11 | MXC_GPIO_PIN_12), MXC_GPIO_FUNC_ALT1,
MXC_GPIO_PAD_PULL_UP, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 };
Expand Down
2 changes: 1 addition & 1 deletion mxc_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Format: `[Release tag]-[commits since release tag]-g[commit SHA]`
* If exactly on a release tag, this string will match the tag
*/
#define MSDK_VERSION_STRING "v2024_02-25-g36ccc483ba"
#define MSDK_VERSION_STRING "v2024_02-22-g61823d75cf"
/**
* @brief The month of the current MSDK version
*/
Expand Down

0 comments on commit 7db1d20

Please sign in to comment.