Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
41f69485
Commit
41f69485
authored
Sep 13, 2015
by
Daniel Campora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cc3200: New WDT API.
parent
8332044f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
49 deletions
+97
-49
cc3200/mods/pybwdt.c
cc3200/mods/pybwdt.c
+42
-38
cc3200/qstrdefsport.h
cc3200/qstrdefsport.h
+2
-1
docs/library/pyb.WDT.rst
docs/library/pyb.WDT.rst
+9
-10
tests/wipy/wdt.py
tests/wipy/wdt.py
+37
-0
tests/wipy/wdt.py.exp
tests/wipy/wdt.py.exp
+7
-0
No files found.
cc3200/mods/pybwdt.c
View file @
41f69485
...
@@ -88,48 +88,52 @@ void pybwdt_sl_alive (void) {
...
@@ -88,48 +88,52 @@ void pybwdt_sl_alive (void) {
/******************************************************************************/
/******************************************************************************/
// Micro Python bindings
// Micro Python bindings
/// \function constructor('msec')
STATIC
const
mp_arg_t
pyb_wdt_init_args
[]
=
{
/// Enables the watchdog timer with msec timeout value
{
MP_QSTR_id
,
MP_ARG_OBJ
,
{.
u_obj
=
mp_const_none
}
},
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
)
{
{
MP_QSTR_timeout
,
MP_ARG_INT
,
{.
u_int
=
5000
}
},
// 5 s
};
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
*
all_args
)
{
// check the arguments
// check the arguments
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
1
,
false
);
mp_map_t
kw_args
;
mp_map_init_fixed_table
(
&
kw_args
,
n_kw
,
all_args
+
n_args
);
if
(
n_args
>
0
)
{
mp_arg_val_t
args
[
MP_ARRAY_SIZE
(
pyb_wdt_init_args
)];
mp_int_t
msec
=
mp_obj_get_int
(
args
[
0
]);
mp_arg_parse_all
(
n_args
,
all_args
,
&
kw_args
,
MP_ARRAY_SIZE
(
args
),
pyb_wdt_init_args
,
args
);
if
(
msec
<
PYBWDT_MIN_TIMEOUT_MS
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
if
(
args
[
0
].
u_obj
!=
mp_const_none
&&
mp_obj_get_int
(
args
[
0
].
u_obj
)
>
0
)
{
}
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_OSError
,
mpexception_os_resource_not_avaliable
));
if
(
pybwdt_data
.
running
)
{
}
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_OSError
,
mpexception_os_request_not_possible
));
uint
timeout_ms
=
args
[
1
].
u_int
;
}
if
(
timeout_ms
<
PYBWDT_MIN_TIMEOUT_MS
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
mpexception_value_invalid_arguments
));
// 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
;
}
}
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
(
timeout_ms
/
2
));
// start the timer. Once it's started, it cannot be disabled.
MAP_WatchdogEnable
(
WDT_BASE
);
pybwdt_data
.
running
=
true
;
return
(
mp_obj_t
)
&
pyb_wdt_obj
;
return
(
mp_obj_t
)
&
pyb_wdt_obj
;
}
}
/// \function wdt.kick()
STATIC
mp_obj_t
pyb_wdt_feed
(
mp_obj_t
self
)
{
/// Kicks the watchdog timer
STATIC
mp_obj_t
pyb_wdt_kick
(
mp_obj_t
self
)
{
if
((
pybwdt_data
.
servers
||
pybwdt_data
.
servers_sleeping
)
&&
pybwdt_data
.
simplelink
&&
pybwdt_data
.
running
)
{
if
((
pybwdt_data
.
servers
||
pybwdt_data
.
servers_sleeping
)
&&
pybwdt_data
.
simplelink
&&
pybwdt_data
.
running
)
{
pybwdt_data
.
servers
=
false
;
pybwdt_data
.
servers
=
false
;
pybwdt_data
.
simplelink
=
false
;
pybwdt_data
.
simplelink
=
false
;
...
@@ -137,10 +141,10 @@ STATIC mp_obj_t pyb_wdt_kick(mp_obj_t self) {
...
@@ -137,10 +141,10 @@ STATIC mp_obj_t pyb_wdt_kick(mp_obj_t self) {
}
}
return
mp_const_none
;
return
mp_const_none
;
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_wdt_
kick_obj
,
pyb_wdt_kick
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_wdt_
feed_obj
,
pyb_wdt_feed
);
STATIC
const
mp_map_elem_t
pybwdt_locals_dict_table
[]
=
{
STATIC
const
mp_map_elem_t
pybwdt_locals_dict_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_
kick
),
(
mp_obj_t
)
&
pyb_wdt_kick
_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_
feed
),
(
mp_obj_t
)
&
pyb_wdt_feed
_obj
},
};
};
STATIC
MP_DEFINE_CONST_DICT
(
pybwdt_locals_dict
,
pybwdt_locals_dict_table
);
STATIC
MP_DEFINE_CONST_DICT
(
pybwdt_locals_dict
,
pybwdt_locals_dict_table
);
...
...
cc3200/qstrdefsport.h
View file @
41f69485
...
@@ -299,7 +299,8 @@ Q(EXTERNAL)
...
@@ -299,7 +299,8 @@ Q(EXTERNAL)
// for WDT class
// for WDT class
Q
(
WDT
)
Q
(
WDT
)
Q
(
kick
)
Q
(
feed
)
Q
(
timeout
)
// for HeartBeat class
// for HeartBeat class
Q
(
HeartBeat
)
Q
(
HeartBeat
)
...
...
docs/library/pyb.WDT.rst
View file @
41f69485
...
@@ -10,24 +10,23 @@ watchdog periodically to prevent it from expiring and resetting the system.
...
@@ -10,24 +10,23 @@ watchdog periodically to prevent it from expiring and resetting the system.
Example usage::
Example usage::
wdt = pyb.WDT(
5000) # enable with a timeout of 5
s
wdt = pyb.WDT(
timeout=2000) # enable with a timeout of 2
s
wdt.
kick
()
wdt.
feed
()
Constructors
Constructors
------------
------------
.. class:: pyb.WDT(
[timeout]
)
.. class:: pyb.WDT(
id=0, timeout=5000
)
Create a WDT object. If the timeout is specified the WDT is started.
Create a WDT object and start it. The timeout must be given in seconds and
The timeout must be given in seconds and 1s the minimum value that
the minimum value that is accepted is 1 second. Once it is running the timeout
is accepted. Once it is running the timeout cannot be changed and
cannot be changed and the WDT cannot be stopped either.
the WDT cannot be stopped either.
Methods
Methods
-------
-------
.. method:: wdt.
kick
()
.. method:: wdt.
feed
()
Kick
the WDT to prevent it from resetting the system. The application
Feed
the WDT to prevent it from resetting the system. The application
should place this call in a sensible place ensuring that the WDT is
should place this call in a sensible place ensuring that the WDT is
only
kick
ed after verifying that everything is functioning correctly.
only
f
ed after verifying that everything is functioning correctly.
tests/wipy/wdt.py
0 → 100644
View file @
41f69485
'''
WDT test for the CC3200 based boards
'''
from
pyb
import
WDT
# test the invalid cases first
try
:
wdt
=
WDT
(
1
)
except
Exception
:
print
(
"Exception"
)
try
:
wdt
=
WDT
(
0
,
500
)
except
Exception
:
print
(
"Exception"
)
try
:
wdt
=
WDT
(
1
,
timeout
=
2000
)
except
Exception
:
print
(
"Exception"
)
wdt
=
WDT
(
timeout
=
1000
)
print
(
wdt
)
try
:
wdt
=
WDT
(
0
,
timeout
=
2000
)
except
Exception
:
print
(
"Exception"
)
pyb
.
delay
(
500
)
wdt
.
feed
()
print
(
wdt
)
pyb
.
delay
(
900
)
wdt
.
feed
()
print
(
wdt
)
pyb
.
delay
(
950
)
tests/wipy/wdt.py.exp
0 → 100644
View file @
41f69485
Exception
Exception
Exception
<WDT>
Exception
<WDT>
<WDT>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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