You've already forked Core2forAWS-MicroPython
mirror of
https://github.com/m5stack/Core2forAWS-MicroPython.git
synced 2026-05-20 10:30:31 -07:00
docs: Add more documentation for the CC3200 in the pyb module.
This commit is contained in:
+25
-11
@@ -315,8 +315,9 @@ STATIC void pyb_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
|
||||
/// Initialise the timer. Initialisation must give the desired mode
|
||||
/// and an optional timer width
|
||||
///
|
||||
/// tim.init(mode=Timer.ONE_SHOT, width=32) # one shot mode
|
||||
/// tim.init(mode=Timer.PERIODIC) # configure in free running periodic mode
|
||||
/// tim.init(mode=Timer.ONE_SHOT, width=16) # one shot mode splitted into two 16-bit independent timers
|
||||
/// split into two 16-bit independent timers
|
||||
///
|
||||
/// Keyword arguments:
|
||||
///
|
||||
@@ -326,7 +327,7 @@ STATIC void pyb_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
|
||||
STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *tim, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT, },
|
||||
{ MP_QSTR_width, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 32} },
|
||||
{ MP_QSTR_width, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 16} },
|
||||
};
|
||||
|
||||
// parse args
|
||||
@@ -405,7 +406,7 @@ STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);
|
||||
|
||||
/// \method channel(channel, *, freq, polarity, duty_cycle)
|
||||
/// \method channel(channel, *, freq, period, polarity, duty_cycle)
|
||||
/// Initialise the timer channel. Initialization requires at least a frequency param. With no
|
||||
/// extra params given besides the channel id, the channel is returned with the previous configuration
|
||||
/// os 'None', if it hasn't been initialized before.
|
||||
@@ -735,7 +736,7 @@ STATIC mp_obj_t pyb_timer_channel_duty_cycle(mp_uint_t n_args, const mp_obj_t *a
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_channel_duty_cycle_obj, 1, 3, pyb_timer_channel_duty_cycle);
|
||||
|
||||
/// \method callback(handler, value, priority)
|
||||
/// \method callback(handler, priority, value)
|
||||
/// create a callback object associated with the timer channel
|
||||
STATIC mp_obj_t pyb_timer_channel_callback (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
mp_arg_val_t args[mpcallback_INIT_NUM_ARGS];
|
||||
@@ -753,10 +754,21 @@ STATIC mp_obj_t pyb_timer_channel_callback (mp_uint_t n_args, const mp_obj_t *po
|
||||
goto invalid_args;
|
||||
}
|
||||
|
||||
uint32_t _config = (ch->channel == TIMER_B) ? ((ch->timer->config & TIMER_B) >> 8) : (ch->timer->config & TIMER_A);
|
||||
|
||||
// validate and set the value if we are in edge count mode
|
||||
if (_config == TIMER_CFG_A_CAP_COUNT) {
|
||||
uint32_t c_value = args[3].u_int;
|
||||
if (!c_value || c_value > 0xFFFF) {
|
||||
// zero or exceeds the maximum value of a 16-bit timer
|
||||
goto invalid_args;
|
||||
}
|
||||
MAP_TimerMatchSet(ch->timer->timer, ch->channel, c_value);
|
||||
}
|
||||
|
||||
// disable the callback first
|
||||
pyb_timer_channel_callback_disable(ch);
|
||||
|
||||
uint32_t _config = (ch->channel == TIMER_B) ? ((ch->timer->config & TIMER_B) >> 8) : (ch->timer->config & TIMER_A);
|
||||
uint8_t shift = (ch->channel == TIMER_B) ? 8 : 0;
|
||||
switch (_config) {
|
||||
case TIMER_CFG_A_ONE_SHOT:
|
||||
@@ -778,13 +790,9 @@ STATIC mp_obj_t pyb_timer_channel_callback (mp_uint_t n_args, const mp_obj_t *po
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// special case for a 32-bit timer
|
||||
if (ch->channel == (TIMER_A | TIMER_B)) {
|
||||
// again a special case for the pwm match interrupt
|
||||
if (_config == TIMER_CFG_A_PWM) {
|
||||
ch->timer->intflags |= TIMER_TIMB_MATCH;
|
||||
} else {
|
||||
ch->timer->intflags |= (ch->timer->intflags << 8);
|
||||
}
|
||||
ch->timer->intflags |= (ch->timer->intflags << 8);
|
||||
}
|
||||
|
||||
void (*pfnHandler)(void);
|
||||
@@ -835,6 +843,12 @@ STATIC mp_obj_t pyb_timer_channel_callback (mp_uint_t n_args, const mp_obj_t *po
|
||||
// create the callback
|
||||
_callback = mpcallback_new (ch, args[1].u_obj, &pyb_timer_channel_cb_methods);
|
||||
|
||||
// reload the timer
|
||||
uint32_t period_c;
|
||||
uint32_t match;
|
||||
compute_prescaler_period_and_match_value(ch, &period_c, &match);
|
||||
MAP_TimerLoadSet(ch->timer->timer, ch->channel, period_c);
|
||||
|
||||
// enable the callback before returning
|
||||
pyb_timer_channel_callback_enable(ch);
|
||||
}
|
||||
|
||||
@@ -262,9 +262,9 @@ Methods
|
||||
Return a 5-tuple with the configuration of the pin:
|
||||
``(name, alternate-function, mode, type, strength)``
|
||||
|
||||
.. method:: pin.callback(mode, priority=1, handler=None, wakes=pyb.Sleep.ACTIVE)
|
||||
.. method:: pin.callback(\*, mode, priority=1, handler=None, wakes=pyb.Sleep.ACTIVE)
|
||||
|
||||
Create a callback to be triggered when data is received on the UART.
|
||||
Create a callback to be triggered when the input level at the pin changes.
|
||||
|
||||
- ``mode`` configures the pin level which can generate an interrupt. Possible values are:
|
||||
|
||||
@@ -286,8 +286,8 @@ Methods
|
||||
of this pins can be enabled as a wake source at the same time, so, only
|
||||
the last enabled pin as a ``pyb.Sleep.SUSPENDED`` wake source will have effect.
|
||||
- If ``wakes=pyb.Sleep.SUSPENDED`` pins ``GPIO2``, ``GPIO4``, ``GPIO10``,
|
||||
``GPIO11``, GPIO17`` and ``GPIO24`` can wake the board. In this case all this 6
|
||||
pins can be enabled as a ``pyb.Sleep.HIBERNATE`` wake source at the same time.
|
||||
``GPIO11``, ``GPIO17`` and ``GPIO24`` can wake the board. In this case all of the
|
||||
6 pins can be enabled as a ``pyb.Sleep.HIBERNATE`` wake source at the same time.
|
||||
- Values can be ORed to make a pin generate interrupts in more than one power
|
||||
mode.
|
||||
|
||||
|
||||
@@ -32,13 +32,23 @@ Methods
|
||||
date and time. With 1 argument (being an 8-tuple) it sets the date
|
||||
and time.
|
||||
|
||||
The 8-tuple has the following format:
|
||||
.. only:: port_pyboard
|
||||
|
||||
(year, month, day, weekday, hours, minutes, seconds, subseconds)
|
||||
The 8-tuple has the following format:
|
||||
|
||||
(year, month, day, weekday, hours, minutes, seconds, subseconds)
|
||||
|
||||
``weekday`` is 1-7 for Monday through Sunday.
|
||||
|
||||
``subseconds`` counts down from 255 to 0
|
||||
|
||||
.. only:: port_wipy
|
||||
|
||||
``weekday`` is 1-7 for Monday through Sunday.
|
||||
|
||||
``subseconds`` counts down from 255 to 0
|
||||
The 8-tuple has the following format:
|
||||
|
||||
``(year, month, day, weekday, hours, minutes, seconds, milliseconds)``
|
||||
|
||||
``weekday`` is 0-6 for Monday through Sunday.
|
||||
|
||||
.. only:: port_pyboard
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Example usage::
|
||||
|
||||
# data, clk and cmd pins must be passed along with
|
||||
# their respective alternate functions
|
||||
sd = pyb.SD('GPIO15', 8, 'GPIO16', 8, 'GPIO17', 8)
|
||||
sd = pyb.SD('GPIO15', 8, 'GPIO10', 6, 'GPIO11', 6)
|
||||
sd.enable() # enable and mount the SD card
|
||||
sd.disable() # disable and unmount it
|
||||
|
||||
|
||||
+368
-187
File diff suppressed because it is too large
Load Diff
@@ -247,7 +247,7 @@ Miscellaneous functions
|
||||
|
||||
.. function:: repl_uart(uart)
|
||||
|
||||
Get or set the UART object that the REPL is repeated on.
|
||||
Get or set the UART object where the REPL is repeated on.
|
||||
|
||||
.. only:: port_pyboard
|
||||
|
||||
@@ -269,13 +269,13 @@ Miscellaneous functions
|
||||
|
||||
.. function:: unique_id()
|
||||
|
||||
Returns a string of 12 bytes (96 bits), which is the unique ID for the MCU.
|
||||
Returns a string of 12 bytes (96 bits), which is the unique ID of the MCU.
|
||||
|
||||
.. only:: port_wipy
|
||||
|
||||
.. function:: unique_id()
|
||||
|
||||
Returns a string of 6 bytes (48 bits), which is the unique ID for the MCU.
|
||||
Returns a string of 6 bytes (48 bits), which is the unique ID of the MCU.
|
||||
This also corresponds to the ``MAC address`` of the WiPy.
|
||||
|
||||
Classes
|
||||
|
||||
@@ -43,7 +43,7 @@ Constructors
|
||||
:class: attention
|
||||
|
||||
Due to hardware implementation details of the WiPy, data must be buffered before being
|
||||
digested, which would make impossible to calculate the hash of big blocks of data that
|
||||
digested, which would make it impossible to calculate the hash of big blocks of data that
|
||||
do not fit in RAM. In this case, since most likely the total size of the data is known
|
||||
in advance, the size can be passed to the constructor and hence the HASH hardware engine
|
||||
of the WiPy can be properly initialized without needing buffering. If ``block_size`` is
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
.. only:: port_pyboard
|
||||
|
||||
.. _quickref:
|
||||
.. _quickref:
|
||||
|
||||
Quick reference for the pyboard
|
||||
===============================
|
||||
|
||||
@@ -35,12 +35,12 @@ If you power up normally, or press the reset button, the WiPy will boot
|
||||
into standard mode: the ``boot.py`` file will be executed first, then
|
||||
``main.py`` will run.
|
||||
|
||||
You can override this boot sequence by pulling ``GPIO28`` **up** during reset.
|
||||
The heart beat LED will flash slowly 3 times to signal that safe boot is being
|
||||
requested, and then 3 more times quickly to let you know that safe boot is
|
||||
going to be performed. While safe booting, the WiPy runs the factory firmware
|
||||
and skips the execution of ``boot.py`` and ``main.py``. This is useful to
|
||||
recover from any crash situation.
|
||||
You can override this boot sequence by pulling ``GPIO28`` **up** (connect
|
||||
it to the 3v3 output pin) during reset. The heart beat LED will flash slowly
|
||||
3 times to signal that safe boot is being requested, and then 3 more times
|
||||
quickly to let you know that safe boot is going to be performed. While safe
|
||||
booting, the WiPy runs the factory firmware and skips the execution of
|
||||
``boot.py`` and ``main.py``. This is useful to recover from any crash situation.
|
||||
|
||||
The heart beat LED
|
||||
------------------
|
||||
|
||||
+8
-10
@@ -1,6 +1,4 @@
|
||||
.. only:: port_wipy
|
||||
|
||||
.. _quickref_:
|
||||
.. _quickref_:
|
||||
|
||||
Quick reference for the WiPy
|
||||
============================
|
||||
@@ -20,7 +18,7 @@ See :mod:`pyb`. ::
|
||||
pyb.delay(50) # wait 50 milliseconds
|
||||
pyb.millis() # number of milliseconds since boot-up
|
||||
pyb.freq() # get the CPU frequency
|
||||
pyb.unique_id() # return the 6-byte unique id of the board (it's MAC address)
|
||||
pyb.unique_id() # return the 6-byte unique id of the board (the WiPy's MAC address)
|
||||
|
||||
Pins and GPIO
|
||||
-------------
|
||||
@@ -176,7 +174,7 @@ See :ref:`pyb.SD <pyb.SD>`. ::
|
||||
|
||||
# SD card pins need special configuration so we pass 'em to the constructor
|
||||
# data pin, data af, clock pin, clock af, cmd pin, cmd af
|
||||
sd = SD('GPIO15', 8, 'GPIO16', 8, 'GPIO17', 8)
|
||||
sd = pyb.SD('GPIO15', 8, 'GPIO10', 6, 'GPIO11', 6)
|
||||
sd.enable()
|
||||
|
||||
WLAN (WiFi)
|
||||
@@ -213,16 +211,16 @@ See ``pyb.Sleep``. ::
|
||||
Sleep.suspend() # everything except for WLAN is powered down (~950uA)
|
||||
# wakes from Pin, RTC or WLAN
|
||||
|
||||
Sleep.hibernate() # deepest sleep mode, mcu starts from reset. Wakes from Pin and RTC.
|
||||
Sleep.hibernate() # deepest sleep mode, MCU starts from reset. Wakes from Pin and RTC.
|
||||
|
||||
Heart beat LED
|
||||
-----------------------------
|
||||
--------------
|
||||
|
||||
See :ref:`pyb.HeartBeat <pyb.HeartBeat>`. ::
|
||||
|
||||
from pyb import HeartBeat
|
||||
|
||||
# disable the heart beat indication (you are free to use this led connected to GPIO25)
|
||||
HeartBeat.disable()
|
||||
# disable the heart beat indication (you are free to use this LED connected to GPIO25)
|
||||
HeartBeat().disable()
|
||||
# enable the heart beat again
|
||||
HeartBeat.enable()
|
||||
HeartBeat().enable()
|
||||
|
||||
Reference in New Issue
Block a user