Spawn PD earlier
This commit is contained in:
@@ -11,11 +11,4 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
// Initialisation to be performed with scheduler active
|
// Initialisation to be performed with scheduler active
|
||||||
void postRToSInit() {
|
void postRToSInit() {}
|
||||||
#ifdef POW_PD
|
|
||||||
if (usb_pd_detect() == true) {
|
|
||||||
// Spawn all of the USB-C processors
|
|
||||||
fusb302_start_processing();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ void postRToSInit() {
|
|||||||
hall_effect_present = Si7210::init();
|
hall_effect_present = Si7210::init();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef POW_PD
|
|
||||||
// Spawn all of the USB-C processors
|
|
||||||
fusb302_start_processing();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
int16_t getRawHallEffect() {
|
int16_t getRawHallEffect() {
|
||||||
if (hall_effect_present) {
|
if (hall_effect_present) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include <pd.h>
|
#include <pd.h>
|
||||||
|
|
||||||
osThreadId InterruptHandler::TaskHandle = NULL;
|
volatile osThreadId InterruptHandler::TaskHandle = NULL;
|
||||||
uint32_t InterruptHandler::TaskBuffer[InterruptHandler::TaskStackSize];
|
uint32_t InterruptHandler::TaskBuffer[InterruptHandler::TaskStackSize];
|
||||||
osStaticThreadDef_t InterruptHandler::TaskControlBlock;
|
osStaticThreadDef_t InterruptHandler::TaskControlBlock;
|
||||||
|
|
||||||
@@ -68,11 +68,9 @@ void InterruptHandler::Thread(const void *arg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void InterruptHandler::irqCallback() {
|
void InterruptHandler::irqCallback() {
|
||||||
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
|
|
||||||
if (TaskHandle != NULL) {
|
if (TaskHandle != NULL) {
|
||||||
BaseType_t taskWoke = pdFALSE;
|
BaseType_t taskWoke = pdFALSE;
|
||||||
xTaskNotifyFromISR(TaskHandle, 0x01, eNotifyAction::eSetBits, &taskWoke);
|
xTaskNotifyFromISR(TaskHandle, 0, eNotifyAction::eNoAction, &taskWoke);
|
||||||
portYIELD_FROM_ISR(taskWoke);
|
portYIELD_FROM_ISR(taskWoke);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static void Thread(const void *arg);
|
static void Thread(const void *arg);
|
||||||
static osThreadId TaskHandle;
|
static volatile osThreadId TaskHandle;
|
||||||
static const size_t TaskStackSize = 1536 / 3;
|
static const size_t TaskStackSize = 1536 / 3;
|
||||||
static uint32_t TaskBuffer[TaskStackSize];
|
static uint32_t TaskBuffer[TaskStackSize];
|
||||||
static osStaticThreadDef_t TaskControlBlock;
|
static osStaticThreadDef_t TaskControlBlock;
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
#define EVENT_MASK(x) (1 << x)
|
#define EVENT_MASK(x) (1 << x)
|
||||||
|
|
||||||
/* PD Buddy thread priorities */
|
/* PD Buddy thread priorities */
|
||||||
#define PDB_PRIO_PE (osPriorityBelowNormal)
|
#define PDB_PRIO_PE (osPriorityAboveNormal)
|
||||||
#define PDB_PRIO_PRL (osPriorityNormal)
|
#define PDB_PRIO_PRL (osPriorityNormal)
|
||||||
#define PDB_PRIO_PRL_INT_N (osPriorityAboveNormal)
|
#define PDB_PRIO_PRL_INT_N (osPriorityBelowNormal)
|
||||||
|
|
||||||
#endif /* PDB_CONF_H */
|
#endif /* PDB_CONF_H */
|
||||||
|
|||||||
@@ -622,10 +622,10 @@ void PolicyEngine::PPSTimerCallback() {
|
|||||||
if (PPSTimerEnabled && state == policy_engine_state::PESinkReady) {
|
if (PPSTimerEnabled && state == policy_engine_state::PESinkReady) {
|
||||||
// I believe even once per second is totally fine, but leaning on faster since everything seems cool with faster
|
// I believe even once per second is totally fine, but leaning on faster since everything seems cool with faster
|
||||||
// Have seen everything from 10ms to 1 second :D
|
// Have seen everything from 10ms to 1 second :D
|
||||||
// if ((xTaskGetTickCount() - PPSTimeLastEvent) > (100)) {
|
if ((xTaskGetTickCount() - PPSTimeLastEvent) > (TICKS_SECOND)) {
|
||||||
// Send a new PPS message
|
// Send a new PPS message
|
||||||
PolicyEngine::notify(Notifications::PDB_EVT_PE_PPS_REQUEST);
|
PolicyEngine::notify(Notifications::PDB_EVT_PE_PPS_REQUEST);
|
||||||
PPSTimeLastEvent = xTaskGetTickCount();
|
PPSTimeLastEvent = xTaskGetTickCount();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include <MMA8652FC.hpp>
|
#include <MMA8652FC.hpp>
|
||||||
|
#include <fusbpd.h>
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
#include <power.hpp>
|
#include <power.hpp>
|
||||||
uint8_t DetectedAccelerometerVersion = 0;
|
uint8_t DetectedAccelerometerVersion = 0;
|
||||||
@@ -61,7 +62,12 @@ int main(void) {
|
|||||||
osThreadStaticDef(MOVTask, startMOVTask, osPriorityNormal, 0, MOVTaskStackSize, MOVTaskBuffer, &MOVTaskControlBlock);
|
osThreadStaticDef(MOVTask, startMOVTask, osPriorityNormal, 0, MOVTaskStackSize, MOVTaskBuffer, &MOVTaskControlBlock);
|
||||||
MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL);
|
MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL);
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
|
#ifdef POW_PD
|
||||||
|
if (usb_pd_detect() == true) {
|
||||||
|
// Spawn all of the USB-C processors
|
||||||
|
fusb302_start_processing();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* Start scheduler */
|
/* Start scheduler */
|
||||||
osKernelStart();
|
osKernelStart();
|
||||||
/* We should never get here as control is now taken by the scheduler */
|
/* We should never get here as control is now taken by the scheduler */
|
||||||
|
|||||||
Reference in New Issue
Block a user