Skip to content

Commit 0f2566b

Browse files
authored
Merge pull request #2432 from jeremybrodt/max326xx_bugfix
[MAX326xx] Bug fixes and clean up.
2 parents 64a30a0 + 7be00b8 commit 0f2566b

File tree

18 files changed

+115
-60
lines changed

18 files changed

+115
-60
lines changed

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32600/dac_regs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ typedef struct {
103103
__IO uint8_t output_8; /* 0x0000 Write to push values to DAC output FIFO */
104104
__IO uint16_t output_16; /* 0x0000 Write to push values to DAC output FIFO */
105105
};
106-
} mxc_dac_fifo_t;
106+
} mxc_dac_fifo_regs_t;
107107

108108
/*
109109
Register offsets for module DAC12.

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32600/gpio_regs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,12 @@ typedef struct {
459459
#define MXC_S_GPIO_OUT_MODE_PIN7_FAST_HIGH_Z ((uint32_t)(MXC_V_GPIO_OUT_MODE_FAST_HIGH_Z << MXC_F_GPIO_OUT_MODE_PIN7_POS))
460460
#define MXC_S_GPIO_OUT_MODE_PIN7_FAST_DRIVE ((uint32_t)(MXC_V_GPIO_OUT_MODE_FAST_DRIVE << MXC_F_GPIO_OUT_MODE_PIN7_POS))
461461

462-
#define MXC_V_GPIO_INT_MODE_DISABLED ((uint32_t)(0x00000000UL))
462+
#define MXC_V_GPIO_INT_MODE_DISABLE ((uint32_t)(0x00000000UL))
463463
#define MXC_V_GPIO_INT_MODE_FALLING_EDGE ((uint32_t)(0x00000001UL))
464464
#define MXC_V_GPIO_INT_MODE_RISING_EDGE ((uint32_t)(0x00000002UL))
465-
#define MXC_V_GPIO_INT_MODE_BOTH_EDGES ((uint32_t)(0x00000003UL))
466-
#define MXC_V_GPIO_INT_MODE_LOW_LEVEL ((uint32_t)(0x00000004UL))
467-
#define MXC_V_GPIO_INT_MODE_HIGH_LEVEL ((uint32_t)(0x00000005UL))
465+
#define MXC_V_GPIO_INT_MODE_ANY_EDGE ((uint32_t)(0x00000003UL))
466+
#define MXC_V_GPIO_INT_MODE_LOW_LVL ((uint32_t)(0x00000004UL))
467+
#define MXC_V_GPIO_INT_MODE_HIGH_LVL ((uint32_t)(0x00000005UL))
468468

469469
#ifdef __cplusplus
470470
}

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32600/max32600.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,10 +656,10 @@ typedef enum {
656656

657657
/*******************************************************************************/
658658

659-
#define BITBAND(reg, bit) ((0xf0000000 & (uint32_t)(reg)) + 0x2000000 + (((uint32_t)(reg) & 0x0fffffff) << 5) + ((bit) << 2))
660-
#define BITBAND_ClrBit(reg, bit) *(volatile uint32_t *)BITBAND(reg, bit) = 0
661-
#define BITBAND_SetBit(reg, bit) *(volatile uint32_t *)BITBAND(reg, bit) = 1
662-
#define BITBAND_GetBit(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit))
659+
#define BITBAND(reg, bit) ((0xf0000000 & (uint32_t)(reg)) + 0x2000000 + (((uint32_t)(reg) & 0x0fffffff) << 5) + ((bit) << 2))
660+
#define MXC_CLRBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit) = 0)
661+
#define MXC_SETBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit) = 1)
662+
#define MXC_GETBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit))
663663

