Skip to content

Commit b4a41a8

Browse files
author
Daniel Campora
committed
cc3200: Add missing antenna diversity source files.
1 parent a3acaa0 commit b4a41a8

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

cc3200/misc/antenna.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2015 Daniel Campora
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <stdint.h>
28+
29+
#include "mpconfigboard.h"
30+
#include "inc/hw_types.h"
31+
#include "inc/hw_gpio.h"
32+
#include "inc/hw_ints.h"
33+
#include "inc/hw_memmap.h"
34+
#include "rom_map.h"
35+
#include "pin.h"
36+
#include "prcm.h"
37+
#include "gpio.h"
38+
#include "antenna.h"
39+
40+
41+
#if MICROPY_HW_ANTENNA_DIVERSITY
42+
43+
/******************************************************************************
44+
DEFINE CONSTANTS
45+
******************************************************************************/
46+
#define REG_PAD_CONFIG_26 (0x4402E108)
47+
#define REG_PAD_CONFIG_27 (0x4402E10C)
48+
49+
/******************************************************************************
50+
DEFINE PUBLIC FUNCTIONS
51+
******************************************************************************/
52+
void antenna_init0(void) {
53+
54+
MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
55+
MAP_GPIODirModeSet(GPIOA3_BASE, 0x0C, GPIO_DIR_MODE_OUT);
56+
57+
// configure PIN_29 for GPIOOutput
58+
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~(PAD_STRENGTH_MASK
59+
| PAD_TYPE_MASK)) | (0x00000020 | 0x00000000 ));
60+
61+
// set the mode
62+
HWREG(REG_PAD_CONFIG_26) = (((HWREG(REG_PAD_CONFIG_26) & ~PAD_MODE_MASK) |
63+
0x00000000) & ~(3 << 10));
64+
65+
// set the direction
66+
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~0xC00) | 0x00000800);
67+
68+
69+
// configure PIN_30 for GPIOOutput
70+
HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~(PAD_STRENGTH_MASK
71+
| PAD_TYPE_MASK)) | (0x00000020 | 0x00000000 ));
72+
73+
// set the mode
74+
HWREG(REG_PAD_CONFIG_27) = (((HWREG(REG_PAD_CONFIG_27) & ~PAD_MODE_MASK) |
75+
0x00000000) & ~(3 << 10));
76+
77+
// set the direction
78+
HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_27) & ~0xC00) | 0x00000800);
79+
}
80+
81+
void antenna_select (antenna_type_t antenna_type) {
82+
if (antenna_type == ANTENNA_TYPE_INTERNAL) {
83+
MAP_GPIOPinWrite(GPIOA3_BASE, 0x0C, 0x04);
84+
} else {
85+
MAP_GPIOPinWrite(GPIOA3_BASE, 0x0C, 0x08);
86+
}
87+
}
88+
89+
#endif
90+

cc3200/misc/antenna.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2015 Daniel Campora
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef _ANTENNA_H_
28+
#define _ANTENNA_H_
29+
30+
typedef enum {
31+
ANTENNA_TYPE_INTERNAL = 0,
32+
ANTENNA_TYPE_EXTERNAL
33+
} antenna_type_t;
34+
35+
extern void antenna_init0 (void);
36+
extern void antenna_select (antenna_type_t antenna_type);
37+
38+
#endif /* _ANTENNA_H_ */

0 commit comments

Comments
 (0)