Skip to content

Commit e74fbcd

Browse files
committed
Add CC3220SF_Launchxl to Mbed OS
1 parent 3d5489a commit e74fbcd

File tree

189 files changed

+111504
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+111504
-0
lines changed

components/storage/blockdevice/COMPONENT_SD/mbed_lib.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@
165165
"SPI_MISO": "D12",
166166
"SPI_CLK": "D13",
167167
"SPI_CS": "D10"
168+
},
169+
"CC3220SF_LAUNCHXL": {
170+
"SPI_MOSI": "D11",
171+
"SPI_MISO": "D12",
172+
"SPI_CLK": "D13",
173+
"SPI_CS": "D10"
168174
}
169175
}
170176
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2018 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef MBED_PERIPHERALPINS_H
18+
#define MBED_PERIPHERALPINS_H
19+
20+
#include "pinmap.h"
21+
#include "PeripheralNames.h"
22+
23+
/************GPIO***************/
24+
extern const PinMap PinMap_GPIO[];
25+
26+
/************PWM****************/
27+
extern const PinMap PinMap_PWM[];
28+
29+
/************UART***************/
30+
extern const PinMap PinMap_UART_TX[];
31+
extern const PinMap PinMap_UART_RX[];
32+
extern const PinMap PinMap_UART_CTS[];
33+
extern const PinMap PinMap_UART_RTS[];
34+
35+
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2018 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#ifndef MBED_PORTNAMES_H
17+
#define MBED_PORTNAMES_H
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
typedef enum {
24+
Port0 = 0,
25+
Port1 = 1,
26+
Port2 = 2,
27+
Port3 = 3
28+
} PortName;
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif
33+
#endif
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
/*
2+
* Copyright (c) 2016-2018, Texas Instruments Incorporated
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of Texas Instruments Incorporated nor the names of
17+
* its contributors may be used to endorse or promote products derived
18+
* from this software without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
/*
34+
* ======== CC3220SF_LAUNCHXL.c ========
35+
* This file is responsible for setting up the board specific items for the
36+
* CC3220SF_LAUNCHXL board.
37+
*/
38+
39+
#include <stdbool.h>
40+
#include <stddef.h>
41+
#include <stdint.h>
42+
43+
#include <ti/devices/cc32xx/inc/hw_ints.h>
44+
#include <ti/devices/cc32xx/inc/hw_memmap.h>
45+
#include <ti/devices/cc32xx/inc/hw_types.h>
46+
47+
#include <ti/devices/cc32xx/driverlib/rom.h>
48+
#include <ti/devices/cc32xx/driverlib/rom_map.h>
49+
#include <ti/devices/cc32xx/driverlib/adc.h>
50+
#include <ti/devices/cc32xx/driverlib/gpio.h>
51+
#include <ti/devices/cc32xx/driverlib/pin.h>
52+
#include <ti/devices/cc32xx/driverlib/prcm.h>
53+
#include <ti/devices/cc32xx/driverlib/ti_spi_driverlib.h>
54+
#include <ti/devices/cc32xx/driverlib/sdhost.h>
55+
#include <ti/devices/cc32xx/driverlib/ti_timer.h>
56+
#include <ti/devices/cc32xx/driverlib/uart.h>
57+
#include <ti/devices/cc32xx/driverlib/udma.h>
58+
#include <ti/devices/cc32xx/driverlib/interrupt.h>
59+
#include <ti/devices/cc32xx/driverlib/wdt.h>
60+
61+
#include <ti/drivers/Power.h>
62+
#include <ti/drivers/power/PowerCC32XX.h>
63+
64+
#include "CC3220SF_LAUNCHXL.h"
65+
66+
/*
67+
* =============================== Power ===============================
68+
*/
69+
/*
70+
* This table defines the parking state to be set for each parkable pin
71+
* during LPDS. (Device pins must be parked during LPDS to achieve maximum
72+
* power savings.) If the pin should be left unparked, specify the state
73+
* PowerCC32XX_DONT_PARK. For example, for a UART TX pin, the device
74+
* will automatically park the pin in a high state during transition to LPDS,
75+
* so the Power Manager does not need to explictly park the pin. So the
76+
* corresponding entries in this table should indicate PowerCC32XX_DONT_PARK.
77+
*/
78+
PowerCC32XX_ParkInfo parkInfo[] = {
79+
/* PIN PARK STATE PIN ALIAS (FUNCTION)
80+
----------------- ------------------------------ -------------------- */
81+
{PowerCC32XX_PIN01, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO10 */
82+
{PowerCC32XX_PIN02, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO11 */
83+
{PowerCC32XX_PIN03, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO12 */
84+
{PowerCC32XX_PIN04, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO13 */
85+
{PowerCC32XX_PIN05, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO14 */
86+
{PowerCC32XX_PIN06, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO15 */
87+
{PowerCC32XX_PIN07, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO16 */
88+
{PowerCC32XX_PIN08, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO17 */
89+
{PowerCC32XX_PIN13, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* FLASH_SPI_DIN */
90+
{PowerCC32XX_PIN15, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO22 */
91+
{PowerCC32XX_PIN16, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TDI (JTAG DEBUG) */
92+
{PowerCC32XX_PIN17, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TDO (JTAG DEBUG) */
93+
{PowerCC32XX_PIN19, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TCK (JTAG DEBUG) */
94+
{PowerCC32XX_PIN20, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* TMS (JTAG DEBUG) */
95+
{PowerCC32XX_PIN18, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO28 */
96+
{PowerCC32XX_PIN21, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* SOP2 */
97+
{PowerCC32XX_PIN29, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* ANTSEL1 */
98+
{PowerCC32XX_PIN30, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* ANTSEL2 */
99+
{PowerCC32XX_PIN45, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* DCDC_ANA2_SW_P */
100+
{PowerCC32XX_PIN50, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO0 */
101+
{PowerCC32XX_PIN52, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* RTC_XTAL_N */
102+
{PowerCC32XX_PIN53, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO30 */
103+
{PowerCC32XX_PIN55, PowerCC32XX_WEAK_PULL_UP_STD}, /* GPIO1 (XDS_UART_RX) */
104+
{PowerCC32XX_PIN57, PowerCC32XX_WEAK_PULL_UP_STD}, /* GPIO2 (XDS_UART_TX) */
105+
{PowerCC32XX_PIN58, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO3 */
106+
{PowerCC32XX_PIN59, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO4 */
107+
{PowerCC32XX_PIN60, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO5 */
108+
{PowerCC32XX_PIN61, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO6 */
109+
{PowerCC32XX_PIN62, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO7 */
110+
{PowerCC32XX_PIN63, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO8 */
111+
{PowerCC32XX_PIN64, PowerCC32XX_WEAK_PULL_DOWN_STD}, /* GPIO9 */
112+
};
113+
114+
/*
115+
* This structure defines the configuration for the Power Manager.
116+
*
117+
* In this configuration the Power policy is disabled by default (because
118+
* enablePolicy is set to false). The Power policy can be enabled dynamically
119+
* at runtime by calling Power_enablePolicy(), or at build time, by changing
120+
* enablePolicy to true in this structure.
121+
*/
122+
const PowerCC32XX_ConfigV1 PowerCC32XX_config = {
123+
.policyInitFxn = &PowerCC32XX_initPolicy,
124+
.policyFxn = &PowerCC32XX_sleepPolicy,
125+
.enterLPDSHookFxn = NULL,
126+
.resumeLPDSHookFxn = NULL,
127+
.enablePolicy = false,
128+
.enableGPIOWakeupLPDS = true,
129+
.enableGPIOWakeupShutdown = true,
130+
.enableNetworkWakeupLPDS = true,
131+
.wakeupGPIOSourceLPDS = PRCM_LPDS_GPIO13,
132+
.wakeupGPIOTypeLPDS = PRCM_LPDS_FALL_EDGE,
133+
.wakeupGPIOFxnLPDS = NULL,
134+
.wakeupGPIOFxnLPDSArg = 0,
135+
.wakeupGPIOSourceShutdown = PRCM_HIB_GPIO13,
136+
.wakeupGPIOTypeShutdown = PRCM_HIB_RISE_EDGE,
137+
.ramRetentionMaskLPDS = PRCM_SRAM_COL_1 | PRCM_SRAM_COL_2 |
138+
PRCM_SRAM_COL_3 | PRCM_SRAM_COL_4,
139+
.keepDebugActiveDuringLPDS = false,
140+
.ioRetentionShutdown = PRCM_IO_RET_GRP_1,
141+
.pinParkDefs = parkInfo,
142+
.numPins = sizeof(parkInfo) / sizeof(PowerCC32XX_ParkInfo)
143+
};
144+
/*
145+
* =============================== SPI ===============================
146+
*/
147+
#include <ti/drivers/ti_SPI.h>
148+
#include <ti/drivers/spi/SPICC32XXDMA.h>
149+
150+
SPICC32XXDMA_Object spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPICOUNT];
151+
152+
#ifdef TOOLCHAIN_GCC_ARM
153+
__attribute__ ((aligned (32)))
154+
#elif defined TOOLCHAIN_ARM
155+
__attribute__ ((aligned (32)))
156+
#elif defined TOOLCHAIN_IAR
157+
#pragma data_alignment=32
158+
#endif
159+
uint32_t spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPICOUNT];
160+
161+
const SPICC32XXDMA_HWAttrsV1 spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPICOUNT] = {
162+
/* index 0 is reserved for LSPI that links to the NWP */
163+
{
164+
.baseAddr = LSPI_BASE,
165+
.intNum = INT_LSPI,
166+
.intPriority = (~0),
167+
.spiPRCM = PRCM_LSPI,
168+
.csControl = SPI_SW_CTRL_CS,
169+
.csPolarity = SPI_CS_ACTIVEHIGH,
170+
.pinMode = SPI_4PIN_MODE,
171+
.turboMode = SPI_TURBO_OFF,
172+
.scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI0],
173+
.defaultTxBufValue = 0,
174+
.rxChannelIndex = UDMA_CH12_LSPI_RX,
175+
.txChannelIndex = UDMA_CH13_LSPI_TX,
176+
.minDmaTransferSize = 100,
177+
.mosiPin = SPICC32XXDMA_PIN_NO_CONFIG,
178+
.misoPin = SPICC32XXDMA_PIN_NO_CONFIG,
179+
.clkPin = SPICC32XXDMA_PIN_NO_CONFIG,
180+
.csPin = SPICC32XXDMA_PIN_NO_CONFIG
181+
},
182+
{
183+
.baseAddr = GSPI_BASE,
184+
.intNum = INT_GSPI,
185+
.intPriority = (~0),
186+
.spiPRCM = PRCM_GSPI,
187+
.csControl = SPI_HW_CTRL_CS,
188+
.csPolarity = SPI_CS_ACTIVELOW,
189+
.pinMode = SPI_4PIN_MODE,
190+
.turboMode = SPI_TURBO_OFF,
191+
.scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI1],
192+
.defaultTxBufValue = 0,
193+
.rxChannelIndex = UDMA_CH6_GSPI_RX,
194+
.txChannelIndex = UDMA_CH7_GSPI_TX,
195+
.minDmaTransferSize = 10,
196+
.mosiPin = SPICC32XXDMA_PIN_07_MOSI,
197+
.misoPin = SPICC32XXDMA_PIN_06_MISO,
198+
.clkPin = SPICC32XXDMA_PIN_05_CLK,
199+
.csPin = SPICC32XXDMA_PIN_08_CS
200+
}
201+
};
202+
203+
const SPI_Config SPI_config[CC3220SF_LAUNCHXL_SPICOUNT] = {
204+
{
205+
.fxnTablePtr = &SPICC32XXDMA_fxnTable,
206+
.object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI0],
207+
.hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI0]
208+
},
209+
{
210+
.fxnTablePtr = &SPICC32XXDMA_fxnTable,
211+
.object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI1],
212+
.hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI1]
213+
}
214+
};
215+
216+
const uint_least8_t SPI_count = CC3220SF_LAUNCHXL_SPICOUNT;
217+
218+
/*
219+
* =============================== DMA ===============================
220+
*/
221+
#include <ti/drivers/dma/UDMACC32XX.h>
222+
223+
#if defined(__TI_COMPILER_VERSION__)
224+
#pragma DATA_ALIGN(dmaControlTable, 1024)
225+
#elif defined(__IAR_SYSTEMS_ICC__)
226+
#pragma data_alignment=1024
227+
#elif defined(__GNUC__)
228+
__attribute__ ((aligned (1024)))
229+
#endif
230+
static tDMAControlTable dmaControlTable[64];
231+
232+
/*
233+
* ======== dmaErrorFxn ========
234+
* This is the handler for the uDMA error interrupt.
235+
*/
236+
static void dmaErrorFxn(uintptr_t arg)
237+
{
238+
int status = MAP_uDMAErrorStatusGet();
239+
MAP_uDMAErrorStatusClear();
240+
241+
/* Suppress unused variable warning */
242+
(void)status;
243+
244+
while (1);
245+
}
246+
247+
UDMACC32XX_Object udmaCC3220SObject;
248+
249+
const UDMACC32XX_HWAttrs udmaCC3220SHWAttrs = {
250+
.controlBaseAddr = (void *)dmaControlTable,
251+
.dmaErrorFxn = (UDMACC32XX_ErrorFxn)dmaErrorFxn,
252+
.intNum = INT_UDMAERR,
253+
.intPriority = (~0)
254+
};
255+
256+
const UDMACC32XX_Config UDMACC32XX_config = {
257+
.object = &udmaCC3220SObject,
258+
.hwAttrs = &udmaCC3220SHWAttrs
259+
};
260+
/*
261+
* =============================== General ===============================
262+
*/
263+
/*
264+
* ======== CC3220SF_LAUNCHXL_initGeneral ========
265+
*/
266+
void CC3220SF_LAUNCHXL_initGeneral(void)
267+
{
268+
MAP_IntMasterEnable();
269+
//MAP_IntEnable(FAULT_SYSTICK);
270+
PRCMCC3200MCUInit();
271+
//Power_init();
272+
}
273+
274+
#if defined TOOLCHAIN_ARM
275+
__attribute__((section("signature_section")))
276+
#elif defined TOOLCHAIN_IAR
277+
#pragma default_variable_attributes = @ ".dbghdr"
278+
#elif defined TOOLCHAIN_GCC_ARM
279+
__attribute__ ((section (".dbghdr")))
280+
#endif
281+
const unsigned long ulDebugHeader[]=
282+
{
283+
0x5AA5A55A,
284+
0x000FF800,
285+
0xEFA3247D
286+
};

0 commit comments

Comments
 (0)