Merge branch 'master' into fix-micros
This commit is contained in:
6 files changed
+51
-5
No files matched your search
@@ -36,6 +36,7 @@ void setup( void ) ;
|
||||
void loop( void ) ;
|
||||
|
||||
void suspendLoop(void);
|
||||
void resumeLoop(void);
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
|
||||
@@ -182,7 +182,13 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
|
||||
configPRE_SLEEP_PROCESSING( xModifiableIdleTime );
|
||||
if ( xModifiableIdleTime > 0 )
|
||||
{
|
||||
#if 0 // With FreeRTOS sd_app_evt_wait increases power consumption with FreeRTOS compared to _WFE (NRFFOSDK-11174)
|
||||
#if (__FPU_USED == 1)
|
||||
// nRF52832 errata 87: prevent FPU from keeping CPU on
|
||||
// https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/anomaly_832_87.html?cp=4_2_1_0_1_24
|
||||
__set_FPSCR(__get_FPSCR() & ~(0x0000009F));
|
||||
(void) __get_FPSCR();
|
||||
NVIC_ClearPendingIRQ(FPU_IRQn);
|
||||
#endif
|
||||
#ifdef SOFTDEVICE_PRESENT // TODO
|
||||
uint8_t sd_en = 0;
|
||||
(void) sd_softdevice_is_enabled(&sd_en);
|
||||
@@ -193,7 +199,6 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif // (NRFFOSDK-11174)
|
||||
{
|
||||
/* No SD - we would just block interrupts globally.
|
||||
* BASEPRI cannot be used for that because it would prevent WFE from wake up.
|
||||
@@ -227,15 +232,34 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
|
||||
diff = xExpectedIdleTime;
|
||||
}
|
||||
|
||||
if (diff > 0)
|
||||
{
|
||||
vTaskStepTick(diff);
|
||||
// nRF-provided fix for delay() wakeup 1ms spin-loop power waste
|
||||
// See https://devzone.nordicsemi.com/f/nordic-q-a/63828/vtaskdelay-on-nrf52-freertos-port-wastes-cpu-power
|
||||
BaseType_t switch_req = pdFALSE;
|
||||
|
||||
if (diff > 1)
|
||||
{
|
||||
vTaskStepTick(diff - 1);
|
||||
|
||||
// If dwt cycle count is enable, adjust it as welll
|
||||
if ( (CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && (DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk) )
|
||||
{
|
||||
DWT->CYCCNT += ((diff * 1000000) / configTICK_RATE_HZ) * 64;
|
||||
}
|
||||
|
||||
switch_req = xTaskIncrementTick();
|
||||
}
|
||||
else if (diff == 1)
|
||||
{
|
||||
switch_req = xTaskIncrementTick();
|
||||
}
|
||||
|
||||
/* Increment the RTOS tick as usual which checks if there is a need for rescheduling */
|
||||
if ( switch_req != pdFALSE )
|
||||
{
|
||||
/* A context switch is required. Context switching is performed in
|
||||
the PendSV interrupt. Pend the PendSV interrupt. */
|
||||
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
|
||||
__SEV();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,18 @@ void suspendLoop(void)
|
||||
vTaskSuspend(_loopHandle);
|
||||
}
|
||||
|
||||
void resumeLoop(void)
|
||||
{
|
||||
if ( isInISR() )
|
||||
{
|
||||
xTaskResumeFromISR(_loopHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
vTaskResume(_loopHandle);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ void lfs_crc(uint32_t *crc, const void *buffer, size_t size);
|
||||
// Allocate memory, only used if buffers are not provided to littlefs
|
||||
static inline void *lfs_malloc(size_t size) {
|
||||
#ifndef LFS_NO_MALLOC
|
||||
extern void *pvPortMalloc( size_t xWantedSize );
|
||||
return pvPortMalloc(size);
|
||||
#else
|
||||
(void)size;
|
||||
@@ -178,6 +179,7 @@ static inline void *lfs_malloc(size_t size) {
|
||||
// Deallocate memory, only used if buffers are not provided to littlefs
|
||||
static inline void lfs_free(void *p) {
|
||||
#ifndef LFS_NO_MALLOC
|
||||
extern void vPortFree( void *pv );
|
||||
vPortFree(p);
|
||||
#else
|
||||
(void)p;
|
||||
|
||||
@@ -39,6 +39,7 @@ class TwoWire : public Stream
|
||||
void begin(uint8_t);
|
||||
void end();
|
||||
void setClock(uint32_t);
|
||||
void setPins(uint8_t pinSDA, uint8_t pinSCL);
|
||||
|
||||
void beginTransmission(uint8_t);
|
||||
uint8_t endTransmission(bool stopBit);
|
||||
|
||||
@@ -127,6 +127,12 @@ void TwoWire::setClock(uint32_t baudrate) {
|
||||
}
|
||||
}
|
||||
|
||||
void TwoWire::setPins(uint8_t pinSDA, uint8_t pinSCL)
|
||||
{
|
||||
this->_uc_pinSDA = g_ADigitalPinMap[pinSDA];
|
||||
this->_uc_pinSCL = g_ADigitalPinMap[pinSCL];
|
||||
}
|
||||
|
||||
void TwoWire::end() {
|
||||
if (master)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user