Skip to content

Commit a3acaa0

Browse files
author
Daniel Campora
committed
cc3200: Add antenna selection feature to WLAN.
1 parent 098f5ae commit a3acaa0

File tree

14 files changed

+84
-43
lines changed

14 files changed

+84
-43
lines changed

cc3200/application.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ APP_HAL_SRC_C = $(addprefix hal/,\
7575
)
7676

7777
APP_MISC_SRC_C = $(addprefix misc/,\
78+
antenna.c \
7879
FreeRTOSHooks.c \
7980
pin_named_pins.c \
8081
help.c \

cc3200/boards/LAUNCHXL/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define MICROPY_HW_HAS_SDCARD (0)
3434
#define MICROPY_HW_ENABLE_RNG (1)
3535
#define MICROPY_HW_ENABLE_RTC (1)
36+
#define MICROPY_HW_ANTENNA_DIVERSITY (0)
3637

3738
#define MICROPY_STDIO_UART 1
3839
#define MICROPY_STDIO_UART_BAUD 115200

cc3200/boards/WIPY/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define MICROPY_HW_HAS_SDCARD (1)
3434
#define MICROPY_HW_ENABLE_RNG (1)
3535
#define MICROPY_HW_ENABLE_RTC (1)
36+
#define MICROPY_HW_ANTENNA_DIVERSITY (1)
3637

3738
#define MICROPY_SYS_LED_PRCM PRCM_GPIOA3
3839
#define MICROPY_SAFE_BOOT_PRCM PRCM_GPIOA3

cc3200/bootmgr/bootloader.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ BOOT_CC3100_SRC_C = $(addprefix drivers/cc3100/,\
4242
)
4343

4444
BOOT_MISC_SRC_C = $(addprefix misc/,\
45+
antenna.c \
4546
mperror.c \
4647
)
4748

cc3200/bootmgr/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include "cc3200_hal.h"
5454
#include "debug.h"
5555
#include "mperror.h"
56+
#include "antenna.h"
5657

5758

5859
//*****************************************************************************
@@ -151,6 +152,13 @@ static void bootmgr_board_init(void) {
151152

152153
mperror_bootloader_check_reset_cause();
153154

155+
#if MICROPY_HW_ANTENNA_DIVERSITY
156+
// configure the antenna selection pins
157+
antenna_init0();
158+
// select the internal antenna
159+
antenna_select(ANTENNA_TYPE_INTERNAL);
160+
#endif
161+
154162
// Enable the Data Hashing Engine
155163
CRYPTOHASH_Init();
156164

cc3200/hal/pin.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@
4949
#include "inc/hw_ocp_shared.h"
5050
#include "pin.h"
5151

52-
//*****************************************************************************
53-
// Macros
54-
//*****************************************************************************
55-
#define PAD_MODE_MASK 0x0000000F
56-
#define PAD_STRENGTH_MASK 0x000000E0
57-
#define PAD_TYPE_MASK 0x00000310
58-
#define PAD_CONFIG_BASE ((OCP_SHARED_BASE + \
59-
OCP_SHARED_O_GPIO_PAD_CONFIG_0))
60-
6152
//*****************************************************************************
6253
// PIN to PAD matrix
6354
//*****************************************************************************

cc3200/hal/pin.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ extern "C"
143143
#define PIN_TYPE_OD_PD 0x00000210
144144
#define PIN_TYPE_ANALOG 0x10000000
145145

146+
//*****************************************************************************
147+
// Macros for mode and type
148+
//*****************************************************************************
149+
#define PAD_MODE_MASK 0x0000000F
150+
#define PAD_STRENGTH_MASK 0x000000E0
151+
#define PAD_TYPE_MASK 0x00000310
152+
#define PAD_CONFIG_BASE ((OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_0))
146153

147154
//*****************************************************************************
148155
//

cc3200/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "simplelink.h"
3535
#include "pybwdt.h"
3636
#include "debug.h"
37+
#include "antenna.h"
3738
#include "mperror.h"
3839

3940
/******************************************************************************
@@ -65,6 +66,13 @@ int main (void) {
6566
// Initialize the clocks and the interrupt system
6667
HAL_SystemInit();
6768

69+
#if MICROPY_HW_ANTENNA_DIVERSITY
70+
// configure the antenna selection pins
71+
antenna_init0();
72+
// select the internal antenna
73+
antenna_select(ANTENNA_TYPE_INTERNAL);
74+
#endif
75+
6876
// Init the watchdog
6977
pybwdt_init0();
7078

cc3200/misc/mperror.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void mperror_init0 (void) {
9191
// configure the system led
9292
pin_config ((pin_obj_t *)&MICROPY_SYS_LED_GPIO, PIN_MODE_0, GPIO_DIR_MODE_OUT, PIN_TYPE_STD, PIN_STRENGTH_6MA);
9393
#endif
94+
mperror_heart_beat.enabled = true;
9495
mperror_heartbeat_switch_off();
9596
}
9697

@@ -132,25 +133,19 @@ void mperror_signal_error (void) {
132133
}
133134
}
134135

135-
void mperror_enable_heartbeat (void) {
136-
mperror_heart_beat.enabled = true;
137-
}
138-
139136
void mperror_heartbeat_switch_off (void) {
140-
mperror_heart_beat.on_time = 0;
141-
mperror_heart_beat.off_time = 0;
142-
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
143-
}
144-
145-
void mperror_disable_heartbeat (void) {
146-
mperror_heart_beat.do_disable = true;
137+
if (mperror_heart_beat.enabled) {
138+
mperror_heart_beat.on_time = 0;
139+
mperror_heart_beat.off_time = 0;
140+
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
141+
}
147142
}
148143

149144
void mperror_heartbeat_signal (void) {
150145
if (mperror_heart_beat.do_disable) {
151-
mperror_heart_beat.enabled = false;
152146
mperror_heart_beat.do_disable = false;
153147
mperror_heartbeat_switch_off();
148+
mperror_heart_beat.enabled = false;
154149
}
155150
else if (mperror_heart_beat.enabled) {
156151
if (!mperror_heart_beat.beating) {
@@ -206,15 +201,15 @@ void nlr_jump_fail(void *val) {
206201
/// \function enable()
207202
/// Enables the heartbeat signal
208203
STATIC mp_obj_t pyb_enable_heartbeat(mp_obj_t self) {
209-
mperror_enable_heartbeat ();
204+
mperror_heart_beat.enabled = true;
210205
return mp_const_none;
211206
}
212207
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_enable_heartbeat_obj, pyb_enable_heartbeat);
213208

214209
/// \function disable()
215210
/// Disables the heartbeat signal
216211
STATIC mp_obj_t pyb_disable_heartbeat(mp_obj_t self) {
217-
mperror_disable_heartbeat ();
212+
mperror_heart_beat.do_disable = true;
218213
return mp_const_none;
219214
}
220215
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_disable_heartbeat_obj, pyb_disable_heartbeat);

cc3200/misc/mperror.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ void mperror_init0 (void);
3838
void mperror_bootloader_check_reset_cause (void);
3939
void mperror_deinit_sfe_pin (void);
4040
void mperror_signal_error (void);
41-
void mperror_enable_heartbeat (void);
4241
void mperror_heartbeat_switch_off (void);
43-
void mperror_disable_heartbeat (void);
4442
void mperror_heartbeat_signal (void);
4543

4644
#endif // MPERROR_H_

0 commit comments

Comments
 (0)