664664
/*******************************************************************************/
665665

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32600/spi_regs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ typedef struct {
119119
#define MXC_F_SPI_MSTR_CFG_ALT_SCK_LO_CLK_POS 24
120120
#define MXC_F_SPI_MSTR_CFG_ALT_SCK_LO_CLK ((uint32_t)(0x0000000FUL << MXC_F_SPI_MSTR_CFG_ALT_SCK_LO_CLK_POS))
121121

122+
#define MXC_V_SPI_MSTR_CFG_PAGE_SIZE_4B ((uint32_t)0x00000000UL)
123+
#define MXC_V_SPI_MSTR_CFG_PAGE_SIZE_8B ((uint32_t)0x00000001UL)
124+
#define MXC_V_SPI_MSTR_CFG_PAGE_SIZE_16B ((uint32_t)0x00000002UL)
125+
#define MXC_V_SPI_MSTR_CFG_PAGE_SIZE_32B ((uint32_t)0x00000003UL)
126+
127+
#define MXC_S_SPI_MSTR_CFG_PAGE_4B (MXC_V_SPI_MSTR_CFG_PAGE_SIZE_4B << MXC_F_SPI_MSTR_CFG_PAGE_SIZE_POS)
128+
#define MXC_S_SPI_MSTR_CFG_PAGE_8B (MXC_V_SPI_MSTR_CFG_PAGE_SIZE_8B << MXC_F_SPI_MSTR_CFG_PAGE_SIZE_POS)
129+
#define MXC_S_SPI_MSTR_CFG_PAGE_16B (MXC_V_SPI_MSTR_CFG_PAGE_SIZE_16B << MXC_F_SPI_MSTR_CFG_PAGE_SIZE_POS)
130+
#define MXC_S_SPI_MSTR_CFG_PAGE_32B (MXC_V_SPI_MSTR_CFG_PAGE_SIZE_32B << MXC_F_SPI_MSTR_CFG_PAGE_SIZE_POS)
131+
122132
#define MXC_F_SPI_SS_SR_POLARITY_SS_POLARITY_POS 0
123133
#define MXC_F_SPI_SS_SR_POLARITY_SS_POLARITY ((uint32_t)(0x000000FFUL << MXC_F_SPI_SS_SR_POLARITY_SS_POLARITY_POS))
124134
#define MXC_F_SPI_SS_SR_POLARITY_FC_POLARITY_POS 8

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32600/system_max32600.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ void Trim_RO(void)
130130
MXC_ADCCFG->ro_cal1 = (MXC_ADCCFG->ro_cal1 & ~MXC_F_ADC_RO_CAL1_TRM_INIT) |
131131
((trim << MXC_F_ADC_RO_CAL1_TRM_INIT_POS) & MXC_F_ADC_RO_CAL1_TRM_INIT);
132132
MXC_ADCCFG->ro_cal0 = (MXC_ADCCFG->ro_cal0 & ~MXC_F_ADC_RO_CAL0_TRM_MU) | (0x04 << MXC_F_ADC_RO_CAL0_TRM_MU_POS);
133-
BITBAND_SetBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_LOAD_POS);
134-
BITBAND_SetBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
135-
BITBAND_SetBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_RUN_POS);
133+
MXC_SETBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_LOAD_POS);
134+
MXC_SETBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
135+
MXC_SETBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_RUN_POS);
136136

137137
SysTick->LOAD = 1635; /* about 50ms, based on a 32KHz systick clock */
138138
SysTick->VAL = 0;
@@ -142,7 +142,7 @@ void Trim_RO(void)
142142
SysTick->CTRL = 0;
143143

144144
trim = (MXC_ADCCFG->ro_cal0 & MXC_F_ADC_RO_CAL0_RO_TRM) >> (MXC_F_ADC_RO_CAL0_RO_TRM_POS + 2);
145-
BITBAND_ClrBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
145+
MXC_CLRBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
146146
MXC_PWRSEQ->reg5 = (MXC_PWRSEQ->reg5 & ~MXC_F_PWRSEQ_REG5_PWR_TRIM_OSC_VREF) |
147147
((trim << MXC_F_PWRSEQ_REG5_PWR_TRIM_OSC_VREF_POS) & MXC_F_PWRSEQ_REG5_PWR_TRIM_OSC_VREF);
148148

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32610/dac_regs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ typedef struct {
103103
__IO uint8_t output_8; /* 0x0000 Write to push values to DAC output FIFO */
104104
__IO uint16_t output_16; /* 0x0000 Write to push values to DAC output FIFO */
105105
};
106-
} mxc_dac_fifo_t;
106+
} mxc_dac_fifo_regs_t;
107107

108108
/*
109109
Register offsets for module DAC12.

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32610/gpio_regs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,12 @@ typedef struct {
459459
#define MXC_S_GPIO_OUT_MODE_PIN7_FAST_HIGH_Z ((uint32_t)(MXC_V_GPIO_OUT_MODE_FAST_HIGH_Z << MXC_F_GPIO_OUT_MODE_PIN7_POS))
460460
#define MXC_S_GPIO_OUT_MODE_PIN7_FAST_DRIVE ((uint32_t)(MXC_V_GPIO_OUT_MODE_FAST_DRIVE << MXC_F_GPIO_OUT_MODE_PIN7_POS))
461461

462-
#define MXC_V_GPIO_INT_MODE_DISABLED ((uint32_t)(0x00000000UL))
462+
#define MXC_V_GPIO_INT_MODE_DISABLE ((uint32_t)(0x00000000UL))
463463
#define MXC_V_GPIO_INT_MODE_FALLING_EDGE ((uint32_t)(0x00000001UL))
464464
#define MXC_V_GPIO_INT_MODE_RISING_EDGE ((uint32_t)(0x00000002UL))
465-
#define MXC_V_GPIO_INT_MODE_BOTH_EDGES ((uint32_t)(0x00000003UL))
466-
#define MXC_V_GPIO_INT_MODE_LOW_LEVEL ((uint32_t)(0x00000004UL))
467-
#define MXC_V_GPIO_INT_MODE_HIGH_LEVEL ((uint32_t)(0x00000005UL))
465+
#define MXC_V_GPIO_INT_MODE_ANY_EDGE ((uint32_t)(0x00000003UL))
466+
#define MXC_V_GPIO_INT_MODE_LOW_LVL ((uint32_t)(0x00000004UL))
467+
#define MXC_V_GPIO_INT_MODE_HIGH_LVL ((uint32_t)(0x00000005UL))
468468

469469
#ifdef __cplusplus
470470
}

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32610/max32610.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ typedef enum IRQn_Type {
109109
#include <core_cm3.h> /* Processor and core peripherals */
110110
#include "system_max32610.h" /* System Header */
111111

112-
113112
/* ================================================================================ */
114113
/* ================== Device Specific Memory Section ================== */
115114
/* ================================================================================ */
@@ -126,7 +125,6 @@ typedef enum IRQn_Type {
126125
/*******************************************************************************/
127126
/* General Purpose I/O Ports (GPIO) */
128127

129-
130128
#define MXC_BASE_GPIO ((uint32_t)0x40000000UL)
131129
#define MXC_GPIO ((mxc_gpio_regs_t *)MXC_BASE_GPIO)
132130
#define MXC_BASE_GPIO_BITBAND ((uint32_t)0x42000000UL)
@@ -645,10 +643,10 @@ typedef enum {
645643

646644
/*******************************************************************************/
647645

648-
#define BITBAND(reg, bit) ((0xf0000000 & (uint32_t)(reg)) + 0x2000000 + (((uint32_t)(reg) & 0x0fffffff) << 5) + ((bit) << 2))
649-
#define BITBAND_ClrBit(reg, bit) *(volatile uint32_t *)BITBAND(reg, bit) = 0
650-
#define BITBAND_SetBit(reg, bit) *(volatile uint32_t *)BITBAND(reg, bit) = 1
651-
#define BITBAND_GetBit(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit))
646+
#define BITBAND(reg, bit) ((0xf0000000 & (uint32_t)(reg)) + 0x2000000 + (((uint32_t)(reg) & 0x0fffffff) << 5) + ((bit) << 2))
647+
#define MXC_CLRBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit) = 0)
648+
#define MXC_SETBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit) = 1)
649+
#define MXC_GETBIT(reg, bit) (*(volatile uint32_t *)BITBAND(reg, bit))
652650

653651
/*******************************************************************************/
654652

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32610/system_max32610.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ void Trim_RO(void)
130130
MXC_ADCCFG->ro_cal1 = (MXC_ADCCFG->ro_cal1 & ~MXC_F_ADC_RO_CAL1_TRM_INIT) |
131131
((trim << MXC_F_ADC_RO_CAL1_TRM_INIT_POS) & MXC_F_ADC_RO_CAL1_TRM_INIT);
132132
MXC_ADCCFG->ro_cal0 = (MXC_ADCCFG->ro_cal0 & ~MXC_F_ADC_RO_CAL0_TRM_MU) | (0x04 << MXC_F_ADC_RO_CAL0_TRM_MU_POS);
133-
BITBAND_SetBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_LOAD_POS);
134-
BITBAND_SetBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
135-
BITBAND_SetBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_RUN_POS);
133+
MXC_SETBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_LOAD_POS);
134+
MXC_SETBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
135+
MXC_SETBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_RUN_POS);
136136

137137
SysTick->LOAD = 1635; /* about 50ms, based on a 32KHz systick clock */
138138
SysTick->VAL = 0;
@@ -142,7 +142,7 @@ void Trim_RO(void)
142142
SysTick->CTRL = 0;
143143

144144
trim = (MXC_ADCCFG->ro_cal0 & MXC_F_ADC_RO_CAL0_RO_TRM) >> (MXC_F_ADC_RO_CAL0_RO_TRM_POS + 2);
145-
BITBAND_ClrBit(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
145+
MXC_CLRBIT(&MXC_ADCCFG->ro_cal0, MXC_F_ADC_RO_CAL0_RO_CAL_EN_POS);
146146
MXC_PWRSEQ->reg5 = (MXC_PWRSEQ->reg5 & ~MXC_F_PWRSEQ_REG5_PWR_TRIM_OSC_VREF) |
147147
((trim << MXC_F_PWRSEQ_REG5_PWR_TRIM_OSC_VREF_POS) & MXC_F_PWRSEQ_REG5_PWR_TRIM_OSC_VREF);
148148

hal/targets/cmsis/TARGET_Maxim/TARGET_MAX32610/usb_regs.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ typedef struct {
305305
#define MXC_F_USB_SETUP1_BYTE7_POS 24
306306
#define MXC_F_USB_SETUP1_BYTE7 ((uint32_t)(0x000000FFUL << MXC_F_USB_SETUP1_BYTE7_POS))
307307

308-
309308
#define MXC_F_USB_EP0_EP_DIR_POS 0
310309
#define MXC_F_USB_EP0_EP_DIR ((uint32_t)(0x00000003UL << MXC_F_USB_EP0_EP_DIR_POS))
311310
#define MXC_F_USB_EP0_EP_BUF2_POS 3
@@ -442,6 +441,34 @@ typedef struct {
442441
#define MXC_F_USB_EP7_EP_ST_ACK_POS 10
443442
#define MXC_F_USB_EP7_EP_ST_ACK ((uint32_t)(0x00000001UL << MXC_F_USB_EP7_EP_ST_ACK_POS))
444443

444+
#define MXC_F_USB_EP_DIR_POS (0)
445+
#define MXC_F_USB_EP_DIR ((uint32_t)(0x00000003UL << MXC_F_USB_EP_DIR_POS))
446+
447+
#define MXC_V_USB_EP_DIR_DISABLE ((uint32_t)0x00000000UL)
448+
#define MXC_V_USB_EP_DIR_OUT ((uint32_t)0x00000001UL)
449+
#define MXC_V_USB_EP_DIR_IN ((uint32_t)0x00000002UL)
450+
#define MXC_V_USB_EP_DIR_CONTROL ((uint32_t)0x00000003UL)
451+
452+
#define MXC_S_USB_EP_DIR_DISABLE (MXC_V_USB_EP_DIR_DISABLE << MXC_F_USB_EP_DIR_POS)
453+
#define MXC_S_USB_EP_DIR_OUT (MXC_V_USB_EP_DIR_OUT << MXC_F_USB_EP_DIR_POS)
454+
#define MXC_S_USB_EP_DIR_IN (MXC_V_USB_EP_DIR_IN << MXC_F_USB_EP_DIR_POS)
455+
#define MXC_S_USB_EP_DIR_CONTROL (MXC_V_USB_EP_DIR_CONTROL << MXC_F_USB_EP_DIR_POS)
456+
457+
#define MXC_F_USB_EP_BUF2_POS (3)
458+
#define MXC_F_USB_EP_BUF2 ((uint32_t)(0x00000001UL << MXC_F_USB_EP_BUF2_POS))
459+
#define MXC_F_USB_EP_INTEN_POS (4)
460+
#define MXC_F_USB_EP_INT_EN ((uint32_t)(0x00000001UL << MXC_F_USB_EP_INTEN_POS))
461+
#define MXC_F_USB_EP_NAK_EN_POS (5)
462+
#define MXC_F_USB_EP_NAK_EN ((uint32_t)(0x00000001UL << MXC_F_USB_EP_NAK_EN_POS))
463+
#define MXC_F_USB_EP_DT_POS (6)
464+
#define MXC_F_USB_EP_DT ((uint32_t)(0x00000001UL << MXC_F_USB_EP_DT_POS))
465+
#define MXC_F_USB_EP_STALL_POS (8)
466+
#define MXC_F_USB_EP_STALL ((uint32_t)(0x00000001UL << MXC_F_USB_EP_STALL_POS))
467+
#define MXC_F_USB_EP_ST_STALL_POS (9)
468+
#define MXC_F_USB_EP_ST_STALL ((uint32_t)(0x00000001UL << MXC_F_USB_EP_ST_STALL_POS))
469+
#define MXC_F_USB_EP_ST_ACK_POS (10)
470+
#define MXC_F_USB_EP_ST_ACK ((uint32_t)(0x00000001UL << MXC_F_USB_EP_ST_ACK_POS))
471+
445472
#ifdef __cplusplus
446473
}
447474
#endif

0 commit comments

Comments
 (0)