1
0
forked from me/IronOS

Correct a few missed time values from the tick rate change (#874)

* Pass over all refs to xTaskGetTickCount()

* That wasn't a second 😓

* Update FreeRTOSConfig.h

* Fix warning in usb code; style; fix slow description
This commit is contained in:
Ben V. Brown
2021-03-15 21:01:09 +11:00
committed by GitHub
parent 2796f095af
commit 7fbfde7b33
12 changed files with 35 additions and 28 deletions

View File

@@ -7,7 +7,7 @@
#ifndef BSP_DEFINES_H_ #ifndef BSP_DEFINES_H_
#define BSP_DEFINES_H_ #define BSP_DEFINES_H_
#include "FreeRTOSConfig.h"
enum Orientation { ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3 }; enum Orientation { ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3 };
// It is assumed that all hardware implements an 8Hz update period at this time // It is assumed that all hardware implements an 8Hz update period at this time

View File

@@ -83,7 +83,9 @@
*----------------------------------------------------------*/ *----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
/* Section where include file can be added */ #ifdef __cplusplus
extern "C" {
#endif
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Ensure stdint is only used by the compiler, and not the assembler. */ /* Ensure stdint is only used by the compiler, and not the assembler. */
@@ -172,5 +174,7 @@ extern uint32_t SystemCoreClock;
#define configTIMER_QUEUE_LENGTH 8 #define configTIMER_QUEUE_LENGTH 8
#define configTIMER_TASK_STACK_DEPTH (512 / 4) #define configTIMER_TASK_STACK_DEPTH (512 / 4)
#endif #endif
#ifdef __cplusplus
}
#endif
#endif /* FREERTOS_CONFIG_H */ #endif /* FREERTOS_CONFIG_H */

View File

@@ -93,7 +93,8 @@ usb_reqsta usbd_class_request(usb_core_driver *udev, usb_req *req) {
if (USBD_CONFIGURED == udev->dev.cur_status) { if (USBD_CONFIGURED == udev->dev.cur_status) {
if (BYTE_LOW(req->wIndex) <= USBD_ITF_MAX_NUM) { if (BYTE_LOW(req->wIndex) <= USBD_ITF_MAX_NUM) {
/* call device class handle function */ /* call device class handle function */
return (usb_reqsta)udev->dev.class_core->req_proc(udev, req); uint8_t res = udev->dev.class_core->req_proc(udev, req);
return (usb_reqsta)res;
} }
} }
@@ -426,7 +427,10 @@ static usb_reqsta _usb_std_getdescriptor(usb_core_driver *udev, usb_req *req) {
case USB_RECPTYPE_ITF: case USB_RECPTYPE_ITF:
/* get device class special descriptor */ /* get device class special descriptor */
return (usb_reqsta)(udev->dev.class_core->req_proc(udev, req)); {
uint8_t res = udev->dev.class_core->req_proc(udev, req);
return (usb_reqsta)res;
}
case USB_RECPTYPE_EP: case USB_RECPTYPE_EP:
break; break;

View File

@@ -45,7 +45,6 @@ OF SUCH DAMAGE.
static uint32_t usbh_request_submit(usb_core_driver *pudev, uint8_t pp_num) { static uint32_t usbh_request_submit(usb_core_driver *pudev, uint8_t pp_num) {
pudev->host.pipe[pp_num].urb_state = URB_IDLE; pudev->host.pipe[pp_num].urb_state = URB_IDLE;
pudev->host.pipe[pp_num].xfer_count = 0U; pudev->host.pipe[pp_num].xfer_count = 0U;
return usb_pipe_xfer(pudev, pp_num); return usb_pipe_xfer(pudev, pp_num);
} }
@@ -63,8 +62,8 @@ usbh_status usbh_ctlsetup_send(usb_core_driver *pudev, uint8_t *buf, uint8_t pp_
pp->DPID = PIPE_DPID_SETUP; pp->DPID = PIPE_DPID_SETUP;
pp->xfer_buf = buf; pp->xfer_buf = buf;
pp->xfer_len = USB_SETUP_PACKET_LEN; pp->xfer_len = USB_SETUP_PACKET_LEN;
uint32_t res = usbh_request_submit(pudev, pp_num);
return (usbh_status)usbh_request_submit(pudev, pp_num); return (usbh_status)res;
} }
/*! /*!

View File

@@ -24,7 +24,7 @@ ButtonState getButtonState() {
*/ */
static uint8_t previousState = 0; static uint8_t previousState = 0;
static uint32_t previousStateChange = 0; static uint32_t previousStateChange = 0;
const uint16_t timeout = 400; const uint16_t timeout = TICKS_100MS * 4;
uint8_t currentState; uint8_t currentState;
currentState = (getButtonA()) << 0; currentState = (getButtonA()) << 0;
currentState |= (getButtonB()) << 1; currentState |= (getButtonB()) << 1;

View File

@@ -162,14 +162,14 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
uint8_t *firstBackStripPtr = &secondFrameBuffer[0]; uint8_t *firstBackStripPtr = &secondFrameBuffer[0];
uint8_t *secondBackStripPtr = &secondFrameBuffer[OLED_WIDTH]; uint8_t *secondBackStripPtr = &secondFrameBuffer[OLED_WIDTH];
uint32_t totalDuration = 50; // 500ms uint32_t totalDuration = TICKS_100MS * 5; // 500ms
uint32_t duration = 0; uint32_t duration = 0;
uint32_t start = xTaskGetTickCount(); uint32_t start = xTaskGetTickCount();
uint8_t offset = 0; uint8_t offset = 0;
while (duration <= totalDuration) { while (duration <= totalDuration) {
duration = xTaskGetTickCount() - start; duration = xTaskGetTickCount() - start;
uint8_t progress = duration * TICKS_SECOND / totalDuration; uint8_t progress = ((duration * 100) / totalDuration); // Percentage of the period we are through for animation
progress = easeInOutTiming(progress); progress = easeInOutTiming(progress);
progress = lerp(0, OLED_WIDTH, progress); progress = lerp(0, OLED_WIDTH, progress);
if (progress > OLED_WIDTH) { if (progress > OLED_WIDTH) {

View File

@@ -11,9 +11,9 @@
#include "Settings.h" #include "Settings.h"
#include "Translation.h" #include "Translation.h"
#define PRESS_ACCEL_STEP 30 #define PRESS_ACCEL_STEP (TICKS_100MS / 3)
#define PRESS_ACCEL_INTERVAL_MIN 100 #define PRESS_ACCEL_INTERVAL_MIN TICKS_100MS
#define PRESS_ACCEL_INTERVAL_MAX 300 #define PRESS_ACCEL_INTERVAL_MAX (TICKS_100MS * 3)
// GUI holds the menu structure and all its methods for the menu itself // GUI holds the menu structure and all its methods for the menu itself

View File

@@ -276,7 +276,7 @@ static int userConfirmation(const char *message) {
bool lcdRefresh = true; bool lcdRefresh = true;
for (;;) { for (;;) {
int16_t messageOffset = ((xTaskGetTickCount() - messageStart) / (systemSettings.descriptionScrollSpeed == 1 ? 10 : 20)); int16_t messageOffset = ((xTaskGetTickCount() - messageStart) / (systemSettings.descriptionScrollSpeed == 1 ? TICKS_100MS : (TICKS_100MS * 2)));
messageOffset %= messageWidth; // Roll around at the end messageOffset %= messageWidth; // Roll around at the end
if (lastOffset != messageOffset) { if (lastOffset != messageOffset) {
@@ -1078,7 +1078,7 @@ void gui_Menu(const menuitem *menu) {
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
// If the user has hesitated for >=3 seconds, show the long text // If the user has hesitated for >=3 seconds, show the long text
// Otherwise "draw" the option // Otherwise "draw" the option
if ((xTaskGetTickCount() - lastButtonTime < 3000) || menu[currentScreen].description == NULL) { if ((xTaskGetTickCount() - lastButtonTime < (TICKS_SECOND * 3)) || menu[currentScreen].description == NULL) {
OLED::clearScreen(); OLED::clearScreen();
menu[currentScreen].draw(); menu[currentScreen].draw();
uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize; uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize;
@@ -1095,7 +1095,7 @@ void gui_Menu(const menuitem *menu) {
descriptionStart = xTaskGetTickCount(); descriptionStart = xTaskGetTickCount();
// lower the value - higher the speed // lower the value - higher the speed
int16_t descriptionWidth = FONT_12_WIDTH * (strlen(menu[currentScreen].description) + 7); int16_t descriptionWidth = FONT_12_WIDTH * (strlen(menu[currentScreen].description) + 7);
int16_t descriptionOffset = ((xTaskGetTickCount() - descriptionStart) / (systemSettings.descriptionScrollSpeed == 1 ? 10 : 20)); int16_t descriptionOffset = ((xTaskGetTickCount() - descriptionStart) / (systemSettings.descriptionScrollSpeed == 1 ? (TICKS_100MS / 10) : (TICKS_100MS / 5)));
descriptionOffset %= descriptionWidth; // Roll around at the end descriptionOffset %= descriptionWidth; // Roll around at the end
if (lastOffset != descriptionOffset) { if (lastOffset != descriptionOffset) {
OLED::clearScreen(); OLED::clearScreen();
@@ -1149,7 +1149,7 @@ void gui_Menu(const menuitem *menu) {
descriptionStart = 0; descriptionStart = 0;
break; break;
case BUTTON_F_LONG: case BUTTON_F_LONG:
if ((int)(xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration) > PRESS_ACCEL_INTERVAL_MAX) { if ((xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration) > PRESS_ACCEL_INTERVAL_MAX) {
if ((lastValue = menu[currentScreen].incrementHandler())) if ((lastValue = menu[currentScreen].incrementHandler()))
autoRepeatTimer = 1000; autoRepeatTimer = 1000;
else else
@@ -1185,7 +1185,7 @@ void gui_Menu(const menuitem *menu) {
osDelay(40); osDelay(40);
lcdRefresh = false; lcdRefresh = false;
} }
if ((xTaskGetTickCount() - lastButtonTime) > (1000 * 30)) { if ((xTaskGetTickCount() - lastButtonTime) > (TICKS_SECOND * 30)) {
// If user has not pressed any buttons in 30 seconds, exit back a menu layer // If user has not pressed any buttons in 30 seconds, exit back a menu layer
// This will trickle the user back to the main screen eventually // This will trickle the user back to the main screen eventually
earlyExit = true; earlyExit = true;

View File

@@ -256,7 +256,7 @@ static void gui_solderingTempAdjust() {
systemSettings.SolderingTemp = 10; systemSettings.SolderingTemp = 10;
} }
if (xTaskGetTickCount() - lastChange > 2000) if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2))
return; // exit if user just doesn't press anything for a bit return; // exit if user just doesn't press anything for a bit
#ifdef OLED_FLIP #ifdef OLED_FLIP
@@ -645,11 +645,11 @@ void showDebugMenu(void) {
break; break;
case 4: case 4:
// system up time stamp // system up time stamp
OLED::printNumber(xTaskGetTickCount() / 100, 5); OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5);
break; break;
case 5: case 5:
// Movement time stamp // Movement time stamp
OLED::printNumber(lastMovementTime / 100, 5); OLED::printNumber(lastMovementTime / TICKS_100MS, 5);
break; break;
case 6: case 6:
// Raw Tip // Raw Tip
@@ -774,7 +774,7 @@ void startGUITask(void const *argument __unused) {
getTipRawTemp(1); // reset filter getTipRawTemp(1); // reset filter
OLED::setRotation(systemSettings.OrientationMode & 1); OLED::setRotation(systemSettings.OrientationMode & 1);
uint32_t ticks = xTaskGetTickCount(); uint32_t ticks = xTaskGetTickCount();
ticks += 4000; // 4 seconds from now ticks += (TICKS_SECOND * 4); // 4 seconds from now
while (xTaskGetTickCount() < ticks) { while (xTaskGetTickCount() < ticks) {
if (showBootLogoIfavailable() == false) if (showBootLogoIfavailable() == false)
ticks = xTaskGetTickCount(); ticks = xTaskGetTickCount();
@@ -912,7 +912,7 @@ void startGUITask(void const *argument __unused) {
// If we have a tip connected draw the temp, if not we leave it blank // If we have a tip connected draw the temp, if not we leave it blank
if (!tipDisconnectedDisplay) { if (!tipDisconnectedDisplay) {
// draw in the temp // draw in the temp
if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 26 < 16))) if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 260 < 160)))
gui_drawTipTemp(false); // draw in the temp gui_drawTipTemp(false); // draw in the temp
} else { } else {
// Draw in missing tip symbol // Draw in missing tip symbol

View File

@@ -170,6 +170,6 @@ void startMOVTask(void const *argument __unused) {
lastMovementTime = xTaskGetTickCount(); lastMovementTime = xTaskGetTickCount();
} }
osDelay(TICKS_100MS); // Slow down update rate vTaskDelay(TICKS_100MS); // Slow down update rate
} }
} }

View File

@@ -14,8 +14,8 @@
#include "main.hpp" #include "main.hpp"
#include "power.hpp" #include "power.hpp"
#include "task.h" #include "task.h"
static TickType_t powerPulseRate = 10000; static TickType_t powerPulseRate = 10 * TICKS_SECOND;
static TickType_t powerPulseDuration = 250; static TickType_t powerPulseDuration = 3 * TICKS_100MS;
TaskHandle_t pidTaskNotification = NULL; TaskHandle_t pidTaskNotification = NULL;
uint32_t currentTempTargetDegC = 0; // Current temperature target in C uint32_t currentTempTargetDegC = 0; // Current temperature target in C

View File

@@ -127,7 +127,7 @@ HEXFILE_DIR=Hexfile
OUTPUT_DIR_BASE=Objects OUTPUT_DIR_BASE=Objects
OUTPUT_DIR=Objects/$(model) OUTPUT_DIR=Objects/$(model)
# code optimisation ------------------------------------------------------------ # code optimisation ------------------------------------------------------------
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums
# global defines --------------------------------------------------------------- # global defines ---------------------------------------------------------------
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U