Skip to content

Commit c020109

Browse files
committed
cc3200: Add SD module and disable SD card support for the LAUNCHXL.
1 parent 571e3f5 commit c020109

15 files changed

Lines changed: 285 additions & 134 deletions

File tree

cc3200/application.lds

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,3 @@
1-
/*****************************************************************************
2-
* cc3200.lds
3-
*
4-
* GCC Linker script for the CC3200
5-
*
6-
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
7-
*
8-
*
9-
* Redistribution and use in source and binary forms, with or without
10-
* modification, are permitted provided that the following conditions
11-
* are met:
12-
*
13-
* Redistributions of source code must retain the above copyright
14-
* notice, this list of conditions and the following disclaimer.
15-
*
16-
* Redistributions in binary form must reproduce the above copyright
17-
* notice, this list of conditions and the following disclaimer in the
18-
* documentation and/or other materials provided with the
19-
* distribution.
20-
*
21-
* Neither the name of Texas Instruments Incorporated nor the names of
22-
* its contributors may be used to endorse or promote products derived
23-
* from this software without specific prior written permission.
24-
*
25-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36-
*
37-
******************************************************************************/
38-
391
/*
402
* This file is part of the Micro Python project, http://micropython.org/
413
*
@@ -62,8 +24,8 @@
6224
* THE SOFTWARE.
6325
*/
6426

65-
__stack_size__ = 1K; /* interrupts are handled using this stack */
66-
__min_heap_size__ = 6K;
27+
__stack_size__ = 1K; /* interrupts are handled within this stack */
28+
__min_heap_size__ = 8K;
6729
__rtos_heap_size = 16K;
6830

6931
MEMORY

cc3200/application.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ APP_MODS_SRC_C = $(addprefix mods/,\
9494
pybi2c.c \
9595
pybpin.c \
9696
pybrtc.c \
97+
pybsd.c \
9798
pybsystick.c \
9899
pybuart.c \
99100
)

cc3200/boards/LAUNCHXL/mpconfigboard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
#define MICROPY_HW_BOARD_NAME "LaunchPad"
3131
#define MICROPY_HW_MCU_NAME "CC3200"
3232

33-
#define MICROPY_HW_HAS_SDCARD (1)
33+
#define MICROPY_HW_HAS_SDCARD (0)
3434
#define MICROPY_HW_ENABLE_RNG (1)
3535
#define MICROPY_HW_ENABLE_RTC (1)
3636

3737
#define MICROPY_STDIO_UART PYB_UART_0
3838
#define MICROPY_STDIO_UART_BAUD 115200
39+

cc3200/bootmgr/bootmgr.lds

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
1-
/*****************************************************************************
2-
* bootmgr.lds
3-
*
4-
* GCC Linker script for get_time application.
5-
*
6-
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
7-
*
8-
*
9-
* Redistribution and use in source and binary forms, with or without
10-
* modification, are permitted provided that the following conditions
11-
* are met:
12-
*
13-
* Redistributions of source code must retain the above copyright
14-
* notice, this list of conditions and the following disclaimer.
15-
*
16-
* Redistributions in binary form must reproduce the above copyright
17-
* notice, this list of conditions and the following disclaimer in the
18-
* documentation and/or other materials provided with the
19-
* distribution.
20-
*
21-
* Neither the name of Texas Instruments Incorporated nor the names of
22-
* its contributors may be used to endorse or promote products derived
23-
* from this software without specific prior written permission.
24-
*
25-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36-
*
37-
******************************************************************************/
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+
*/
3826

3927
__stack_size__ = 1024;
4028

cc3200/fatfs/src/ffconf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ int ff_get_ldnumber (const TCHAR **path) {
6161
}
6262

6363
if (**path != '/') {
64-
#if _FS_RPATH
64+
#if _FS_RPATH
6565
return ff_CurrVol;
66-
#else
66+
#else
6767
return -1;
68-
#endif
68+
#endif
6969
}
7070

