Skip to content

Commit ea2cc2b

Browse files
author
Daniel Campora
committed
docs: Add more documentation for the CC3200 in the pyb module.
1 parent cdfa11f commit ea2cc2b

File tree

10 files changed

+441
-240
lines changed

10 files changed

+441
-240
lines changed

cc3200/mods/pybtimer.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ STATIC void pyb_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
315315
/// Initialise the timer. Initialisation must give the desired mode
316316
/// and an optional timer width
317317
///
318+
/// tim.init(mode=Timer.ONE_SHOT, width=32) # one shot mode
318319
/// tim.init(mode=Timer.PERIODIC) # configure in free running periodic mode
319-
/// tim.init(mode=Timer.ONE_SHOT, width=16) # one shot mode splitted into two 16-bit independent timers
320+
/// split into two 16-bit independent timers
320321
///
321322
/// Keyword arguments:
322323
///
@@ -326,7 +327,7 @@ STATIC void pyb_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
326327
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) {
327328
static const mp_arg_t allowed_args[] = {
328329
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT, },
329-
{ MP_QSTR_width, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 32} },
330+
{ MP_QSTR_width, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 16} },
330331
};
331332

332333
// parse args
@@ -405,7 +406,7 @@ STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in) {
405406
}
406407
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);
407408

408-
/// \method channel(channel, *, freq, polarity, duty_cycle)
409+
/// \method channel(channel, *, freq, period, polarity, duty_cycle)
409410
/// Initialise the timer channel. Initialization requires at least a frequency param. With no
410411
/// extra params given besides the channel id, the channel is returned with the previous configuration
411412
/// 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
735736
}
736737
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_channel_duty_cycle_obj, 1, 3, pyb_timer_channel_duty_cycle);
737738

738-
/// \method callback(handler, value, priority)
739+
/// \method callback(handler, priority, value)
739740
/// create a callback object associated with the timer channel
740741
STATIC mp_obj_t pyb_timer_channel_callback (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
741742
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
753754
goto invalid_args;
754755
}
755756

757+
uint32_t _config = (ch->channel == TIMER_B) ? ((ch->timer->config & TIMER_B) >> 8) : (ch->timer->config & TIMER_A);
758+
759+
// validate and set the value if we are in edge count mode
760+
if (_config == TIMER_CFG_A_CAP_COUNT) {
761+
uint32_t c_value = args[3].u_int;
762+
if (!c_value || c_value > 0xFFFF) {
763+
// zero or exceeds the maximum value of a 16-bit timer
764+
goto invalid_args;
765+
}
766+
MAP_TimerMatchSet(ch->timer->timer, ch->channel, c_value);
767+
}
768+
756769
// disable the callback first
757770
pyb_timer_channel_callback_disable(ch);
758771

759-
uint32_t _config = (ch->channel == TIMER_B) ? ((ch->timer->config & TIMER_B) >> 8) : (ch->timer->config & TIMER_A);
760772
uint8_t shift = (ch->channel == TIMER_B) ? 8 : 0;
761773
switch (_config) {
762774
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
778790
default:
779791
break;
780792
}
793+
// special case for a 32-bit timer
781794
if (ch->channel == (TIMER_A | TIMER_B)) {
782-
// again a special case for the pwm match interrupt
783-
if (_config == TIMER_CFG_A_PWM) {
784-
ch->timer->intflags |= TIMER_TIMB_MATCH;
785-
} else {
786-
ch->timer->intflags |= (ch->timer->intflags << 8);
787-
}
795+
ch->timer->intflags |= (ch->timer->intflags << 8);
788796
}
789797

790798
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
835843
// create the callback
836844
_callback = mpcallback_new (ch, args[1].u_obj, &pyb_timer_channel_cb_methods);
837845

846+
// reload the timer
847+
uint32_t period_c;
848+
uint32_t match;
849+
compute_prescaler_period_and_match_value(ch, &period_c, &match);
850+
MAP_TimerLoadSet(ch->timer->timer, ch->channel, period_c);
851+
838852
// enable the callback before returning
839853
pyb_timer_channel_callback_enable(ch);
840854
}

docs/library/pyb.Pin.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ Methods
262262
Return a 5-tuple with the configuration of the pin:
263263
``(name, alternate-function, mode, type, strength)``
264264

265-
.. method:: pin.callback(mode, priority=1, handler=None, wakes=pyb.Sleep.ACTIVE)
265+
.. method:: pin.callback(\*, mode, priority=1, handler=None, wakes=pyb.Sleep.ACTIVE)
266266

267-
Create a callback to be triggered when data is received on the UART.
267+
Create a callback to be triggered when the input level at the pin changes.
268268

269269
- ``mode`` configures the pin level which can generate an interrupt. Possible values are:
270270

@@ -286,8 +286,8 @@ Methods
286286
of this pins can be enabled as a wake source at the same time, so, only
287287
the last enabled pin as a ``pyb.Sleep.SUSPENDED`` wake source will have effect.
288288
- If ``wakes=pyb.Sleep.SUSPENDED`` pins ``GPIO2``, ``GPIO4``, ``GPIO10``,
289-
``GPIO11``, GPIO17`` and ``GPIO24`` can wake the board. In this case all this 6
290-
pins can be enabled as a ``pyb.Sleep.HIBERNATE`` wake source at the same time.
289+
``GPIO11``, ``GPIO17`` and ``GPIO24`` can wake the board. In this case all of the
290+
6 pins can be enabled as a ``pyb.Sleep.HIBERNATE`` wake source at the same time.
291291
- Values can be ORed to make a pin generate interrupts in more than one power
292292
mode.
293293

docs/library/pyb.RTC.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ Methods
3232
date and time. With 1 argument (being an 8-tuple) it sets the date
3333
and time.
3434

35-
The 8-tuple has the following format:
35+
.. only:: port_pyboard
3636

37-
(year, month, day, weekday, hours, minutes, seconds, subseconds)
38-
39-
``weekday`` is 1-7 for Monday through Sunday.
37+
The 8-tuple has the following format:
38+
39+
(year, month, day, weekday, hours, minutes, seconds, subseconds)
40+
41+
``weekday`` is 1-7 for Monday through Sunday.
42+
43+
``subseconds`` counts down from 255 to 0
44+
45+
.. only:: port_wipy
4046

41-
``subseconds`` counts down from 255 to 0
47+
The 8-tuple has the following format:
48+
49+
``(year, month, day, weekday, hours, minutes, seconds, milliseconds)``
50+
51+
``weekday`` is 0-6 for Monday through Sunday.
4252

4353
.. only:: port_pyboard
4454

docs/library/pyb.SD.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Example usage::
1515

1616
# data, clk and cmd pins must be passed along with
1717
# their respective alternate functions
18-
sd = pyb.SD('GPIO15', 8, 'GPIO16', 8, 'GPIO17', 8)
18+
sd = pyb.SD('GPIO15', 8, 'GPIO10', 6, 'GPIO11', 6)
1919
sd.enable() # enable and mount the SD card
2020
sd.disable() # disable and unmount it
2121

0 commit comments

Comments
 (0)