Skip to content

Commit 42582bf

Browse files
committed
Merge branch 'master' into esp32
2 parents 975df68 + dee4794 commit 42582bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1003
-299
lines changed

cc3200/application.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ APP_MISC_SRC_C = $(addprefix misc/,\
7777
mpirq.c \
7878
mperror.c \
7979
mpexception.c \
80-
mpsystick.c \
8180
)
8281

8382
APP_MODS_SRC_C = $(addprefix mods/,\

cc3200/hal/cc3200_hal.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ mp_uint_t mp_hal_ticks_ms(void) {
108108
return HAL_tickCount;
109109
}
110110

111+
// The SysTick timer counts down at HAL_FCPU_HZ, so we can use that knowledge
112+
// to grab a microsecond counter.
113+
mp_uint_t mp_hal_ticks_us(void) {
114+
mp_uint_t irq_state = disable_irq();
115+
uint32_t counter = SysTickValueGet();
116+
uint32_t milliseconds = mp_hal_ticks_ms();
117+
enable_irq(irq_state);
118+
119+
uint32_t load = SysTickPeriodGet();
120+
counter = load - counter; // Convert from decrementing to incrementing
121+
return (milliseconds * 1000) + ((counter * 1000) / load);
122+
}
123+
111124
void mp_hal_delay_ms(mp_uint_t delay) {
112125
// only if we are not within interrupt context and interrupts are enabled
113126
if ((HAL_NVIC_INT_CTRL_REG & HAL_VECTACTIVE_MASK) == 0 && query_irq() == IRQ_STATE_ENABLED) {
@@ -211,4 +224,3 @@ static void hal_TickInit (void) {
211224
MAP_SysTickEnable();
212225
}
213226
#endif
214-

cc3200/hal/cc3200_hal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include <stdint.h>
3131
#include <stdbool.h>
3232

33+
#include "hal/utils.h"
34+
#include "hal/systick.h"
35+
3336
/******************************************************************************
3437
DEFINE CONSTANTS
3538
******************************************************************************/
@@ -64,4 +67,7 @@ extern void HAL_SystemDeInit (void);
6467
extern void HAL_IncrementTick(void);
6568
extern void mp_hal_set_interrupt_char (int c);
6669

70+
#define mp_hal_delay_us(usec) UtilsDelay(UTILS_DELAY_US_TO_COUNT(usec))
71+
#define mp_hal_ticks_cpu() (SysTickPeriodGet() - SysTickValueGet())
72+
6773
#endif /* CC3200_LAUNCHXL_HAL_CC3200_HAL_H_ */

cc3200/misc/mpsystick.c

Lines changed: 0 additions & 71 deletions
This file was deleted.

cc3200/mods/modutime.c

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "py/obj.h"
3434
#include "py/smallint.h"
3535
#include "py/mphal.h"
36+
#include "extmod/utime_mphal.h"
3637
#include "timeutils.h"
3738
#include "inc/hw_types.h"
3839
#include "inc/hw_ints.h"
@@ -41,7 +42,6 @@
4142
#include "prcm.h"
4243
#include "systick.h"
4344
#include "pybrtc.h"
44-
#include "mpsystick.h"
4545
#include "mpexception.h"
4646
#include "utils.h"
4747

@@ -143,38 +143,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_ms_obj, time_sleep_ms);
143143
STATIC mp_obj_t time_sleep_us (mp_obj_t usec_in) {
144144
mp_int_t usec = mp_obj_get_int(usec_in);
145145
if (usec > 0) {
146-
UtilsDelay(UTILS_DELAY_US_TO_COUNT(usec));
146+
mp_hal_delay_us(usec);
147147
}
148148
return mp_const_none;
149149
}
150150
STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_us_obj, time_sleep_us);
151151

152-
STATIC mp_obj_t time_ticks_ms(void) {
153-
// We want to "cast" the 32 bit unsigned into a 30-bit small-int
154-
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & MP_SMALL_INT_POSITIVE_MASK);
155-
}
156-
STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_ticks_ms_obj, time_ticks_ms);
157-
158-
STATIC mp_obj_t time_ticks_us(void) {
159-
// We want to "cast" the 32 bit unsigned into a 30-bit small-int
160-
return MP_OBJ_NEW_SMALL_INT(sys_tick_get_microseconds() & MP_SMALL_INT_POSITIVE_MASK);
161-
}
162-
STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_ticks_us_obj, time_ticks_us);
163-
164-
STATIC mp_obj_t time_ticks_cpu(void) {
165-
// We want to "cast" the 32 bit unsigned into a 30-bit small-int
166-
return MP_OBJ_NEW_SMALL_INT((SysTickPeriodGet() - SysTickValueGet()) & MP_SMALL_INT_POSITIVE_MASK);
167-
}
168-
STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_ticks_cpu_obj, time_ticks_cpu);
169-
170-
STATIC mp_obj_t time_ticks_diff(mp_obj_t t0, mp_obj_t t1) {
171-
// We want to "cast" the 32 bit unsigned into a 30-bit small-int
172-
uint32_t start = mp_obj_get_int(t0);
173-
uint32_t end = mp_obj_get_int(t1);
174-
return MP_OBJ_NEW_SMALL_INT((end - start) & MP_SMALL_INT_POSITIVE_MASK);
175-
}
176-
STATIC MP_DEFINE_CONST_FUN_OBJ_2(time_ticks_diff_obj, time_ticks_diff);
177-
178152
STATIC const mp_map_elem_t time_module_globals_table[] = {
179153
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_utime) },
180154

@@ -186,10 +160,11 @@ STATIC const mp_map_elem_t time_module_globals_table[] = {
186160
// MicroPython additions
187161
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep_ms), (mp_obj_t)&time_sleep_ms_obj },
188162
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep_us), (mp_obj_t)&time_sleep_us_obj },
189-
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_ms), (mp_obj_t)&time_ticks_ms_obj },
190-
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_us), (mp_obj_t)&time_ticks_us_obj },
191-
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_cpu), (mp_obj_t)&time_ticks_cpu_obj },
192-
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_diff), (mp_obj_t)&time_ticks_diff_obj },
163+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_ms), (mp_obj_t)&mp_utime_ticks_ms_obj },
164+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_us), (mp_obj_t)&mp_utime_ticks_us_obj },
165+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_cpu), (mp_obj_t)&mp_utime_ticks_cpu_obj },
166+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_add), (mp_obj_t)&mp_utime_ticks_add_obj },
167+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ticks_diff), (mp_obj_t)&mp_utime_ticks_diff_obj },
193168
};
194169

195170
STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table);

cc3200/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
#define MICROPY_PY_UHEAPQ (0)
117117
#define MICROPY_PY_UHASHLIB (0)
118118
#define MICROPY_PY_USELECT (1)
119+
#define MICROPY_PY_UTIME_MP_HAL (1)
119120

120121
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
121122
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)

docs/library/lcd160cr.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Constructors
6969
- "YX" is for the left-side and uses:
7070
``pwr=Pin("Y4")``, ``i2c=I2C("X")``, ``spi=SPI("Y")``
7171

72+
See `this image <http://micropython.org/resources/LCD160CRv10-positions.jpg>`_
73+
for how the display can be connected to the pyboard.
74+
7275
Static methods
7376
--------------
7477

docs/library/machine.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,15 @@ Miscellaneous functions
118118
microseconds. The `pulse_level` argument should be 0 to time a low pulse
119119
or 1 to time a high pulse.
120120

121-
The function first waits while the pin input is different to the `pulse_level`
122-
parameter, then times the duration that the pin is equal to `pulse_level`.
121+
If the current input value of the pin is different to `pulse_level`,
122+
the function first (*) waits until the pin input becomes equal to `pulse_level`,
123+
then (**) times the duration that the pin is equal to `pulse_level`.
123124
If the pin is already equal to `pulse_level` then timing starts straight away.
124125

125-
The function will raise an OSError with ETIMEDOUT if either of the waits is
126-
longer than the given timeout value (which is in microseconds).
126+
The function will return -2 if there was timeout waiting for condition marked
127+
(*) above, and -1 if there was timeout during the main measurement, marked (**)
128+
above. The timeout is the same for both cases and given by `timeout_us` (which
129+
is in microseconds).
127130

128131
.. _machine_constants:
129132

docs/library/pyb.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ Reset related functions
8080

8181
Activate the bootloader without BOOT\* pins.
8282

83+
.. function:: fault_debug(value)
84+
85+
Enable or disable hard-fault debugging. A hard-fault is when there is a fatal
86+
error in the underlying system, like an invalid memory access.
87+
88+
If the `value` argument is `False` then the board will automatically reset if
89+
there is a hard fault.
90+
91+
If `value` is `True` then, when the board has a hard fault, it will print the
92+
registers and the stack trace, and then cycle the LEDs indefinitely.
93+
94+
The default value is disabled, i.e. to automatically reset.
95+
8396
Interrupt related functions
8497
---------------------------
8598

docs/pyboard/tutorial/lcd160cr_skin.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ The LCD160CR skin
33

44
This tutorial shows how to get started using the LCD160CR skin.
55

6-
.. image:: http://micropython.org/resources/LCD160CRv10-persp.jpg
6+
.. image:: http://micropython.org/resources/LCD160CRv10-positions.jpg
77
:alt: LCD160CRv1.0 picture
8-
:width: 640px
8+
:width: 800px
99

1010
For detailed documentation of the driver for the display see the
1111
:mod:`lcd160cr` module.
@@ -16,6 +16,8 @@ Plugging in the display
1616
The display can be plugged directly into a pyboard (all pyboard versions
1717
are supported). You plug the display onto the top of the pyboard either
1818
in the X or Y positions. The display should cover half of the pyboard.
19+
See the picture above for how to achieve this; the left half of the picture
20+
shows the X position, and the right half shows the Y position.
1921

2022
Getting the driver
2123
------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy