Skip to content

Commit 33ddb56

Browse files
committed
cc3200: Remove dependencies from FreeRTOS.
Use the simplelink wrappers instead. This is one step further towards having a single module for the cc3200 and the cc3100.
1 parent 5c047b9 commit 33ddb56

File tree

18 files changed

+91
-117
lines changed

18 files changed

+91
-117
lines changed

cc3200/fatfs/src/drivers/sflash_diskio.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
#include "debug.h"
1111
#include "modwlan.h"
1212

13-
#ifdef USE_FREERTOS
14-
#include "FreeRTOS.h"
15-
#include "task.h"
16-
#include "semphr.h"
17-
#endif
18-
1913
#define SFLASH_TIMEOUT_MAX_MS 5500
2014
#define SFLASH_WAIT_TIME_MS 5
2115

@@ -38,18 +32,15 @@ static bool sflash_access (_u32 mode, _i32 (* sl_FsFunction)(_i32 FileHdl, _u32
3832
bool retval = false;
3933

4034
// wlan must be enabled in order to access the serial flash
41-
#ifdef USE_FREERTOS
42-
xSemaphoreTake (xWlanSemaphore, portMAX_DELAY);
43-
#endif
35+
sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER);
36+
4437
if (0 == sl_FsOpen(sflash_block_name, mode, NULL, &fileHandle)) {
4538
if (SFLASH_BLOCK_SIZE == sl_FsFunction (fileHandle, 0, sflash_block_cache, SFLASH_BLOCK_SIZE)) {
4639
retval = true;
4740
}
4841
sl_FsClose (fileHandle, NULL, NULL, 0);
4942
}
50-
#ifdef USE_FREERTOS
51-
xSemaphoreGive (xWlanSemaphore);
52-
#endif
43+
sl_LockObjUnlock (&wlan_LockObj);
5344
return retval;
5445
}
5546

@@ -64,32 +55,24 @@ DRESULT sflash_disk_init (void) {
6455
// Proceed to format the memory if not done yet
6556
for (int i = 0; i < SFLASH_BLOCK_COUNT; i++) {
6657
print_block_name (i);
67-
#ifdef USE_FREERTOS
68-
xSemaphoreTake (xWlanSemaphore, portMAX_DELAY);
69-
#endif
58+
sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER);
7059
// Create the block file if it doesn't exist
7160
if (sl_FsGetInfo(sflash_block_name, 0, &FsFileInfo) < 0) {
7261
if (!sl_FsOpen(sflash_block_name, FS_MODE_OPEN_CREATE(SFLASH_BLOCK_SIZE, 0), NULL, &fileHandle)) {
7362
sl_FsClose(fileHandle, NULL, NULL, 0);
74-
#ifdef USE_FREERTOS
75-
xSemaphoreGive (xWlanSemaphore);
76-
#endif
63+
sl_LockObjUnlock (&wlan_LockObj);
7764
memset(sflash_block_cache, 0xFF, SFLASH_BLOCK_SIZE);
7865
if (!sflash_access(FS_MODE_OPEN_WRITE, sl_FsWrite)) {
7966
return RES_ERROR;
8067
}
8168
}
8269
else {
8370
// Unexpected failure while creating the file
84-
#ifdef USE_FREERTOS
85-
xSemaphoreGive (xWlanSemaphore);
86-
#endif
71+
sl_LockObjUnlock (&wlan_LockObj);
8772
return RES_ERROR;
8873
}
8974
}
90-
#ifdef USE_FREERTOS
91-
xSemaphoreGive (xWlanSemaphore);
92-
#endif
75+
sl_LockObjUnlock (&wlan_LockObj);
9376
}
9477
sflash_init_done = true;
9578
sflash_prblock = UINT32_MAX;

cc3200/ftp/ftp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "py/mpconfig.h"
3232
#include MICROPY_HAL_H
3333
#include "py/obj.h"
34-
#include "osi.h"
3534
#include "inc/hw_types.h"
3635
#include "inc/hw_ints.h"
3736
#include "inc/hw_memmap.h"

cc3200/ftp/updater.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ bool updater_check_path (void *path) {
6060
bool updater_start (void) {
6161
_u32 AccessModeAndMaxSize = FS_MODE_OPEN_WRITE;
6262
SlFsFileInfo_t FsFileInfo;
63-
#ifdef USE_FREERTOS
64-
xSemaphoreTake (xWlanSemaphore, portMAX_DELAY);
65-
#endif
63+
sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER);
6664
if (0 != sl_FsGetInfo((_u8 *)updater_data.path, 0, &FsFileInfo)) {
6765
// file doesn't exist, create it
6866
AccessModeAndMaxSize = FS_MODE_OPEN_CREATE(updater_data.fsize, 0);
@@ -71,9 +69,7 @@ bool updater_start (void) {
7169
updater_data.foffset = 0;
7270
return true;
7371
}
74-
#ifdef USE_FREERTOS
75-
xSemaphoreGive (xWlanSemaphore);
76-
#endif
72+
sl_LockObjUnlock (&wlan_LockObj);
7773
return false;
7874
}
7975

@@ -115,7 +111,5 @@ void updater_finnish (void) {
115111
}
116112
}
117113
updater_data.fhandle = -1;
118-
#ifdef USE_FREERTOS
119-
xSemaphoreGive (xWlanSemaphore);
120-
#endif
114+
sl_LockObjUnlock (&wlan_LockObj);
121115
}

cc3200/hal/cc3200_hal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#define HAL_SYSTICK_PERIOD_US 1000U
4040
#define UTILS_DELAY_US_TO_COUNT(us) (((us) * HAL_FCPU_MHZ) / 3)
4141

42+
#define HAL_NVIC_INT_CTRL_REG (*((volatile uint32_t *) 0xE000ED04 ) )
43+
#define HAL_VECTACTIVE_MASK (0x1FUL)
44+
4245
/******************************************************************************
4346
DEFINE TYPES
4447
******************************************************************************/

cc3200/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include MICROPY_HAL_H
3333
#include "mptask.h"
3434
#include "simplelink.h"
35-
#include "osi.h"
3635
#include "debug.h"
3736

3837
/******************************************************************************

cc3200/misc/FreeRTOSHooks.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#include "osi.h"
3737

3838

39-
#ifdef USE_FREERTOS
40-
4139
//*****************************************************************************
4240
//
4341
//! \brief Application defined idle task hook
@@ -115,5 +113,3 @@ void vApplicationTickHook( void )
115113
{
116114
HAL_IncrementTick();
117115
}
118-
119-
#endif //USE_FREERTOS

cc3200/mods/modpyb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@
5959
#include "pybi2c.h"
6060
#include "pybsd.h"
6161
#include "utils.h"
62+
#include "gccollect.h"
6263

6364

6465
#ifdef DEBUG
6566
extern OsiTaskHandle mpTaskHandle;
6667
extern OsiTaskHandle svTaskHandle;
67-
extern TaskHandle_t xSimpleLinkSpawnTaskHndl;
68+
extern OsiTaskHandle xSimpleLinkSpawnTaskHndl;
6869
#endif
6970

7071
/// \module pyb - functions related to the pyboard

cc3200/mods/modwlan.c

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,10 @@
3737
#include "modwlan.h"
3838
#include "pybioctl.h"
3939
#include "pybuart.h"
40-
#include "osi.h"
4140
#include "debug.h"
4241
#include "serverstask.h"
4342
#include "mpexception.h"
4443

45-
#ifdef USE_FREERTOS
46-
#include "FreeRTOS.h"
47-
#include "task.h"
48-
#include "semphr.h"
49-
#endif
50-
5144

5245
/******************************************************************************
5346
DEFINE TYPES
@@ -88,7 +81,6 @@ typedef struct _wlan_obj_t {
8881
uint8_t macAddr[SL_MAC_ADDR_LEN];
8982
uint8_t ssid_name[33];
9083
uint8_t bssid[6];
91-
bool servers_enabled;
9284

9385
// IPVv4 data
9486
uint32_t ip;
@@ -152,7 +144,7 @@ STATIC wlan_obj_t wlan_obj;
152144
/******************************************************************************
153145
DECLARE EXPORTED DATA
154146
******************************************************************************/
155-
SemaphoreHandle_t xWlanSemaphore = NULL;
147+
OsiLockObj_t wlan_LockObj;
156148

157149
/******************************************************************************
158150
DECLARE PRIVATE FUNCTIONS
@@ -355,11 +347,7 @@ void wlan_init0 (void) {
355347
wlan_obj.mode = -1;
356348
wlan_obj.base.type = NULL;
357349
memset (wlan_obj.macAddr, 0, SL_MAC_ADDR_LEN);
358-
#ifdef USE_FREERTOS
359-
if (NULL == xWlanSemaphore) {
360-
xWlanSemaphore = xSemaphoreCreateBinary();
361-
}
362-
#endif
350+
ASSERT(OSI_OK == sl_LockObjCreate(&wlan_LockObj, "WlanLock"));
363351
wlan_initialize_data ();
364352
}
365353

@@ -369,9 +357,7 @@ modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ss
369357
if (mode == ROLE_STA || mode == ROLE_AP || mode == ROLE_P2P) {
370358
if (wlan_obj.mode < 0) {
371359
wlan_obj.mode = sl_Start(0, 0, 0);
372-
#ifdef USE_FREERTOS
373-
xSemaphoreGive (xWlanSemaphore);
374-
#endif
360+
sl_LockObjUnlock (&wlan_LockObj);
375361
}
376362

377363
// get the mac address
@@ -492,9 +478,7 @@ modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ss
492478

493479
void wlan_sl_disable (void) {
494480
if (wlan_obj.mode >= 0) {
495-
#ifdef USE_FREERTOS
496-
xSemaphoreTake (xWlanSemaphore, portMAX_DELAY);
497-
#endif
481+
sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER);
498482
wlan_obj.mode = -1;
499483
sl_Stop(SL_STOP_TIMEOUT);
500484
}
@@ -543,14 +527,10 @@ STATIC void wlan_initialize_data (void) {
543527
STATIC void wlan_reenable (SlWlanMode_t mode) {
544528
// Stop and start again
545529
wlan_obj.mode = -1;
546-
#ifdef USE_FREERTOS
547-
xSemaphoreTake (xWlanSemaphore, portMAX_DELAY);
548-
#endif
530+
sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER);
549531
sl_Stop(SL_STOP_TIMEOUT);
550532
wlan_obj.mode = sl_Start(0, 0, 0);
551-
#ifdef USE_FREERTOS
552-
xSemaphoreGive (xWlanSemaphore);
553-
#endif
533+
sl_LockObjUnlock (&wlan_LockObj);
554534
ASSERT (wlan_obj.mode == mode);
555535
}
556536

@@ -647,7 +627,8 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
647627
SlWlanMode_t mode = mp_obj_get_int(args[0]);
648628

649629
// Stop all other processes using the wlan engine
650-
if ( (wlan_obj.servers_enabled = servers_are_enabled()) ) {
630+
bool servers_enabled;
631+
if ( (servers_enabled = servers_are_enabled()) ) {
651632
wlan_servers_stop();
652633
}
653634
if (mode == ROLE_AP) {
@@ -667,7 +648,7 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
667648
}
668649

669650
// Start the servers again
670-
if (wlan_obj.servers_enabled) {
651+
if (servers_enabled) {
671652
servers_enable ();
672653
}
673654
} else if (wlan_obj.mode < 0) {

cc3200/mods/modwlan.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ typedef enum
4848
/******************************************************************************
4949
DECLARE PUBLIC DATA
5050
******************************************************************************/
51-
#ifdef USE_FREERTOS
52-
#include "FreeRTOS.h"
53-
#include "task.h"
54-
#include "semphr.h"
55-
extern SemaphoreHandle_t xWlanSemaphore;
56-
#endif
51+
extern _SlLockObj_t wlan_LockObj;
5752

5853
/******************************************************************************
5954
DECLARE PUBLIC FUNCTIONS

cc3200/mods/pybsd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "pybpin.h"
4141
#include "pybsd.h"
4242
#include "ff.h"
43-
#include "osi.h"
43+
#include "simplelink.h"
4444
#include "debug.h"
4545
#include "mpexception.h"
4646

0 commit comments

Comments
 (0)