Commit b766e795 authored by Damien George's avatar Damien George
Browse files

stmhal: Initial implementation of cc3k module and driver.

Pulled in and modified work done by mux/iabdalkader on cc3k driver, from
iabdalkader-cc3k-update branch.  That branch was terribly messy and had
too many conflicts to merge neatly.
parent f996d885
......@@ -22,7 +22,6 @@ HAL_DIR=hal
USBDEV_DIR=usbdev
#USBHOST_DIR=usbhost
FATFS_DIR=fatfs
CC3K_DIR=cc3k
DFU=../tools/dfu.py
# may need to prefix dfu-util with sudo
DFU_UTIL ?= dfu-util
......@@ -39,7 +38,6 @@ INC += -I$(HAL_DIR)/inc
INC += -I$(USBDEV_DIR)/core/inc -I$(USBDEV_DIR)/class/cdc_msc_hid/inc
#INC += -I$(USBHOST_DIR)
INC += -I$(FATFS_DIR)/src
INC += -I$(CC3K_DIR)
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_CORTEX_M4) $(COPT)
......@@ -187,19 +185,6 @@ SRC_FATFS = $(addprefix $(FATFS_DIR)/src/,\
option/ccsbcs.c \
)
SRC_CC3K = $(addprefix $(CC3K_DIR)/,\
cc3000_common.c \
evnt_handler.c \
hci.c \
netapp.c \
nvmem.c \
security.c \
socket.c \
wlan.c \
ccspi.c \
pybcc3k.c \
)
ifeq ($(MICROPY_PY_WIZNET5K),1)
WIZNET5K_DIR=drivers/wiznet5k
INC += -I$(TOP)/$(WIZNET5K_DIR)
......@@ -213,6 +198,30 @@ SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
)
endif
# for CC3000 module
ifeq ($(MICROPY_PY_CC3K),1)
CC3000_DIR=drivers/cc3000
INC += -I$(TOP)/$(CC3000_DIR)/inc
CFLAGS_MOD += -DMICROPY_PY_CC3K=1
SRC_MOD += modcc3k.c
SRC_MOD += $(addprefix $(CC3000_DIR)/src/,\
cc3000_common.c \
evnt_handler.c \
hci.c \
netapp.c \
nvmem.c \
security.c \
socket.c \
wlan.c \
ccspi.c \
inet_ntop.c \
inet_pton.c \
)
# patch.c \
# patch_prog.c \
)
endif
OBJ =
OBJ += $(PY_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIB:.c=.o))
......@@ -221,7 +230,6 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_HAL:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_USBDEV:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_FATFS:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_CC3K:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
OBJ += $(BUILD)/pins_$(BOARD).o
......
......@@ -16,7 +16,6 @@
#define MICROPY_HW_ENABLE_I2C1 (1)
#define MICROPY_HW_ENABLE_SPI1 (1)
#define MICROPY_HW_ENABLE_SPI3 (1)
#define MICROPY_HW_ENABLE_CC3K (0)
// USRSW/UBTN (Needs Jumper UBTN) is pulled low. Pressing the button makes the input go high.
#define MICROPY_HW_USRSW_PIN (pin_A0)
......
......@@ -20,7 +20,6 @@
#define MICROPY_HW_ENABLE_I2C1 (0)
#define MICROPY_HW_ENABLE_SPI1 (0)
#define MICROPY_HW_ENABLE_SPI3 (0)
#define MICROPY_HW_ENABLE_CC3K (0)
// USRSW is pulled low. Pressing the button makes the input go high.
#define MICROPY_HW_USRSW_PIN (pin_B11)
......
......@@ -17,7 +17,6 @@
#define MICROPY_HW_ENABLE_I2C1 (1)
#define MICROPY_HW_ENABLE_SPI1 (1)
#define MICROPY_HW_ENABLE_SPI3 (0)
#define MICROPY_HW_ENABLE_CC3K (0)
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
#define MICROPY_HW_USRSW_PIN (pin_B3)
......
......@@ -16,7 +16,6 @@
#define MICROPY_HW_ENABLE_I2C1 (1)
#define MICROPY_HW_ENABLE_SPI1 (1)
#define MICROPY_HW_ENABLE_SPI3 (0)
#define MICROPY_HW_ENABLE_CC3K (0)
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
#define MICROPY_HW_USRSW_PIN (pin_A13)
......
......@@ -16,7 +16,6 @@
#define MICROPY_HW_ENABLE_I2C1 (1)
#define MICROPY_HW_ENABLE_SPI1 (1)
#define MICROPY_HW_ENABLE_SPI3 (0)
#define MICROPY_HW_ENABLE_CC3K (0)
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
#define MICROPY_HW_USRSW_PIN (pin_B3)
......
......@@ -16,7 +16,6 @@
#define MICROPY_HW_ENABLE_I2C1 (1)
#define MICROPY_HW_ENABLE_SPI1 (1)
#define MICROPY_HW_ENABLE_SPI3 (0)
#define MICROPY_HW_ENABLE_CC3K (0)
// USRSW is pulled low. Pressing the button makes the input go high.
#define MICROPY_HW_USRSW_PIN (pin_A0)
......
This diff is collapsed.
......@@ -85,6 +85,13 @@ extern const struct _mp_obj_module_t mp_module_wiznet5k;
#define MICROPY_PY_WIZNET5K_DEF
#endif
#if MICROPY_PY_CC3K
extern const struct _mp_obj_module_t mp_module_cc3k;
#define MICROPY_PY_CC3K_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_cc3k), (mp_obj_t)&mp_module_cc3k },
#else
#define MICROPY_PY_CC3K_DEF
#endif
#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
......@@ -92,6 +99,7 @@ extern const struct _mp_obj_module_t mp_module_wiznet5k;
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_select }, \
MICROPY_PY_WIZNET5K_DEF \
MICROPY_PY_CC3K_DEF \
// extra constants
#define MICROPY_PORT_CONSTANTS \
......
......@@ -2,3 +2,6 @@
# wiznet5k module for ethernet support
MICROPY_PY_WIZNET5K ?= 0
# cc3k module for wifi support
MICROPY_PY_CC3K ?= 0
......@@ -319,7 +319,7 @@ Q(text)
Q(show)
// for WIZnet5k class
#if MICROPY_HW_ENABLE_WIZNET5K
#if MICROPY_PY_WIZNET5K
Q(wiznet5k)
Q(WIZnet5k)
Q(regs)
......@@ -344,6 +344,47 @@ Q(SOCK_STREAM)
Q(SOCK_DGRAM)
#endif
// for CC3k class
#if MICROPY_PY_CC3K
Q(cc3k)
Q(CC3k)
Q(connect)
Q(disconnect)
Q(is_connected)
Q(ifconfig)
Q(patch_version)
Q(patch_program)
Q(socket)
Q(family)
Q(type)
Q(gethostbyname)
Q(WEP)
Q(WPA)
Q(WPA2)
Q(AF_INET)
Q(AF_INET6)
Q(SOCK_STREAM)
Q(SOCK_DGRAM)
Q(SOCK_RAW)
Q(IPPROTO_IP)
Q(IPPROTO_ICMP)
Q(IPPROTO_IPV4)
Q(IPPROTO_TCP)
Q(IPPROTO_UDP)
Q(IPPROTO_IPV6)
Q(IPPROTO_RAW)
Q(send)
Q(recv)
Q(bind)
Q(listen)
Q(accept)
Q(connect)
Q(settimeout)
Q(setblocking)
Q(close)
Q(__del__)
#endif
// for stm module
Q(stm)
Q(mem)
......
......@@ -190,6 +190,14 @@ STATIC const pyb_spi_obj_t pyb_spi_obj[] = {
};
#define PYB_NUM_SPI MP_ARRAY_SIZE(pyb_spi_obj)
SPI_HandleTypeDef *spi_get_handle(mp_obj_t o) {
if (!MP_OBJ_IS_TYPE(o, &pyb_spi_type)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "expecting an SPI object"));
}
pyb_spi_obj_t *self = o;
return self->spi;
}
STATIC void pyb_spi_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_spi_obj_t *self = self_in;
......
......@@ -31,3 +31,4 @@ extern const mp_obj_type_t pyb_spi_type;
void spi_init0(void);
void spi_init(SPI_HandleTypeDef *spi);
SPI_HandleTypeDef *spi_get_handle(mp_obj_t o);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment