Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
8096be08
Commit
8096be08
authored
9 years ago
by
Daniel Campora
Browse files
Options
Downloads
Patches
Plain Diff
cc3200: Add make_new method to the WDT.
parent
fca34934
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cc3200/mods/modpyb.c
+1
-1
1 addition, 1 deletion
cc3200/mods/modpyb.c
cc3200/mods/pybwdt.c
+38
-35
38 additions, 35 deletions
cc3200/mods/pybwdt.c
cc3200/mods/pybwdt.h
+1
-1
1 addition, 1 deletion
cc3200/mods/pybwdt.h
cc3200/qstrdefsport.h
+0
-1
0 additions, 1 deletion
cc3200/qstrdefsport.h
with
40 additions
and
38 deletions
cc3200/mods/modpyb.c
+
1
−
1
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
},
...
...
This diff is collapsed.
Click to expand it.
cc3200/mods/pybwdt.c
+
38
−
35
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
};
This diff is collapsed.
Click to expand it.
cc3200/mods/pybwdt.h
+
1
−
1
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
);
...
...
This diff is collapsed.
Click to expand it.
cc3200/qstrdefsport.h
+
0
−
1
View file @
8096be08
...
...
@@ -275,7 +275,6 @@ Q(WPS_PIN)
// for WDT class
Q
(
WDT
)
Q
(
enable
)
Q
(
kick
)
// for HeartBeat class
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment