Skip to content

Commit 330e21c

Browse files
author
Daniel Campora
committed
cc3200: Use the pull up/down resistors on the antenna selection pins.
1 parent f960d75 commit 330e21c

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

cc3200/misc/antenna.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,24 @@ static antenna_type_t antenna_type_selected = ANTENNA_TYPE_INTERNAL;
5555
DEFINE PUBLIC FUNCTIONS
5656
******************************************************************************/
5757
void antenna_init0(void) {
58-
59-
MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
58+
// enable the peripheral clock and set the gpio direction for
59+
// both antenna 1 and antenna 2 pins
60+
MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
6061
MAP_GPIODirModeSet(GPIOA3_BASE, 0x0C, GPIO_DIR_MODE_OUT);
6162

62-
// configure PIN_29 for GPIOOutput
63-
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~(PAD_STRENGTH_MASK
64-
| PAD_TYPE_MASK)) | (0x00000020 | 0x00000000 ));
65-
63+
// configure antenna 1 pin type and strength
64+
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~(PAD_STRENGTH_MASK | PAD_TYPE_MASK)) | (0x00000020 | 0x00000000));
6665
// set the mode
67-
HWREG(REG_PAD_CONFIG_26) = (((HWREG(REG_PAD_CONFIG_26) & ~PAD_MODE_MASK) |
68-
0x00000000) & ~(3 << 10));
69-
66+
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~PAD_MODE_MASK) | 0x00000000) & ~(3 << 10);
7067
// set the direction
7168
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~0xC00) | 0x00000800);
7269

73-
74-
// configure PIN_30 for GPIOOutput
75-
HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~(PAD_STRENGTH_MASK
76-
| PAD_TYPE_MASK)) | (0x00000020 | 0x00000000 ));
77-
70+
// configure antenna 2 pin type and strength
71+
HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~(PAD_STRENGTH_MASK | PAD_TYPE_MASK)) | (0x00000020 | 0x00000000));
7872
// set the mode
79-
HWREG(REG_PAD_CONFIG_27) = (((HWREG(REG_PAD_CONFIG_27) & ~PAD_MODE_MASK) |
80-
0x00000000) & ~(3 << 10));
81-
73+
HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~PAD_MODE_MASK) | 0x00000000) & ~(3 << 10);
8274
// set the direction
83-
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_27) & ~0xC00) | 0x00000800);
75+
HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~0xC00) | 0x00000800);
8476

8577
// select the currently active antenna
8678
antenna_select(antenna_type_selected);
@@ -89,8 +81,14 @@ void antenna_init0(void) {
8981
void antenna_select (antenna_type_t _antenna) {
9082
if (_antenna == ANTENNA_TYPE_INTERNAL) {
9183
MAP_GPIOPinWrite(GPIOA3_BASE, 0x0C, 0x04);
84+
// also configure the pull-up and pull-down accordingly
85+
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PU;
86+
HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PD;
9287
} else {
9388
MAP_GPIOPinWrite(GPIOA3_BASE, 0x0C, 0x08);
89+
// also configure the pull-up and pull-down accordingly
90+
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PD;
91+
HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PU;
9492
}
9593
antenna_type_selected = _antenna;
9694
}

cc3200/mods/pybsleep.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,17 @@ STATIC void pybsleep_iopark (bool hibernate) {
499499
if (hibernate) {
500500
#endif
501501
// park the antenna selection pins
502+
// (tri-stated with pull down enabled)
502503
HWREG(0x4402E108) = 0x00000E61;
503504
HWREG(0x4402E10C) = 0x00000E61;
504505
#if MICROPY_HW_ANTENNA_DIVERSITY
506+
} else {
507+
// park the antenna selection pins
508+
// (tri-stated without changing the pull up/down resistors)
509+
HWREG(0x4402E108) &= ~0x000000FF;
510+
HWREG(0x4402E108) |= 0x00000C61;
511+
HWREG(0x4402E10C) &= ~0x000000FF;
512+
HWREG(0x4402E10C) |= 0x00000C61;
505513
}
506514
#endif
507515
}

0 commit comments

Comments
 (0)