Skip to content

Commit 8e611e8

Browse files
author
Daniel Campora
committed
cc3200: Add Timer module. Supports free running, PWM and capture modes.
1 parent 9466e15 commit 8e611e8

File tree

16 files changed

+946
-31
lines changed

16 files changed

+946
-31
lines changed

cc3200/application.lds

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
__stack_size__ = 2K; /* interrupts are handled within this stack */
2828
__min_heap_size__ = 8K;
29-
__rtos_heap_size = 16K;
3029

3130
MEMORY
3231
{

cc3200/application.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ APP_MODS_SRC_C = $(addprefix mods/,\
9898
pybsd.c \
9999
pybsleep.c \
100100
pybspi.c \
101+
pybtimer.c \
101102
pybuart.c \
102103
pybwdt.c \
103104
)
@@ -192,6 +193,7 @@ $(BUILD)/FreeRTOS/Source/%.o: CFLAGS += -Os
192193
$(BUILD)/ftp/%.o: CFLAGS += -Os
193194
$(BUILD)/hal/%.o: CFLAGS += -Os
194195
$(BUILD)/misc/%.o: CFLAGS += -Os
196+
$(BUILD)/mods/%.o: CFLAGS += -Os
195197
$(BUILD)/py/%.o: CFLAGS += -Os
196198
$(BUILD)/simplelink/%.o: CFLAGS += -Os
197199
$(BUILD)/drivers/cc3100/%.o: CFLAGS += -Os

cc3200/misc/mpcallback.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ mp_obj_t mpcallback_new (mp_obj_t parent, mp_obj_t handler, const mp_cb_methods_
7171

7272
mpcallback_obj_t *mpcallback_find (mp_obj_t parent) {
7373
for (mp_uint_t i = 0; i < MP_STATE_PORT(mpcallback_obj_list).len; i++) {
74-
// search for the object and then remove it
7574
mpcallback_obj_t *callback_obj = ((mpcallback_obj_t *)(MP_STATE_PORT(mpcallback_obj_list).items[i]));
7675
if (callback_obj->parent == parent) {
7776
return callback_obj;

cc3200/mods/modnetwork.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ STATIC mp_obj_t network_server_stop(void) {
8080
}
8181
STATIC MP_DEFINE_CONST_FUN_OBJ_0(network_server_stop_obj, network_server_stop);
8282

83-
STATIC mp_obj_t network_server_enabled(void) {
83+
STATIC mp_obj_t network_server_running(void) {
8484
return MP_BOOL(servers_are_enabled());
8585
}
86-
STATIC MP_DEFINE_CONST_FUN_OBJ_0(network_server_enabled_obj, network_server_enabled);
86+
STATIC MP_DEFINE_CONST_FUN_OBJ_0(network_server_running_obj, network_server_running);
8787

8888
STATIC mp_obj_t network_server_login(mp_obj_t user, mp_obj_t pass) {
8989
const char *_user = mp_obj_str_get_str(user);
@@ -102,7 +102,7 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
102102
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
103103
{ MP_OBJ_NEW_QSTR(MP_QSTR_start_server), (mp_obj_t)&network_server_start_obj },
104104
{ MP_OBJ_NEW_QSTR(MP_QSTR_stop_server), (mp_obj_t)&network_server_stop_obj },
105-
{ MP_OBJ_NEW_QSTR(MP_QSTR_server_enabled), (mp_obj_t)&network_server_enabled_obj },
105+
{ MP_OBJ_NEW_QSTR(MP_QSTR_server_running), (mp_obj_t)&network_server_running_obj },
106106
{ MP_OBJ_NEW_QSTR(MP_QSTR_server_login), (mp_obj_t)&network_server_login_obj },
107107
#endif
108108
};

cc3200/mods/modpyb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "pybwdt.h"
6363
#include "pybsleep.h"
6464
#include "pybspi.h"
65+
#include "pybtimer.h"
6566
#include "utils.h"
6667
#include "gccollect.h"
6768
#include "mperror.h"
@@ -271,6 +272,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
271272
{ MP_OBJ_NEW_QSTR(MP_QSTR_I2C), (mp_obj_t)&pyb_i2c_type },
272273
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPI), (mp_obj_t)&pyb_spi_type },
273274
{ MP_OBJ_NEW_QSTR(MP_QSTR_UART), (mp_obj_t)&pyb_uart_type },
275+
{ MP_OBJ_NEW_QSTR(MP_QSTR_Timer), (mp_obj_t)&pyb_timer_type },
274276
{ MP_OBJ_NEW_QSTR(MP_QSTR_WDT), (mp_obj_t)&pyb_wdt_obj },
275277
{ MP_OBJ_NEW_QSTR(MP_QSTR_Sleep), (mp_obj_t)&pyb_sleep_obj },
276278
{ MP_OBJ_NEW_QSTR(MP_QSTR_HeartBeat), (mp_obj_t)&pyb_heartbeat_obj },

cc3200/mods/modwlan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ STATIC mp_obj_t wlan_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
787787
// connect to the requested access point
788788
modwlan_Status_t status;
789789
status = wlan_do_connect (ssid, ssid_len, bssid, sec, key, key_len);
790+
// TODO: make the timeout a parameter so that is configurable
790791
if (status == MODWLAN_ERROR_TIMEOUT) {
791792
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
792793
}

cc3200/mods/pybpin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ STATIC void EXTI_Handler(uint port) {
755755
uint32_t bit = MAP_GPIOIntStatus(port, true);
756756
MAP_GPIOIntClear(port, bit);
757757

758+
// TODO: loop through all the active bits before exiting
758759
pin_obj_t *self = (pin_obj_t *)pin_find_pin_by_port_bit(&pin_cpu_pins_locals_dict, port, bit);
759760
mp_obj_t _callback = mpcallback_find(self);
760761
mpcallback_handler(_callback);

cc3200/mods/pybrtc.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ void pybrtc_init(void) {
9292
}
9393
}
9494

95+
void pyb_rtc_callback_disable (mp_obj_t self_in) {
96+
// check the wake from param
97+
if (pybrtc_data.prwmode & PYB_PWR_MODE_ACTIVE) {
98+
// disable the slow clock interrupt
99+
MAP_PRCMIntDisable(PRCM_INT_SLOW_CLK_CTR);
100+
}
101+
// disable wake from ldps and hibernate
102+
pybsleep_configure_timer_wakeup (PYB_PWR_MODE_ACTIVE);
103+
// read the interrupt status to clear any pending interrupt
104+
(void)MAP_PRCMIntStatus();
105+
}
106+
95107
/******************************************************************************
96108
DECLARE PRIVATE FUNCTIONS
97109
******************************************************************************/
@@ -108,18 +120,6 @@ STATIC void pyb_rtc_callback_enable (mp_obj_t self_in) {
108120
pybsleep_configure_timer_wakeup (pybrtc_data.prwmode);
109121
}
110122

111-
STATIC void pyb_rtc_callback_disable (mp_obj_t self_in) {
112-
// check the wake from param
113-
if (pybrtc_data.prwmode & PYB_PWR_MODE_ACTIVE) {
114-
// disable the slow clock interrupt
115-
MAP_PRCMIntDisable(PRCM_INT_SLOW_CLK_CTR);
116-
}
117-
// disable wake from ldps and hibernate
118-
pybsleep_configure_timer_wakeup (PYB_PWR_MODE_ACTIVE);
119-
// read the interrupt status to clear any pending interrupt
120-
(void)MAP_PRCMIntStatus();
121-
}
122-
123123
/******************************************************************************/
124124
// Micro Python bindings
125125

cc3200/mods/pybrtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
extern const mp_obj_base_t pyb_rtc_obj;
3535

3636
void pybrtc_init(void);
37+
void pyb_rtc_callback_disable (mp_obj_t self_in);
3738

3839
#endif // PYBRTC_H_

0 commit comments

Comments
 (0)