Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
8096be08
Commit
8096be08
authored
May 26, 2015
by
Daniel Campora
Browse files
cc3200: Add make_new method to the WDT.
parent
fca34934
Changes
4
Hide whitespace changes
Inline
Side-by-side
cc3200/mods/modpyb.c
View file @
8096be08
...
...
@@ -275,7 +275,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_SPI
),
(
mp_obj_t
)
&
pyb_spi_type
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_UART
),
(
mp_obj_t
)
&
pyb_uart_type
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_Timer
),
(
mp_obj_t
)
&
pyb_timer_type
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_WDT
),
(
mp_obj_t
)
&
pyb_wdt_
obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_WDT
),
(
mp_obj_t
)
&
pyb_wdt_
type
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_Sleep
),
(
mp_obj_t
)
&
pyb_sleep_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_HeartBeat
),
(
mp_obj_t
)
&
pyb_heartbeat_obj
},
...
...
cc3200/mods/pybwdt.c
View file @
8096be08
...
...
@@ -63,6 +63,7 @@ typedef struct {
DECLARE PRIVATE DATA
******************************************************************************/
static
pybwdt_data_t
pybwdt_data
=
{.
servers
=
false
,
.
servers_sleeping
=
false
,
.
simplelink
=
false
,
.
running
=
false
};
STATIC
const
mp_obj_base_t
pyb_wdt_obj
=
{
&
pyb_wdt_type
};
/******************************************************************************
DEFINE PUBLIC FUNCTIONS
...
...
@@ -96,41 +97,44 @@ void pybwdt_sl_alive (void) {
/******************************************************************************/
// Micro Python bindings
/// \function wdt_enable('msec')
/// Enabled the watchdog timer with msec timeout value
STATIC
mp_obj_t
pyb_enable_wdt
(
mp_obj_t
self
,
mp_obj_t
msec_in
)
{
mp_int_t
msec
=
mp_obj_get_int
(
msec_in
);
if
(
msec
<
PYBWDT_MIN_TIMEOUT_MS
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
}
if
(
pybwdt_data
.
running
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
));
/// \function constructor('msec')
/// Enables the watchdog timer with msec timeout value
STATIC
mp_obj_t
pyb_wdt_make_new
(
mp_obj_t
type_in
,
mp_uint_t
n_args
,
mp_uint_t
n_kw
,
const
mp_obj_t
*
args
)
{
// check the arguments
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
1
,
false
);
if
(
n_args
>
0
)
{
mp_int_t
msec
=
mp_obj_get_int
(
args
[
0
]);
if
(
msec
<
PYBWDT_MIN_TIMEOUT_MS
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
}
if
(
pybwdt_data
.
running
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
));
}
// Enable the WDT peripheral clock
MAP_PRCMPeripheralClkEnable
(
PRCM_WDT
,
PRCM_RUN_MODE_CLK
|
PRCM_SLP_MODE_CLK
);
// Unlock to be able to configure the registers
MAP_WatchdogUnlock
(
WDT_BASE
);
#ifdef DEBUG
// make the WDT stall when the debugger stops on a breakpoint
MAP_WatchdogStallEnable
(
WDT_BASE
);
#endif
// set the watchdog timer reload value
// the WDT trigger a system reset after the second timeout
// so, divide by 2 the timeout value received
MAP_WatchdogReloadSet
(
WDT_BASE
,
PYBWDT_MILLISECONDS_TO_TICKS
(
msec
/
2
));
// start the timer. Once it's started, it cannot be disabled.
MAP_WatchdogEnable
(
WDT_BASE
);
pybwdt_data
.
running
=
true
;
}
// Enable the WDT peripheral clock
MAP_PRCMPeripheralClkEnable
(
PRCM_WDT
,
PRCM_RUN_MODE_CLK
|
PRCM_SLP_MODE_CLK
);
// Unlock to be able to configure the registers
MAP_WatchdogUnlock
(
WDT_BASE
);
#ifdef DEBUG
// make the WDT stall when the debugger stops on a breakpoint
MAP_WatchdogStallEnable
(
WDT_BASE
);
#endif
// set the watchdog timer reload value
// the WDT trigger a system reset after the second timeout
// so, divide by 2 the timeout value received
MAP_WatchdogReloadSet
(
WDT_BASE
,
PYBWDT_MILLISECONDS_TO_TICKS
(
msec
/
2
));
// start the timer. Once it's started, it cannot be disabled.
MAP_WatchdogEnable
(
WDT_BASE
);
pybwdt_data
.
running
=
true
;
return
mp_const_none
;
return
(
mp_obj_t
)
&
pyb_wdt_obj
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
pyb_enable_wdt_obj
,
pyb_enable_wdt
);
/// \function wdt_kick()
/// Kicks the watchdog timer
...
...
@@ -141,15 +145,14 @@ STATIC mp_obj_t pyb_kick_wdt(mp_obj_t self) {
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_kick_wdt_obj
,
pyb_kick_wdt
);
STATIC
const
mp_map_elem_t
pybwdt_locals_dict_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_enable
),
(
mp_obj_t
)
&
pyb_enable_wdt_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_kick
),
(
mp_obj_t
)
&
pyb_kick_wdt_obj
},
};
STATIC
MP_DEFINE_CONST_DICT
(
pybwdt_locals_dict
,
pybwdt_locals_dict_table
);
static
const
mp_obj_type_t
pybwdt_type
=
{
const
mp_obj_type_t
pyb
_
wdt_type
=
{
{
&
mp_type_type
},
.
name
=
MP_QSTR_WDT
,
.
make_new
=
pyb_wdt_make_new
,
.
locals_dict
=
(
mp_obj_t
)
&
pybwdt_locals_dict
,
};
const
mp_obj_base_t
pyb_wdt_obj
=
{
&
pybwdt_type
};
cc3200/mods/pybwdt.h
View file @
8096be08
...
...
@@ -29,7 +29,7 @@
#include
"py/obj.h"
extern
const
mp_obj_
bas
e_t
pyb_wdt_
obj
;
extern
const
mp_obj_
typ
e_t
pyb_wdt_
type
;
void
pybwdt_init0
(
void
);
void
pybwdt_kick
(
void
);
...
...
cc3200/qstrdefsport.h
View file @
8096be08
...
...
@@ -275,7 +275,6 @@ Q(WPS_PIN)
// for WDT class
Q
(
WDT
)
Q
(
enable
)
Q
(
kick
)
// for HeartBeat class
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment