<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/ports/nrf/supervisor/port.c, branch encoding</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=encoding</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=encoding'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2020-07-15T14:26:47+00:00</updated>
<entry>
<title>nRF: Always use sd_nvic_critical_region calls</title>
<updated>2020-07-15T14:26:47+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2020-07-14T22:34:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=dc74ae83da6f519a36d75388b5be9923a10bf063'/>
<id>urn:sha1:dc74ae83da6f519a36d75388b5be9923a10bf063</id>
<content type='text'>
The motivation for doing this is so that we can allow
common_hal_mcu_disable_interrupts in IRQ context, something that works
on other ports, but not on nRF with SD enabled.  This is because
when SD is enabled, calling sd_softdevice_is_enabled in the context
of an interrupt with priority 2 or 3 causes a HardFault.  We have chosen
to give the USB interrupt priority 2 on nRF, the highest priority that
is compatible with SD.

Since at least SoftDevice s130 v2.0.1, sd_nvic_critical_region_enter/exit
have been implemented as inline functions and are safe to call even if
softdevice is not enabled.  Reference kindly provided by danh:
 https://devzone.nordicsemi.com/f/nordic-q-a/29553/sd_nvic_critical_region_enter-exit-missing-in-s130-v2

Switching to these as the default/only way to enable/disable interrupts
simplifies things, and fixes several problems and potential problems:
 * Interrupts at priority 2 or 3 could not call common_hal_mcu_disable_interrupts
   because the call to sd_softdevice_is_enabled would HardFault
 * Hypothetically, the state of sd_softdevice_is_enabled
   could change from the disable to the enable call, meaning the calls
   would not match (__disable_irq() could be balanced with
   sd_nvic_critical_region_exit).

This also fixes a problem I believe would exist if disable() were called
twice when SD is enabled.  There is a single "is_nested_critical_region"
flag, and the second call would set it to 1.  Both of the enable()
calls that followed would call critical_region_exit(1), and interrupts
would not properly be reenabled.  In the new version of the code,
we use our own nesting_count value to track the intended state, so
now nested disable()s only call critical_region_enter() once, only
updating is_nested_critical_region once; and only the second enable()
call will call critical_region_exit, with the right value of i_n_c_r.

Finally, in port_sleep_until_interrupt, if !sd_enabled, we really do
need to __disable_irq, rather than using the common_hal_mcu routines;
the reason why is documented in a comment.
</content>
</entry>
<entry>
<title>nrf: add ticks (not subticks) to overflow count during reset</title>
<updated>2020-05-27T03:28:50+00:00</updated>
<author>
<name>Sean Cross</name>
<email>sean@xobs.io</email>
</author>
<published>2020-05-23T03:26:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=e470376c126828c768dfbcf25430869e8bc2b021'/>
<id>urn:sha1:e470376c126828c768dfbcf25430869e8bc2b021</id>
<content type='text'>
Signed-off-by: Sean Cross &lt;sean@xobs.io&gt;
</content>
</entry>
<entry>
<title>nrf: port: save rtc value across reboots</title>
<updated>2020-05-27T03:28:49+00:00</updated>
<author>
<name>Sean Cross</name>
<email>sean@xobs.io</email>
</author>
<published>2020-05-22T11:36:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=daf7c2857da3f0cc61f20474bdd1ce2824cb409c'/>
<id>urn:sha1:daf7c2857da3f0cc61f20474bdd1ce2824cb409c</id>
<content type='text'>
As part of the reset process, save the current tick count to an
uninitialized memory location.  That way, the current tick value will be
preserved across reboots.

A reboot will cause us to lose a certain number of ticks, depending on
how long a reboot takes, however if reboots are infrequent then this
will not be a large amount of time lost.

Signed-off-by: Sean Cross &lt;sean@xobs.io&gt;
</content>
</entry>
<entry>
<title>nrf: reset watchdog as part of port_reset()</title>
<updated>2020-05-27T03:28:49+00:00</updated>
<author>
<name>Sean Cross</name>
<email>sean@xobs.io</email>
</author>
<published>2020-05-22T10:51:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=c5c13a8ba14490c94fd7409bae0183e59b5767f4'/>
<id>urn:sha1:c5c13a8ba14490c94fd7409bae0183e59b5767f4</id>
<content type='text'>
Signed-off-by: Sean Cross &lt;sean@xobs.io&gt;
</content>
</entry>
<entry>
<title>nrf: boot into safe mode sometimes for watchdog reset</title>
<updated>2020-05-27T03:28:49+00:00</updated>
<author>
<name>Sean Cross</name>
<email>sean@xobs.io</email>
</author>
<published>2020-05-22T04:56:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=e738f5eaa13c0e30dc082c511d9659c5f35e7f7e'/>
<id>urn:sha1:e738f5eaa13c0e30dc082c511d9659c5f35e7f7e</id>
<content type='text'>
If the watchdog resets the system and we're plugged into USB, boot into
safe mode.

