diff options
Diffstat (limited to 'stm')
-rw-r--r-- | stm/Makefile | 7 | ||||
-rw-r--r-- | stm/adc.c | 1 | ||||
-rw-r--r-- | stm/audio.c | 12 | ||||
-rw-r--r-- | stm/i2c.c | 1 | ||||
-rw-r--r-- | stm/lcd.c | 19 | ||||
-rw-r--r-- | stm/led.c | 1 | ||||
-rw-r--r-- | stm/lexerfatfs.c | 2 | ||||
-rw-r--r-- | stm/main.c | 70 | ||||
-rw-r--r-- | stm/mma.c | 1 | ||||
-rw-r--r-- | stm/printf.c | 3 | ||||
-rw-r--r-- | stm/pybwlan.c | 52 | ||||
-rw-r--r-- | stm/qstrdefsport.h | 30 | ||||
-rw-r--r-- | stm/servo.c | 1 | ||||
-rw-r--r-- | stm/std.h | 2 | ||||
-rw-r--r-- | stm/stm32fxxx_it.c | 1 | ||||
-rw-r--r-- | stm/storage.c | 1 | ||||
-rw-r--r-- | stm/timer.c | 14 | ||||
-rw-r--r-- | stm/usart.c | 1 | ||||
-rw-r--r-- | stm/usrsw.c | 1 |
19 files changed, 137 insertions, 83 deletions
diff --git a/stm/Makefile b/stm/Makefile index 3ea1472dc6..9c0fe2acf0 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -1,6 +1,9 @@ # define main target all: all2 +# qstr definitions (must come before including py.mk) +QSTR_DEFS = qstrdefsport.h + # include py core make definitions include ../py/py.mk @@ -131,7 +134,7 @@ SRC_CC3K = \ ccspi.c \ pybcc3k.c \ -OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o) $(SRC_CC3K:.c=.o)) $(PY_O) +OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o) $(SRC_CC3K:.c=.o)) #OBJ += $(addprefix $(BUILD)/, $(SRC_STM_OTG:.c=.o)) all2: $(BUILD) $(BUILD)/flash.dfu @@ -155,7 +158,7 @@ $(BUILD)/%.o: %.s $(ECHO) "AS $<" $(Q)$(AS) -o $@ $< -$(BUILD)/%.o: %.c +$(BUILD)/%.o: %.c $(QSTR_DEFS) $(ECHO) "CC $<" $(Q)$(CC) $(CFLAGS) -c -o $@ $< @@ -3,6 +3,7 @@ #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "adc.h" diff --git a/stm/audio.c b/stm/audio.c index e2aa32b9fc..c1a0c84747 100644 --- a/stm/audio.c +++ b/stm/audio.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include <string.h> #include "stm32f4xx_rcc.h" #include "stm32f4xx_gpio.h" @@ -7,6 +8,7 @@ #include "nlr.h" #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "parse.h" #include "obj.h" #include "runtime.h" @@ -90,9 +92,9 @@ void audio_init(void) { // enable interrupt // Python interface - mp_obj_t m = mp_obj_new_module(qstr_from_str_static("audio")); - rt_store_attr(m, qstr_from_str_static("dac"), rt_make_function_n(1, pyb_audio_dac)); - rt_store_attr(m, qstr_from_str_static("is_full"), rt_make_function_n(0, pyb_audio_is_full)); - rt_store_attr(m, qstr_from_str_static("fill"), rt_make_function_n(1, pyb_audio_fill)); - rt_store_name(qstr_from_str_static("audio"), m); + mp_obj_t m = mp_obj_new_module(QSTR_FROM_STR_STATIC("audio")); + rt_store_attr(m, QSTR_FROM_STR_STATIC("dac"), rt_make_function_n(1, pyb_audio_dac)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("is_full"), rt_make_function_n(0, pyb_audio_is_full)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("fill"), rt_make_function_n(1, pyb_audio_fill)); + rt_store_name(QSTR_FROM_STR_STATIC("audio"), m); } @@ -5,6 +5,7 @@ #include "misc.h" #include "systick.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" typedef enum { @@ -4,6 +4,7 @@ #include "nlr.h" #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "parse.h" #include "obj.h" #include "runtime.h" @@ -219,15 +220,15 @@ void lcd_init(void) { lcd_next_line = 0; // Python interface - mp_obj_t m = mp_obj_new_module(qstr_from_str_static("lcd")); - rt_store_attr(m, qstr_from_str_static("lcd8"), rt_make_function_n(2, lcd_draw_pixel_8)); - rt_store_attr(m, qstr_from_str_static("clear"), rt_make_function_n(0, lcd_pix_clear)); - rt_store_attr(m, qstr_from_str_static("get"), rt_make_function_n(2, lcd_pix_get)); - rt_store_attr(m, qstr_from_str_static("set"), rt_make_function_n(2, lcd_pix_set)); - rt_store_attr(m, qstr_from_str_static("reset"), rt_make_function_n(2, lcd_pix_reset)); - rt_store_attr(m, qstr_from_str_static("show"), rt_make_function_n(0, lcd_pix_show)); - rt_store_attr(m, qstr_from_str_static("text"), rt_make_function_n(1, lcd_print)); - rt_store_name(qstr_from_str_static("lcd"), m); + mp_obj_t m = mp_obj_new_module(QSTR_FROM_STR_STATIC("lcd")); + rt_store_attr(m, QSTR_FROM_STR_STATIC("lcd8"), rt_make_function_n(2, lcd_draw_pixel_8)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("clear"), rt_make_function_n(0, lcd_pix_clear)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("get"), rt_make_function_n(2, lcd_pix_get)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("set"), rt_make_function_n(2, lcd_pix_set)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("reset"), rt_make_function_n(2, lcd_pix_reset)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("show"), rt_make_function_n(0, lcd_pix_show)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("text"), rt_make_function_n(1, lcd_print)); + rt_store_name(QSTR_FROM_STR_STATIC("lcd"), m); } void lcd_print_str(const char *str) { @@ -4,6 +4,7 @@ #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "led.h" diff --git a/stm/lexerfatfs.c b/stm/lexerfatfs.c index 461fbb3709..bf82349f35 100644 --- a/stm/lexerfatfs.c +++ b/stm/lexerfatfs.c @@ -4,6 +4,8 @@ #include "ff.h" #include "misc.h" +#include "mpconfig.h" +#include "qstr.h" #include "lexer.h" #include "lexerfatfs.h" diff --git a/stm/main.c b/stm/main.c index 7c92e8e180..a3ad8caf3d 100644 --- a/stm/main.c +++ b/stm/main.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <string.h> #include <stm32f4xx.h> #include <stm32f4xx_rcc.h> #include <stm32f4xx_syscfg.h> @@ -15,7 +16,7 @@ #include "misc.h" #include "ff.h" #include "mpconfig.h" -#include "mpqstr.h" +#include "qstr.h" #include "nlr.h" #include "misc.h" #include "lexer.h" @@ -677,11 +678,10 @@ void file_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, m mp_obj_t file_obj_read(mp_obj_t self_in, mp_obj_t arg) { pyb_file_obj_t *self = self_in; int n = mp_obj_get_int(arg); - char *buf = m_new(char, n + 1); + char *buf = m_new(char, n); UINT n_out; f_read(&self->fp, buf, n, &n_out); - buf[n_out] = 0; - return mp_obj_new_str(qstr_from_str_take(buf, n + 1)); + return mp_obj_new_str(qstr_from_strn_take(buf, n, n_out)); } mp_obj_t file_obj_write(mp_obj_t self_in, mp_obj_t arg) { @@ -827,37 +827,37 @@ soft_reset: // add some functions to the python namespace { - rt_store_name(qstr_from_str_static("help"), rt_make_function_n(0, pyb_help)); - - mp_obj_t m = mp_obj_new_module(qstr_from_str_static("pyb")); - rt_store_attr(m, qstr_from_str_static("info"), rt_make_function_n(0, pyb_info)); - rt_store_attr(m, qstr_from_str_static("sd_test"), rt_make_function_n(0, pyb_sd_test)); - rt_store_attr(m, qstr_from_str_static("stop"), rt_make_function_n(0, pyb_stop)); - rt_store_attr(m, qstr_from_str_static("standby"), rt_make_function_n(0, pyb_standby)); - rt_store_attr(m, qstr_from_str_static("source_dir"), rt_make_function_n(1, pyb_source_dir)); - rt_store_attr(m, qstr_from_str_static("main"), rt_make_function_n(1, pyb_main)); - rt_store_attr(m, qstr_from_str_static("sync"), rt_make_function_n(0, pyb_sync)); - rt_store_attr(m, qstr_from_str_static("gc"), rt_make_function_n(0, pyb_gc)); - rt_store_attr(m, qstr_from_str_static("delay"), rt_make_function_n(1, pyb_delay)); - rt_store_attr(m, qstr_from_str_static("led"), rt_make_function_n(1, pyb_led)); - rt_store_attr(m, qstr_from_str_static("switch"), (mp_obj_t)&pyb_switch_obj); - rt_store_attr(m, qstr_from_str_static("servo"), rt_make_function_n(2, pyb_servo_set)); - rt_store_attr(m, qstr_from_str_static("pwm"), rt_make_function_n(2, pyb_pwm_set)); - rt_store_attr(m, qstr_from_str_static("accel"), (mp_obj_t)&pyb_mma_read_obj); - rt_store_attr(m, qstr_from_str_static("mma_read"), (mp_obj_t)&pyb_mma_read_all_obj); - rt_store_attr(m, qstr_from_str_static("mma_mode"), (mp_obj_t)&pyb_mma_write_mode_obj); - rt_store_attr(m, qstr_from_str_static("hid"), rt_make_function_n(1, pyb_hid_send_report)); - rt_store_attr(m, qstr_from_str_static("time"), rt_make_function_n(0, pyb_rtc_read)); - rt_store_attr(m, qstr_from_str_static("rand"), rt_make_function_n(0, pyb_rng_get)); - rt_store_attr(m, qstr_from_str_static("Led"), rt_make_function_n(1, pyb_Led)); - rt_store_attr(m, qstr_from_str_static("Servo"), rt_make_function_n(1, pyb_Servo)); - rt_store_attr(m, qstr_from_str_static("I2C"), rt_make_function_n(2, pyb_I2C)); - rt_store_attr(m, qstr_from_str_static("gpio"), (mp_obj_t)&pyb_gpio_obj); - rt_store_attr(m, qstr_from_str_static("Usart"), rt_make_function_n(2, pyb_Usart)); - rt_store_attr(m, qstr_from_str_static("ADC"), rt_make_function_n(1, pyb_ADC)); - rt_store_name(qstr_from_str_static("pyb"), m); - - rt_store_name(qstr_from_str_static("open"), rt_make_function_n(2, pyb_io_open)); + rt_store_name(MP_QSTR_help, rt_make_function_n(0, pyb_help)); + + mp_obj_t m = mp_obj_new_module(MP_QSTR_pyb); + rt_store_attr(m, MP_QSTR_info, rt_make_function_n(0, pyb_info)); + rt_store_attr(m, MP_QSTR_sd_test, rt_make_function_n(0, pyb_sd_test)); + rt_store_attr(m, MP_QSTR_stop, rt_make_function_n(0, pyb_stop)); + rt_store_attr(m, MP_QSTR_standby, rt_make_function_n(0, pyb_standby)); + rt_store_attr(m, MP_QSTR_source_dir, rt_make_function_n(1, pyb_source_dir)); + rt_store_attr(m, MP_QSTR_main, rt_make_function_n(1, pyb_main)); + rt_store_attr(m, MP_QSTR_sync, rt_make_function_n(0, pyb_sync)); + rt_store_attr(m, MP_QSTR_gc, rt_make_function_n(0, pyb_gc)); + rt_store_attr(m, MP_QSTR_delay, rt_make_function_n(1, pyb_delay)); + rt_store_attr(m, MP_QSTR_led, rt_make_function_n(1, pyb_led)); + rt_store_attr(m, MP_QSTR_switch, (mp_obj_t)&pyb_switch_obj); + rt_store_attr(m, MP_QSTR_servo, rt_make_function_n(2, pyb_servo_set)); + rt_store_attr(m, MP_QSTR_pwm, rt_make_function_n(2, pyb_pwm_set)); + rt_store_attr(m, MP_QSTR_accel, (mp_obj_t)&pyb_mma_read_obj); + rt_store_attr(m, MP_QSTR_mma_read, (mp_obj_t)&pyb_mma_read_all_obj); + rt_store_attr(m, MP_QSTR_mma_mode, (mp_obj_t)&pyb_mma_write_mode_obj); + rt_store_attr(m, MP_QSTR_hid, rt_make_function_n(1, pyb_hid_send_report)); + rt_store_attr(m, MP_QSTR_time, rt_make_function_n(0, pyb_rtc_read)); + rt_store_attr(m, MP_QSTR_rand, rt_make_function_n(0, pyb_rng_get)); + rt_store_attr(m, MP_QSTR_Led, rt_make_function_n(1, pyb_Led)); + rt_store_attr(m, MP_QSTR_Servo, rt_make_function_n(1, pyb_Servo)); + rt_store_attr(m, MP_QSTR_I2C, rt_make_function_n(2, pyb_I2C)); + rt_store_attr(m, MP_QSTR_gpio, (mp_obj_t)&pyb_gpio_obj); + rt_store_attr(m, MP_QSTR_Usart, rt_make_function_n(2, pyb_Usart)); + rt_store_attr(m, MP_QSTR_ADC, rt_make_function_n(1, pyb_ADC)); + rt_store_name(MP_QSTR_pyb, m); + + rt_store_name(MP_QSTR_open, rt_make_function_n(2, pyb_io_open)); } // print a message to the LCD @@ -6,6 +6,7 @@ #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "systick.h" #include "obj.h" #include "runtime.h" diff --git a/stm/printf.c b/stm/printf.c index 732e834526..82b168d1c4 100644 --- a/stm/printf.c +++ b/stm/printf.c @@ -1,9 +1,12 @@ #include <stdint.h> +#include <string.h> #include <stdarg.h> + #include "std.h" #include "misc.h" #include "systick.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "lcd.h" #include "usart.h" diff --git a/stm/pybwlan.c b/stm/pybwlan.c index 0c9b5501ee..e403a645ee 100644 --- a/stm/pybwlan.c +++ b/stm/pybwlan.c @@ -1,5 +1,6 @@ #include <stdlib.h> #include <stdint.h> +#include <string.h> #include <stm32f4xx.h> #include <stm32f4xx_rcc.h> #include <stm32f4xx_gpio.h> @@ -12,6 +13,7 @@ #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "systick.h" #include "nlr.h" @@ -58,7 +60,7 @@ mp_obj_t decode_addr(unsigned char *ip, int n_bytes) { } else if (n_bytes == 32) { snprintf(data, 64, "%s", ip); } - return mp_obj_new_str(qstr_from_strn_copy(data, strlen(data))); + return mp_obj_new_str(qstr_from_strn(data, strlen(data))); } void decode_addr_and_store(mp_obj_t object, qstr q_attr, unsigned char *ip, int n_bytes) { @@ -78,20 +80,20 @@ mp_obj_t pyb_wlan_get_ip(void) { // if it doesn't already exist, make a new empty class for NetAddress objects if (net_address_type == MP_OBJ_NULL) { - net_address_type = mp_obj_new_type(qstr_from_str_static("NetAddress"), mp_const_empty_tuple, mp_obj_new_dict(0)); + net_address_type = mp_obj_new_type(QSTR_FROM_STR_STATIC("NetAddress"), mp_const_empty_tuple, mp_obj_new_dict(0)); } // make a new NetAddress object mp_obj_t net_addr = rt_call_function_0(net_address_type); // fill the NetAddress object with data - decode_addr_and_store(net_addr, qstr_from_str_static("ip"), &ipconfig.aucIP[0], 4); - decode_addr_and_store(net_addr, qstr_from_str_static("subnet"), &ipconfig.aucSubnetMask[0], 4); - decode_addr_and_store(net_addr, qstr_from_str_static("gateway"), &ipconfig.aucDefaultGateway[0], 4); - decode_addr_and_store(net_addr, qstr_from_str_static("dhcp"), &ipconfig.aucDHCPServer[0], 4); - decode_addr_and_store(net_addr, qstr_from_str_static("dns"), &ipconfig.aucDNSServer[0], 4); - decode_addr_and_store(net_addr, qstr_from_str_static("mac"), &ipconfig.uaMacAddr[0], 6); - decode_addr_and_store(net_addr, qstr_from_str_static("ssid"), &ipconfig.uaSSID[0], 32); + decode_addr_and_store(net_addr, QSTR_FROM_STR_STATIC("ip"), &ipconfig.aucIP[0], 4); + decode_addr_and_store(net_addr, QSTR_FROM_STR_STATIC("subnet"), &ipconfig.aucSubnetMask[0], 4); + decode_addr_and_store(net_addr, QSTR_FROM_STR_STATIC("gateway"), &ipconfig.aucDefaultGateway[0], 4); + decode_addr_and_store(net_addr, QSTR_FROM_STR_STATIC("dhcp"), &ipconfig.aucDHCPServer[0], 4); + decode_addr_and_store(net_addr, QSTR_FROM_STR_STATIC("dns"), &ipconfig.aucDNSServer[0], 4); + decode_addr_and_store(net_addr, QSTR_FROM_STR_STATIC("mac"), &ipconfig.uaMacAddr[0], 6); + decode_addr_and_store(net_addr, QSTR_FROM_STR_STATIC("ssid"), &ipconfig.uaSSID[0], 32); return net_addr; } @@ -122,12 +124,12 @@ mp_obj_t pyb_wlan_http_get(mp_obj_t host_name, mp_obj_t host_path) { last_ip = (192 << 24) | (168 << 16) | (0 << 8) | (3); } else { if (pyb_wlan_get_host(host_name) == mp_const_none) { - nlr_jump(mp_obj_new_exception_msg(qstr_from_str_static("WlanError"), "unknown host")); + nlr_jump(mp_obj_new_exception_msg(QSTR_FROM_STR_STATIC("WlanError"), "unknown host")); } } int sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sd < 0) { - nlr_jump(mp_obj_new_exception_msg_1_arg(qstr_from_str_static("WlanError"), "socket failed: %d", (void*)sd)); + nlr_jump(mp_obj_new_exception_msg_1_arg(QSTR_FROM_STR_STATIC("WlanError"), "socket failed: %d", (void*)sd)); } //printf("socket seemed to work\n"); //sys_tick_delay_ms(200); @@ -138,7 +140,7 @@ mp_obj_t pyb_wlan_http_get(mp_obj_t host_name, mp_obj_t host_path) { remote.sin_addr.s_addr = htonl(last_ip); int ret = connect(sd, (sockaddr*)&remote, sizeof(sockaddr)); if (ret != 0) { - nlr_jump(mp_obj_new_exception_msg_1_arg(qstr_from_str_static("WlanError"), "connect failed: %d", (void*)ret)); + nlr_jump(mp_obj_new_exception_msg_1_arg(QSTR_FROM_STR_STATIC("WlanError"), "connect failed: %d", (void*)ret)); } //printf("connect seemed to work\n"); //sys_tick_delay_ms(200); @@ -159,7 +161,7 @@ mp_obj_t pyb_wlan_http_get(mp_obj_t host_name, mp_obj_t host_path) { ret = send(sd, query + sent, strlen(query + sent), 0); //printf("sent %d bytes\n", ret); if (ret < 0) { - nlr_jump(mp_obj_new_exception_msg(qstr_from_str_static("WlanError"), "send failed")); + nlr_jump(mp_obj_new_exception_msg(QSTR_FROM_STR_STATIC("WlanError"), "send failed")); } sent += ret; //sys_tick_delay_ms(200); @@ -196,12 +198,12 @@ mp_obj_t pyb_wlan_http_get(mp_obj_t host_name, mp_obj_t host_path) { // read data ret = recv(sd, buf, 64, 0); if (ret < 0) { - nlr_jump(mp_obj_new_exception_msg_1_arg(qstr_from_str_static("WlanError"), "recv failed %d", (void*)ret)); + nlr_jump(mp_obj_new_exception_msg_1_arg(QSTR_FROM_STR_STATIC("WlanError"), "recv failed %d", (void*)ret)); } vstr_add_strn(vstr, buf, ret); } - mp_ret = mp_obj_new_str(qstr_from_str_take(vstr->buf, vstr->alloc)); + mp_ret = mp_obj_new_str(qstr_from_strn_take(vstr->buf, vstr->alloc, vstr->len)); } closesocket(sd); @@ -216,7 +218,7 @@ mp_obj_t pyb_wlan_serve(void) { sys_tick_delay_ms(500); if (sd < 0) { printf("socket fail\n"); - nlr_jump(mp_obj_new_exception_msg_1_arg(qstr_from_str_static("WlanError"), "socket failed: %d", (void*)sd)); + nlr_jump(mp_obj_new_exception_msg_1_arg(QSTR_FROM_STR_STATIC("WlanError"), "socket failed: %d", (void*)sd)); } /* @@ -237,7 +239,7 @@ mp_obj_t pyb_wlan_serve(void) { sys_tick_delay_ms(100); if (ret != 0) { printf("bind fail\n"); - nlr_jump(mp_obj_new_exception_msg_1_arg(qstr_from_str_static("WlanError"), "bind failed: %d", (void*)ret)); + nlr_jump(mp_obj_new_exception_msg_1_arg(QSTR_FROM_STR_STATIC("WlanError"), "bind failed: %d", (void*)ret)); } printf("bind seemed to work\n"); @@ -355,14 +357,14 @@ void pyb_wlan_init(void) { SpiInit(); wlan_init(CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin); - mp_obj_t m = mp_obj_new_module(qstr_from_str_static("wlan")); - rt_store_attr(m, qstr_from_str_static("connect"), rt_make_function_var(0, pyb_wlan_connect)); - rt_store_attr(m, qstr_from_str_static("disconnect"), rt_make_function_n(0, pyb_wlan_disconnect)); - rt_store_attr(m, qstr_from_str_static("ip"), rt_make_function_n(0, pyb_wlan_get_ip)); - rt_store_attr(m, qstr_from_str_static("get_host"), rt_make_function_n(1, pyb_wlan_get_host)); - rt_store_attr(m, qstr_from_str_static("http_get"), rt_make_function_n(2, pyb_wlan_http_get)); - rt_store_attr(m, qstr_from_str_static("serve"), rt_make_function_n(0, pyb_wlan_serve)); - rt_store_name(qstr_from_str_static("wlan"), m); + mp_obj_t m = mp_obj_new_module(QSTR_FROM_STR_STATIC("wlan")); + rt_store_attr(m, QSTR_FROM_STR_STATIC("connect"), rt_make_function_var(0, pyb_wlan_connect)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("disconnect"), rt_make_function_n(0, pyb_wlan_disconnect)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("ip"), rt_make_function_n(0, pyb_wlan_get_ip)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("get_host"), rt_make_function_n(1, pyb_wlan_get_host)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("http_get"), rt_make_function_n(2, pyb_wlan_http_get)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("serve"), rt_make_function_n(0, pyb_wlan_serve)); + rt_store_name(QSTR_FROM_STR_STATIC("wlan"), m); } void pyb_wlan_start(void) { diff --git a/stm/qstrdefsport.h b/stm/qstrdefsport.h new file mode 100644 index 0000000000..7e6f93e423 --- /dev/null +++ b/stm/qstrdefsport.h @@ -0,0 +1,30 @@ +// qstrs specific to this port + +Q(help) +Q(pyb) +Q(info) +Q(sd_test) +Q(stop) +Q(standby) +Q(source_dir) +Q(main) +Q(sync) +Q(gc) +Q(delay) +Q(led) +Q(switch) +Q(servo) +Q(pwm) +Q(accel) +Q(mma_read) +Q(mma_mode) +Q(hid) +Q(time) +Q(rand) +Q(Led) +Q(Servo) +Q(I2C) +Q(gpio) +Q(Usart) +Q(ADC) +Q(open) diff --git a/stm/servo.c b/stm/servo.c index f89c97f1c5..31d65283b5 100644 --- a/stm/servo.c +++ b/stm/servo.c @@ -6,6 +6,7 @@ #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "servo.h" @@ -11,7 +11,7 @@ void *memcpy(void *dest, const void *src, size_t n); void *memmove(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); -int strlen(const char *str); +//int strlen(const char *str); int strcmp(const char *s1, const char *s2); int strncmp(const char *s1, const char *s2, size_t n); char *strndup(const char *s, size_t n); diff --git a/stm/stm32fxxx_it.c b/stm/stm32fxxx_it.c index c1a9a0702f..0cece8854f 100644 --- a/stm/stm32fxxx_it.c +++ b/stm/stm32fxxx_it.c @@ -271,6 +271,7 @@ void TIM6_DAC_IRQHandler(void) { #include "std.h" #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "led.h" // EXTI diff --git a/stm/storage.c b/stm/storage.c index daee4adb5e..a684fcb0a0 100644 --- a/stm/storage.c +++ b/stm/storage.c @@ -4,6 +4,7 @@ #include "misc.h" #include "systick.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "led.h" #include "flash.h" diff --git a/stm/timer.c b/stm/timer.c index 062f8c689e..d20d3a77bd 100644 --- a/stm/timer.c +++ b/stm/timer.c @@ -1,5 +1,6 @@ #include <stdint.h> #include <stdio.h> +#include <string.h> #include "stm_misc.h" #include "stm32f4xx_rcc.h" @@ -8,6 +9,7 @@ #include "nlr.h" #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "parse.h" #include "obj.h" #include "runtime.h" @@ -71,12 +73,12 @@ void timer_init(void) { TIM_Cmd(TIM6, ENABLE); // Python interface - mp_obj_t m = mp_obj_new_module(qstr_from_str_static("timer")); - rt_store_attr(m, qstr_from_str_static("callback"), rt_make_function_n(1, timer_py_set_callback)); - rt_store_attr(m, qstr_from_str_static("period"), rt_make_function_n(1, timer_py_set_period)); - rt_store_attr(m, qstr_from_str_static("prescaler"), rt_make_function_n(1, timer_py_set_prescaler)); - rt_store_attr(m, qstr_from_str_static("value"), rt_make_function_n(0, timer_py_get_value)); - rt_store_name(qstr_from_str_static("timer"), m); + mp_obj_t m = mp_obj_new_module(QSTR_FROM_STR_STATIC("timer")); + rt_store_attr(m, QSTR_FROM_STR_STATIC("callback"), rt_make_function_n(1, timer_py_set_callback)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("period"), rt_make_function_n(1, timer_py_set_period)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("prescaler"), rt_make_function_n(1, timer_py_set_prescaler)); + rt_store_attr(m, QSTR_FROM_STR_STATIC("value"), rt_make_function_n(0, timer_py_get_value)); + rt_store_name(QSTR_FROM_STR_STATIC("timer"), m); } void timer_interrupt(void) { diff --git a/stm/usart.c b/stm/usart.c index 796516f547..c687cff05f 100644 --- a/stm/usart.c +++ b/stm/usart.c @@ -5,6 +5,7 @@ #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "usart.h" diff --git a/stm/usrsw.c b/stm/usrsw.c index 9d1ee50ffb..dc2b03f3db 100644 --- a/stm/usrsw.c +++ b/stm/usrsw.c @@ -6,6 +6,7 @@ #include "misc.h" #include "mpconfig.h" +#include "qstr.h" #include "obj.h" #include "usrsw.h" |