aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--py/modcmath.c2
-rw-r--r--stmhal/.gitignore5
-rw-r--r--stmhal/Makefile34
-rw-r--r--stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h2
-rw-r--r--stmhal/boards/PYBV10/mpconfigboard.h2
-rw-r--r--stmhal/boards/PYBV3/mpconfigboard.h2
-rw-r--r--stmhal/boards/PYBV4/mpconfigboard.h2
-rw-r--r--stmhal/boards/STM32F4DISC/mpconfigboard.h2
-rw-r--r--stmhal/cc3k/cc3000_common.c5
-rw-r--r--stmhal/cc3k/ccspi.c5
-rw-r--r--stmhal/cc3k/evnt_handler.c5
-rw-r--r--stmhal/cc3k/hci.c5
-rw-r--r--stmhal/cc3k/netapp.c5
-rw-r--r--stmhal/cc3k/nvmem.c4
-rw-r--r--stmhal/cc3k/pybcc3k.c4
-rw-r--r--stmhal/cc3k/security.c5
-rw-r--r--stmhal/cc3k/socket.c5
-rw-r--r--stmhal/cc3k/wlan.c5
-rw-r--r--stmhal/main.c6
-rw-r--r--stmhal/mpconfigport.h1
-rw-r--r--stmhal/pybwlan.c4
-rwxr-xr-xtools/build-stm-latest.sh4
-rw-r--r--tools/pyboard.py22
23 files changed, 106 insertions, 30 deletions
diff --git a/py/modcmath.c b/py/modcmath.c
index 80dc0c886..cfafdf84e 100644
--- a/py/modcmath.c
+++ b/py/modcmath.c
@@ -65,7 +65,7 @@ mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
mp_obj_get_complex(z_obj, &real, &imag);
mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real*real + imag*imag, 0.25);
mp_float_t theta = 0.5 * MICROPY_FLOAT_C_FUN(atan2)(imag, real);
- return mp_obj_new_complex(sqrt_abs * cos(theta), sqrt_abs * sin(theta));
+ return mp_obj_new_complex(sqrt_abs * MICROPY_FLOAT_C_FUN(cos)(theta), sqrt_abs * MICROPY_FLOAT_C_FUN(sin)(theta));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_sqrt_obj, mp_cmath_sqrt);
diff --git a/stmhal/.gitignore b/stmhal/.gitignore
new file mode 100644
index 000000000..61ad25738
--- /dev/null
+++ b/stmhal/.gitignore
@@ -0,0 +1,5 @@
+build-PYBV3/
+build-PYBV4/
+build-PYBV10/
+build-STM32F4DISC/
+build-NETDUINO_PLUS_2/
diff --git a/stmhal/Makefile b/stmhal/Makefile
index 09c03d71e..4cd33b958 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -1,3 +1,13 @@
+# Select the board to build for: if not given on the command line,
+# then default to PYBV10.
+BOARD ?= PYBV10
+ifeq ($(wildcard boards/$(BOARD)/.),)
+$(error Invalid BOARD specified)
+endif
+
+# If the build directory is not given, make it reflect the board name.
+BUILD ?= build-$(BOARD)
+
include ../py/mkenv.mk
# qstr definitions (must come before including py.mk)
@@ -32,10 +42,6 @@ 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 $(CFLAGS_CORTEX_M4) $(COPT)
-BOARD ?= PYBV10
-ifeq ($(wildcard boards/$(BOARD)/.),)
-$(error Invalid BOARD specified)
-endif
CFLAGS += -Iboards/$(BOARD)
#Debugging/Optimization
@@ -189,25 +195,21 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_FATFS:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_CC3K:.c=.o))
OBJ += $(BUILD)/pins_$(BOARD).o
-all: $(BUILD)/flash.dfu
+all: $(BUILD)/firmware.dfu
-.PHONY: flashboard
+.PHONY: deploy
-flashboard: $(BUILD)/flash.dfu
+deploy: $(BUILD)/firmware.dfu
$(ECHO) "Writing $< to the board"
$(Q)$(DFU_UTIL) -a 0 -D $<
-$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
+$(BUILD)/firmware.dfu: $(BUILD)/firmware.elf
$(ECHO) "Create $@"
- $(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
-
-$(BUILD)/flash0.bin: $(BUILD)/flash.elf
- $(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $@
-
-$(BUILD)/flash1.bin: $(BUILD)/flash.elf
- $(Q)$(OBJCOPY) -O binary -j .text -j .data $^ $@
+ $(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $(BUILD)/firmware0.bin
+ $(Q)$(OBJCOPY) -O binary -j .text -j .data $^ $(BUILD)/firmware1.bin
+ $(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/firmware0.bin -b 0x08020000:$(BUILD)/firmware1.bin $@
-$(BUILD)/flash.elf: $(OBJ)
+$(BUILD)/firmware.elf: $(OBJ)
$(ECHO) "LINK $@"
$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
$(Q)$(SIZE) $@
diff --git a/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h b/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
index b70b56d9c..0e4054525 100644
--- a/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
+++ b/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
@@ -11,7 +11,6 @@
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)
#define MICROPY_HW_HAS_LCD (0)
-#define MICROPY_HW_HAS_WLAN (0)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (0)
#define MICROPY_HW_ENABLE_TIMER (1)
@@ -20,6 +19,7 @@
#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)
diff --git a/stmhal/boards/PYBV10/mpconfigboard.h b/stmhal/boards/PYBV10/mpconfigboard.h
index fc22f6334..3def53123 100644
--- a/stmhal/boards/PYBV10/mpconfigboard.h
+++ b/stmhal/boards/PYBV10/mpconfigboard.h
@@ -7,7 +7,6 @@
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)
#define MICROPY_HW_HAS_LCD (1)
-#define MICROPY_HW_HAS_WLAN (1)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_TIMER (1)
@@ -16,6 +15,7 @@
#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)
diff --git a/stmhal/boards/PYBV3/mpconfigboard.h b/stmhal/boards/PYBV3/mpconfigboard.h
index af4da0c1d..ac0d84ca2 100644
--- a/stmhal/boards/PYBV3/mpconfigboard.h
+++ b/stmhal/boards/PYBV3/mpconfigboard.h
@@ -7,7 +7,6 @@
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)
#define MICROPY_HW_HAS_LCD (0)
-#define MICROPY_HW_HAS_WLAN (0)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_TIMER (1)
@@ -16,6 +15,7 @@
#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)
diff --git a/stmhal/boards/PYBV4/mpconfigboard.h b/stmhal/boards/PYBV4/mpconfigboard.h
index 550f1633f..9fedb7013 100644
--- a/stmhal/boards/PYBV4/mpconfigboard.h
+++ b/stmhal/boards/PYBV4/mpconfigboard.h
@@ -7,7 +7,6 @@
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)
#define MICROPY_HW_HAS_LCD (1)
-#define MICROPY_HW_HAS_WLAN (0)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_TIMER (1)
@@ -16,6 +15,7 @@
#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)
diff --git a/stmhal/boards/STM32F4DISC/mpconfigboard.h b/stmhal/boards/STM32F4DISC/mpconfigboard.h
index c83bb162b..e6780eacb 100644
--- a/stmhal/boards/STM32F4DISC/mpconfigboard.h
+++ b/stmhal/boards/STM32F4DISC/mpconfigboard.h
@@ -7,7 +7,6 @@
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (1)
#define MICROPY_HW_HAS_LCD (0)
-#define MICROPY_HW_HAS_WLAN (0)
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_TIMER (1)
@@ -16,6 +15,7 @@
#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)
diff --git a/stmhal/cc3k/cc3000_common.c b/stmhal/cc3k/cc3000_common.c
index 48eda2676..8d9bd7d03 100644
--- a/stmhal/cc3k/cc3000_common.c
+++ b/stmhal/cc3k/cc3000_common.c
@@ -52,6 +52,9 @@
*
*****************************************************************************/
#include <stdint.h>
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "cc3000_common.h"
#include "socket.h"
@@ -194,3 +197,5 @@ uint32_t STREAM_TO_UINT32_f(char * cp, uint16_t offset)
//! @}
//
//*****************************************************************************
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/ccspi.c b/stmhal/cc3k/ccspi.c
index 4785897e1..133b17d03 100644
--- a/stmhal/cc3k/ccspi.c
+++ b/stmhal/cc3k/ccspi.c
@@ -42,6 +42,9 @@
*****************************************************************************/
#include <stdint.h>
#include <string.h> // for memset
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "ccspi.h"
#include "hci.h"
@@ -735,3 +738,5 @@ void cc3k_int_poll()
SpiIntGPIOHandler();
}
}
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/evnt_handler.c b/stmhal/cc3k/evnt_handler.c
index 5a75fadcc..cca2e796d 100644
--- a/stmhal/cc3k/evnt_handler.c
+++ b/stmhal/cc3k/evnt_handler.c
@@ -52,6 +52,9 @@
//******************************************************************************
#include <stdint.h>
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "cc3000_common.h"
#include "string.h"
@@ -871,3 +874,5 @@ SimpleLinkWaitData(unsigned char *pBuf, unsigned char *from,
//! @}
//
//*****************************************************************************
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/hci.c b/stmhal/cc3k/hci.c
index ef77db95f..533311f17 100644
--- a/stmhal/cc3k/hci.c
+++ b/stmhal/cc3k/hci.c
@@ -50,6 +50,9 @@
#include <stdint.h>
#include <string.h> // for memcpy
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "cc3000_common.h"
#include "hci.h"
@@ -240,3 +243,5 @@ hci_patch_send(unsigned char ucOpcode, unsigned char *pucBuff, char *patch, unsi
//
//
//*****************************************************************************
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/netapp.c b/stmhal/cc3k/netapp.c
index 4b3efb24d..cdeccefc4 100644
--- a/stmhal/cc3k/netapp.c
+++ b/stmhal/cc3k/netapp.c
@@ -41,6 +41,9 @@
*
*****************************************************************************/
#include <stdint.h>
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "netapp.h"
#include "hci.h"
@@ -475,3 +478,5 @@ long netapp_set_debug_level(unsigned long ulLevel)
}
#endif
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/nvmem.c b/stmhal/cc3k/nvmem.c
index 411362008..774759c41 100644
--- a/stmhal/cc3k/nvmem.c
+++ b/stmhal/cc3k/nvmem.c
@@ -50,6 +50,9 @@
#include <stdint.h>
#include <string.h>
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "nvmem.h"
#include "hci.h"
@@ -364,3 +367,4 @@ nvmem_create_entry(unsigned long ulFileId, unsigned long ulNewLen)
//
//*****************************************************************************
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/pybcc3k.c b/stmhal/cc3k/pybcc3k.c
index 8712a3780..d43f42f0b 100644
--- a/stmhal/cc3k/pybcc3k.c
+++ b/stmhal/cc3k/pybcc3k.c
@@ -17,6 +17,8 @@
#include "ccdebug.h"
#include "pybcc3k.h"
+#if MICROPY_HW_ENABLE_CC3K
+
// IRQ on PA14, input, pulled up, active low
// EN on PC7, output, active high
// CS on PC6, output, active low
@@ -165,3 +167,5 @@ uint8_t pyb_cc3000_spi_send(uint8_t val) {
HAL_SPI_TransmitReceive(&SPI_HANDLE, data, data, 1, 1000);
return data[0];
}
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/security.c b/stmhal/cc3k/security.c
index c12aee370..c52d7f67e 100644
--- a/stmhal/cc3k/security.c
+++ b/stmhal/cc3k/security.c
@@ -41,6 +41,9 @@
//*****************************************************************************
#include <stdint.h>
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "security.h"
@@ -533,3 +536,5 @@ signed long aes_write_key(unsigned char *key)
//! @}
//
//*****************************************************************************
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/socket.c b/stmhal/cc3k/socket.c
index cfccbd783..86a4549ec 100644
--- a/stmhal/cc3k/socket.c
+++ b/stmhal/cc3k/socket.c
@@ -50,6 +50,9 @@
#include <stdint.h>
#include <string.h> // for memcpy
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "hci.h"
#include "socket.h"
@@ -1188,3 +1191,5 @@ mdnsAdvertiser(unsigned short mdnsEnabled, char * deviceServiceName, unsigned sh
return ret;
}
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/cc3k/wlan.c b/stmhal/cc3k/wlan.c
index be6b3242c..b22796a7c 100644
--- a/stmhal/cc3k/wlan.c
+++ b/stmhal/cc3k/wlan.c
@@ -49,6 +49,9 @@
//*****************************************************************************
#include <stdlib.h>
#include <stdint.h>
+#include "mpconfigport.h"
+
+#if MICROPY_HW_ENABLE_CC3K
#include "wlan.h"
#include "hci.h"
@@ -1262,3 +1265,5 @@ wlan_smart_config_process()
//! @}
//
//*****************************************************************************
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/stmhal/main.c b/stmhal/main.c
index 603bf3188..5faa70e65 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -495,13 +495,11 @@ soft_reset:
vstr_free(vstr);
}
-#if 0
-#if MICROPY_HW_HAS_WLAN
- // wifi
+#if MICROPY_HW_ENABLE_CC3K
+ // wifi using the CC3000 driver
pyb_wlan_init();
pyb_wlan_start();
#endif
-#endif
// enter REPL
// REPL mode can change, or it can request a soft reset
diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h
index ad55ed632..faa1c806a 100644
--- a/stmhal/mpconfigport.h
+++ b/stmhal/mpconfigport.h
@@ -19,6 +19,7 @@
#define MICROPY_ENABLE_LFN (1)
#define MICROPY_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
#define MICROPY_MOD_SYS_STDFILES (1)
+#define MICROPY_ENABLE_MOD_CMATH (1)
// extra built in names to add to the global namespace
extern const struct _mp_obj_fun_native_t mp_builtin_help_obj;
diff --git a/stmhal/pybwlan.c b/stmhal/pybwlan.c
index 06309b61c..fb214209c 100644
--- a/stmhal/pybwlan.c
+++ b/stmhal/pybwlan.c
@@ -12,6 +12,8 @@
#include "obj.h"
#include "runtime.h"
+#if MICROPY_HW_ENABLE_CC3K
+
#include "cc3k/ccspi.h"
#include "cc3k/hci.h"
#include "cc3k/socket.h"
@@ -377,3 +379,5 @@ void pyb_wlan_start(void) {
printf("nvmem_read_sp_version=%d; %02x %02x\n", ret, ver[0], ver[1]);
*/
}
+
+#endif // MICROPY_HW_ENABLE_CC3K
diff --git a/tools/build-stm-latest.sh b/tools/build-stm-latest.sh
index 951d8be9c..f0d639d10 100755
--- a/tools/build-stm-latest.sh
+++ b/tools/build-stm-latest.sh
@@ -24,8 +24,8 @@ git_hash="$(git rev-parse --short HEAD 2> /dev/null || echo unknown)"
for board in PYBV3 PYBV10; do
echo $board
lower_board=$(echo $board | tr A-Z a-z)
- build_dir=/tmp/stm-build-$lower_board
+ build_dir=/tmp/stm-build-$board
make -B BOARD=$board BUILD=$build_dir || exit 1
- mv $build_dir/flash.dfu $dest_dir/$lower_board-$date-$git_hash.dfu
+ mv $build_dir/firmware.dfu $dest_dir/$lower_board-$date-$git_hash.dfu
rm -rf $build_dir
done
diff --git a/tools/pyboard.py b/tools/pyboard.py
index 38d428282..dce60350d 100644
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -9,7 +9,7 @@ Example usage:
import pyboard
pyb = pyboard.Pyboard('/dev/ttyACM0')
pyb.enter_raw_repl()
- pyb.exec('pyb.Led(1).on()')
+ pyb.exec('pyb.LED(1).on()')
pyb.exit_raw_repl()
To run a script from the local machine on the board and print out the results:
@@ -17,6 +17,10 @@ To run a script from the local machine on the board and print out the results:
import pyboard
pyboard.execfile('test.py', device='/dev/ttyACM0')
+This script can also be run directly. To execute a local script, use:
+
+ python pyboard.py test.py
+
"""
import time
@@ -157,5 +161,19 @@ def run_test():
pyb.exit_raw_repl()
pyb.close()
+def main():
+ import argparse
+ cmd_parser = argparse.ArgumentParser(description='Run scripts on the pyboard.')
+ cmd_parser.add_argument('--device', default='/dev/ttyACM0', help='the serial device of the pyboard')
+ cmd_parser.add_argument('--test', action='store_true', help='run a small test suite on the pyboard')
+ cmd_parser.add_argument('files', nargs='*', help='input files')
+ args = cmd_parser.parse_args()
+
+ if args.test:
+ run_test()
+
+ for file in args.files:
+ execfile(file, device=args.device)
+
if __name__ == "__main__":
- run_test()
+ main()