Signed-off-by: Sean Cross &lt;sean@xobs.io&gt;
</content>
</entry>
<entry>
<title>nrf: port: add memory barrier before wfi</title>
<updated>2020-05-21T13:46:37+00:00</updated>
<author>
<name>Sean Cross</name>
<email>sean@xobs.io</email>
</author>
<published>2020-05-21T13:46:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=fd4ef233c6d9b312c3582466c68390a16ddf15fa'/>
<id>urn:sha1:fd4ef233c6d9b312c3582466c68390a16ddf15fa</id>
<content type='text'>
ARM recommends issuing a DSB instruction propr to issuing WFI, as it is
required on many parts suchas Cortex-M7. This is effectively a no-op on
the Cortex-M4 used in most NRF parts, however it ensures that we won't
be surprised when new parts come out.

See
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHICBGB.html
for more information.

Signed-off-by: Sean Cross &lt;sean@xobs.io&gt;
</content>
</entry>
<entry>
<title>nrf: disable interrupts before running wfi</title>
<updated>2020-05-21T13:43:52+00:00</updated>
<author>
<name>Sean Cross</name>
<email>sean@xobs.io</email>
</author>
<published>2020-05-08T04:38:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=77cf4dce8f1ae03edbe275cb82e250daeba8990f'/>
<id>urn:sha1:77cf4dce8f1ae03edbe275cb82e250daeba8990f</id>
<content type='text'>
In order to ensure we don't have any outstanding requests, disable
interrupts prior to issuing `WFI`.

As part of this process, check to see if there are any pending USB
requests, and only execute the `WFI` if there is no pending data.

This fixes #2855 on NRF.

Signed-off-by: Sean Cross &lt;sean@xobs.io&gt;
</content>
</entry>
<entry>
<title>Merge pull request #2932 from simmel-project/nrf-rtc-reset</title>
<updated>2020-05-20T18:39:16+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@adafruit.com</email>
</author>
<published>2020-05-20T18:39:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=c32214ccc7f9ede8b04c74043d2aed341e0e9b8b'/>
<id>urn:sha1:c32214ccc7f9ede8b04c74043d2aed341e0e9b8b</id>
<content type='text'>
nrf: reset rtc as part of port_reset()</content>
</entry>
<entry>
<title>nrf: reset rtc as part of port_reset()</title>
<updated>2020-05-20T08:44:18+00:00</updated>
<author>
<name>Sean Cross</name>
<email>sean@xobs.io</email>
</author>
<published>2020-05-20T08:44:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=4cca455c9b5651d7b846b9e1a8b49ea81adc8cd7'/>
<id>urn:sha1:4cca455c9b5651d7b846b9e1a8b49ea81adc8cd7</id>
<content type='text'>
On NRF, the `rtc_reset()` function is never called.  As a result,
calls to `time.time()` return a cryptic error&gt;

```
&gt;&gt;&gt; import time
&gt;&gt;&gt; time.time()
'' object has no attribute 'datetime'
&gt;&gt;&gt;
```

This is because `MP_STATE_VM(rtc_time_source)` is not initialized
due to `rtc_reset()` never being called.

If `CIRCUITPY_RTC` is enabled, call `rtc_reset()` as part of the
`reset_port()` call. This ensures that `time.time()` works as expected.

Signed-off-by: Sean Cross &lt;sean@xobs.io&gt;
</content>
</entry>
<entry>
<title>Merge remote-tracking branch 'adafruit/master' into esp32s2</title>
<updated>2020-05-18T23:46:41+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2020-05-18T23:46:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=cf690bd390bf5e970bdc0712063c8ea32d3b6b5a'/>
<id>urn:sha1:cf690bd390bf5e970bdc0712063c8ea32d3b6b5a</id>
<content type='text'>
</content>
</entry>
</feed>