7171
if (check_path(path, "/SFLASH", 7)) {

cc3200/fatfs/src/ffconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232

233233

234234
#define _FS_REENTRANT 1
235-
#define _FS_TIMEOUT 2000
235+
#define _FS_TIMEOUT 2500 // milliseconds
236236
#define _SYNC_t SemaphoreHandle_t
237237
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
238238
/ module itself. Note that regardless of this option, file access to different

cc3200/hal/cc3200_hal.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include "interrupt.h"
4242
#include "systick.h"
4343
#include "prcm.h"
44-
#include "sdhost.h"
4544
#include "pin.h"
4645
#include "mpexception.h"
4746
#include "telnet.h"
@@ -54,20 +53,12 @@
5453
#endif
5554

5655

57-
/******************************************************************************
58-
DECLARE CONSTANTS
59-
******************************************************************************/
60-
#define HAL_SDCARD_FREQUENCY_HZ 15000000 // 15MHz
61-
6256
/******************************************************************************
6357
DECLARE PRIVATE FUNCTIONS
6458
******************************************************************************/
6559
#ifndef USE_FREERTOS
6660
static void hal_TickInit (void);
6761
#endif
68-
#if MICROPY_HW_HAS_SDCARD
69-
static void hal_EnableSdCard (void);
70-
#endif
7162

7263
/******************************************************************************
7364
DECLARE LOCAL DATA
@@ -101,9 +92,6 @@ void HAL_SystemInit (void) {
10192
#ifndef USE_FREERTOS
10293
hal_TickInit();
10394
#endif
104-
#if MICROPY_HW_HAS_SDCARD
105-
hal_EnableSdCard();
106-
#endif
10795
}
10896

10997
void HAL_SystemDeInit (void) {
@@ -189,23 +177,3 @@ static void hal_TickInit (void) {
189177
}
190178
#endif
191179

192-
#if MICROPY_HW_HAS_SDCARD
193-
static void hal_EnableSdCard (void) {
194-
// Configure PIN_06 for SDHOST0 SDHost_D0
195-
MAP_PinTypeSDHost(PIN_06, PIN_MODE_8);
196-
// Configure PIN_07 for SDHOST0 SDHost_CLK
197-
MAP_PinTypeSDHost(PIN_07, PIN_MODE_8);
198-
// Configure PIN_08 for SDHOST0 SDHost_CMD
199-
MAP_PinTypeSDHost(PIN_08, PIN_MODE_8);
200-
// Set the SD card clock as an output pin
201-
MAP_PinDirModeSet(PIN_07, PIN_DIR_MODE_OUT);
202-
// Enable SD peripheral clock
203-
MAP_PRCMPeripheralClkEnable(PRCM_SDHOST, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
204-
// Reset MMCHS
205-
MAP_PRCMPeripheralReset(PRCM_SDHOST);
206-
// Configure MMCHS
207-
MAP_SDHostInit(SDHOST_BASE);
208-
// Configure the card clock
209-
MAP_SDHostSetExpClk(SDHOST_BASE, MAP_PRCMPeripheralClockGet(PRCM_SDHOST), HAL_SDCARD_FREQUENCY_HZ);
210-
}
211-
#endif

cc3200/mods/modpyb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "pybextint.h"
6565
#include "pybadc.h"
6666
#include "pybi2c.h"
67+
#include "pybsd.h"
6768
#include "utils.h"
6869

6970

@@ -317,6 +318,10 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
317318
{ MP_OBJ_NEW_QSTR(MP_QSTR_ADC), (mp_obj_t)&pyb_adc_type },
318319
{ MP_OBJ_NEW_QSTR(MP_QSTR_I2C), (mp_obj_t)&pyb_i2c_type },
319320
{ MP_OBJ_NEW_QSTR(MP_QSTR_UART), (mp_obj_t)&pyb_uart_type },
321+
322+
#if MICROPY_HW_HAS_SDCARD
323+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD), (mp_obj_t)&pyb_sdcard_obj },
324+
#endif
320325
};
321326

322327
STATIC MP_DEFINE_CONST_DICT(pyb_module_globals, pyb_module_globals_table);

cc3200/mods/pybextint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void extint_init0(void) {
271271
}
272272

273273
extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull, mp_obj_t callback) {
274-
const pin_obj_t *pin = NULL;
274+
const pin_obj_t *pin;
275275
extint_obj_t* self;
276276
void *handler;
277277
uint32_t intnum;

cc3200/mods/pybpin.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
113113
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
114114
}
115115

116+
void pin_verify_af (uint af) {
117+
if (af > PIN_MODE_15) {
118+
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
119+
}
120+
}
121+
116122
void pin_config(const pin_obj_t *self, uint af, uint mode, uint type, uint strength) {
117123
// Skip all this if the pin is to be used in analog mode
118124
if (type != PIN_TYPE_ANALOG) {
@@ -138,6 +144,8 @@ void pin_config(const pin_obj_t *self, uint af, uint mode, uint type, uint stren
138144
// configure the direction
139145
MAP_GPIODirModeSet(self->port, self->bit, mode);
140146
}
147+
// verify the alternate function
148+
pin_verify_af (af);
141149
// now set the alternate function, strenght and type
142150
MAP_PinModeSet (self->pin_num, af);
143151
}

0 commit comments

Comments
 (0)