1
0
forked from me/IronOS

Remove unused I2C DMA

Slow down I2C to 50kHz
Adjust ADC timing
This commit is contained in:
Ben V. Brown
2018-01-26 12:42:38 +11:00
parent 715be0b0b6
commit 653c71ba2d
6 changed files with 909 additions and 914 deletions

View File

@@ -18,8 +18,7 @@ extern ADC_HandleTypeDef hadc1;
extern DMA_HandleTypeDef hdma_adc1; extern DMA_HandleTypeDef hdma_adc1;
extern I2C_HandleTypeDef hi2c1; extern I2C_HandleTypeDef hi2c1;
extern DMA_HandleTypeDef hdma_i2c1_rx;
extern DMA_HandleTypeDef hdma_i2c1_tx;
extern IWDG_HandleTypeDef hiwdg; extern IWDG_HandleTypeDef hiwdg;

View File

@@ -9,8 +9,7 @@ ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1; DMA_HandleTypeDef hdma_adc1;
I2C_HandleTypeDef hi2c1; I2C_HandleTypeDef hi2c1;
DMA_HandleTypeDef hdma_i2c1_rx;
DMA_HandleTypeDef hdma_i2c1_tx;
IWDG_HandleTypeDef hiwdg; IWDG_HandleTypeDef hiwdg;
TIM_HandleTypeDef htim2; TIM_HandleTypeDef htim2;
@@ -130,7 +129,7 @@ static void MX_ADC1_Init(void) {
sConfigInjected.InjectedChannel = ADC_CHANNEL_8; sConfigInjected.InjectedChannel = ADC_CHANNEL_8;
sConfigInjected.InjectedRank = 1; sConfigInjected.InjectedRank = 1;
sConfigInjected.InjectedNbrOfConversion = 4; sConfigInjected.InjectedNbrOfConversion = 4;
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_55CYCLES_5; sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_71CYCLES_5;
sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T2_CC1; sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T2_CC1;
sConfigInjected.AutoInjectedConv = DISABLE; sConfigInjected.AutoInjectedConv = DISABLE;
sConfigInjected.InjectedDiscontinuousConvMode = DISABLE; sConfigInjected.InjectedDiscontinuousConvMode = DISABLE;
@@ -149,7 +148,7 @@ static void MX_ADC1_Init(void) {
static void MX_I2C1_Init(void) { static void MX_I2C1_Init(void) {
hi2c1.Instance = I2C1; hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 20000; hi2c1.Init.ClockSpeed = 50000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0; hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
@@ -158,8 +157,6 @@ static void MX_I2C1_Init(void) {
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
HAL_I2C_Init(&hi2c1); HAL_I2C_Init(&hi2c1);
HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
} }

View File

@@ -58,7 +58,7 @@ uint16_t getTipInstantTemperature() {
uint16_t getTipRawTemp(uint8_t instant) { uint16_t getTipRawTemp(uint8_t instant) {
#define filterDepth1 1 #define filterDepth1 1
/*Pre filter used before PID*/ /*Pre filter used before PID*/
#define filterDepth2 64 #define filterDepth2 32
/*Post filter used for UI display*/ /*Post filter used for UI display*/
static uint16_t filterLayer1[filterDepth1]; static uint16_t filterLayer1[filterDepth1];
static uint16_t filterLayer2[filterDepth2]; static uint16_t filterLayer2[filterDepth2];

View File

@@ -109,16 +109,18 @@ ButtonState getButtonState() {
static uint32_t previousStateChange = 0; static uint32_t previousStateChange = 0;
const uint16_t timeout = 400; const uint16_t timeout = 400;
uint8_t currentState; uint8_t currentState;
currentState = currentState = (
(HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ? 1 : 0) HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ?
<< 0; 1 : 0) << 0;
currentState |= currentState |= (
(HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ? 1 : 0) HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ?
<< 1; 1 : 0) << 1;
if (currentState) lastButtonTime = HAL_GetTick(); if (currentState)
lastButtonTime = HAL_GetTick();
if (currentState == previousState) { if (currentState == previousState) {
if (currentState == 0) return BUTTON_NONE; if (currentState == 0)
return BUTTON_NONE;
if ((HAL_GetTick() - previousStateChange) > timeout) { if ((HAL_GetTick() - previousStateChange) > timeout) {
// User has been holding the button down // User has been holding the button down
// We want to send a buttong is held message // We want to send a buttong is held message
@@ -180,8 +182,10 @@ void waitForButtonPressOrTimeout(uint32_t timeout) {
// Make timeout our exit value // Make timeout our exit value
for (;;) { for (;;) {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons) return; if (buttons)
if (HAL_GetTick() > timeout) return; return;
if (HAL_GetTick() > timeout)
return;
GUIDelay(); GUIDelay();
} }
} }
@@ -197,9 +201,11 @@ static bool checkVoltageForExit() {
lcd.print(UndervoltageString); lcd.print(UndervoltageString);
lcd.setCursor(0, 8); lcd.setCursor(0, 8);
lcd.print(InputVoltageString); lcd.print(InputVoltageString);
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
2);
lcd.drawChar('.'); lcd.drawChar('.');
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
1);
lcd.print("V"); lcd.print("V");
} else { } else {
@@ -219,12 +225,15 @@ static void gui_drawBatteryIcon() {
// User is on a lithium battery // User is on a lithium battery
// we need to calculate which of the 10 levels they are on // we need to calculate which of the 10 levels they are on
uint8_t cellCount = systemSettings.cutoutSetting + 2; uint8_t cellCount = systemSettings.cutoutSetting + 2;
uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv) / cellCount; uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv)
/ cellCount;
// Should give us approx cell voltage X10 // Should give us approx cell voltage X10
// Range is 42 -> 33 = 9 steps therefore we will use battery 1-10 // Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
if (cellV < 33) cellV = 33; if (cellV < 33)
cellV = 33;
cellV -= 33; // Should leave us a number of 0-9 cellV -= 33; // Should leave us a number of 0-9
if (cellV > 9) cellV = 9; if (cellV > 9)
cellV = 9;
lcd.drawBattery(cellV + 1); lcd.drawBattery(cellV + 1);
} else } else
lcd.drawSymbol(16); // Draw the DC Logo lcd.drawSymbol(16); // Draw the DC Logo
@@ -237,7 +246,8 @@ static void gui_solderingTempAdjust() {
lcd.clearScreen(); lcd.clearScreen();
lcd.setFont(0); lcd.setFont(0);
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons) lastChange = HAL_GetTick(); if (buttons)
lastChange = HAL_GetTick();
switch (buttons) { switch (buttons) {
case BUTTON_NONE: case BUTTON_NONE:
// stay // stay
@@ -282,7 +292,8 @@ static void gui_solderingTempAdjust() {
if (systemSettings.SolderingTemp < 120) if (systemSettings.SolderingTemp < 120)
systemSettings.SolderingTemp = 120; systemSettings.SolderingTemp = 120;
} else { } else {
if (systemSettings.SolderingTemp < 50) systemSettings.SolderingTemp = 50; if (systemSettings.SolderingTemp < 50)
systemSettings.SolderingTemp = 50;
} }
if (HAL_GetTick() - lastChange > 1500) if (HAL_GetTick() - lastChange > 1500)
@@ -306,8 +317,8 @@ static void gui_settingsMenu() {
uint32_t autoRepeatTimer = 0; uint32_t autoRepeatTimer = 0;
bool earlyExit = false; bool earlyExit = false;
uint32_t descriptionStart = 0; uint32_t descriptionStart = 0;
while ((settingsMenu[currentScreen].incrementHandler.func != NULL) && while ((settingsMenu[currentScreen].incrementHandler.func != NULL)
earlyExit == false) { && earlyExit == false) {
lcd.setFont(0); lcd.setFont(0);
lcd.clearScreen(); lcd.clearScreen();
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
@@ -318,8 +329,10 @@ static void gui_settingsMenu() {
} else { } else {
// Draw description // Draw description
// draw string starting from descriptionOffset // draw string starting from descriptionOffset
int16_t maxOffset = strlen(settingsMenu[currentScreen].description) + 7; int16_t maxOffset = strlen(settingsMenu[currentScreen].description)
if (descriptionStart == 0) descriptionStart = HAL_GetTick(); + 7;
if (descriptionStart == 0)
descriptionStart = HAL_GetTick();
int16_t descriptionOffset = int16_t descriptionOffset =
(((HAL_GetTick() - descriptionStart) / 3) % (maxOffset * 12)); (((HAL_GetTick() - descriptionStart) / 3) % (maxOffset * 12));
@@ -407,7 +420,8 @@ static int gui_showTipTempWarning() {
} }
} }
if (systemSettings.coolingTempBlink && tipTemp > 70) { if (systemSettings.coolingTempBlink && tipTemp > 70) {
if (HAL_GetTick() % 500 < 250) lcd.clearScreen(); if (HAL_GetTick() % 500 < 250)
lcd.clearScreen();
} }
lcd.refresh(); lcd.refresh();
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
@@ -416,10 +430,12 @@ static int gui_showTipTempWarning() {
else if (buttons == BUTTON_B_SHORT || buttons == BUTTON_BOTH) else if (buttons == BUTTON_B_SHORT || buttons == BUTTON_BOTH)
return 0; return 0;
if (tipTemp < 50) return 0;//Exit the warning screen if (tipTemp < 50)
return 0; //Exit the warning screen
GUIDelay(); GUIDelay();
} }
return 0;
} }
static uint16_t min(uint16_t a, uint16_t b) { static uint16_t min(uint16_t a, uint16_t b) {
if (a > b) if (a > b)
@@ -432,18 +448,22 @@ static int gui_SolderingSleepingMode() {
for (;;) { for (;;) {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons) return 0; if (buttons)
if ((HAL_GetTick() - lastMovementTime < 1000) || return 0;
(HAL_GetTick() - lastButtonTime < 1000)) if ((HAL_GetTick() - lastMovementTime < 1000)
|| (HAL_GetTick() - lastButtonTime < 1000))
return 0; // user moved or pressed a button, go back to soldering return 0; // user moved or pressed a button, go back to soldering
if (checkVoltageForExit()) return 1; // return non-zero on error if (checkVoltageForExit())
return 1; // return non-zero on error
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = ftoTipMeasurement( currentlyActiveTemperatureTarget = ftoTipMeasurement(
min(systemSettings.SleepTemp, systemSettings.SolderingTemp)); min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
else else
currentlyActiveTemperatureTarget = ctoTipMeasurement( currentlyActiveTemperatureTarget = ctoTipMeasurement(
min(systemSettings.SleepTemp, systemSettings.SolderingTemp)); min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
// draw the lcd // draw the lcd
uint16_t tipTemp; uint16_t tipTemp;
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
@@ -465,9 +485,11 @@ static int gui_SolderingSleepingMode() {
lcd.print("C"); lcd.print("C");
lcd.print(" "); lcd.print(" ");
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
2);
lcd.drawChar('.'); lcd.drawChar('.');
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
1);
lcd.drawChar('V'); lcd.drawChar('V');
} else { } else {
lcd.setFont(0); lcd.setFont(0);
@@ -480,8 +502,8 @@ static int gui_SolderingSleepingMode() {
} }
if (systemSettings.ShutdownTime) // only allow shutdown exit if time > 0 if (systemSettings.ShutdownTime) // only allow shutdown exit if time > 0
if (lastMovementTime) if (lastMovementTime)
if (((uint32_t)(HAL_GetTick() - lastMovementTime)) > if (((uint32_t) (HAL_GetTick() - lastMovementTime))
(uint32_t)(systemSettings.ShutdownTime * 60 * 1000)) { > (uint32_t) (systemSettings.ShutdownTime * 60 * 1000)) {
// shutdown // shutdown
currentlyActiveTemperatureTarget = 0; currentlyActiveTemperatureTarget = 0;
return 1; // we want to exit soldering mode return 1; // we want to exit soldering mode
@@ -489,6 +511,7 @@ static int gui_SolderingSleepingMode() {
lcd.refresh(); lcd.refresh();
GUIDelay(); GUIDelay();
} }
return 0;
} }
static void gui_solderingMode() { static void gui_solderingMode() {
/* /*
@@ -528,7 +551,8 @@ static void gui_solderingMode() {
break; break;
case BUTTON_F_LONG: case BUTTON_F_LONG:
// if boost mode is enabled turn it on // if boost mode is enabled turn it on
if (systemSettings.boostModeEnabled) boostModeOn = true; if (systemSettings.boostModeEnabled)
boostModeOn = true;
break; break;
case BUTTON_F_SHORT: case BUTTON_F_SHORT:
case BUTTON_B_SHORT: { case BUTTON_B_SHORT: {
@@ -537,7 +561,8 @@ static void gui_solderingMode() {
if (oldTemp != systemSettings.SolderingTemp) { if (oldTemp != systemSettings.SolderingTemp) {
saveSettings(); // only save on change saveSettings(); // only save on change
} }
} break; }
break;
default: default:
break; break;
} }
@@ -608,19 +633,19 @@ static void gui_solderingMode() {
// Update the setpoints for the temperature // Update the setpoints for the temperature
if (boostModeOn) { if (boostModeOn) {
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = currentlyActiveTemperatureTarget = ftoTipMeasurement(
ftoTipMeasurement(systemSettings.BoostTemp); systemSettings.BoostTemp);
else else
currentlyActiveTemperatureTarget = currentlyActiveTemperatureTarget = ctoTipMeasurement(
ctoTipMeasurement(systemSettings.BoostTemp); systemSettings.BoostTemp);
} else { } else {
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = currentlyActiveTemperatureTarget = ftoTipMeasurement(
ftoTipMeasurement(systemSettings.SolderingTemp); systemSettings.SolderingTemp);
else else
currentlyActiveTemperatureTarget = currentlyActiveTemperatureTarget = ctoTipMeasurement(
ctoTipMeasurement(systemSettings.SolderingTemp); systemSettings.SolderingTemp);
} }
// Undervoltage test // Undervoltage test
@@ -630,8 +655,8 @@ static void gui_solderingMode() {
lcd.refresh(); lcd.refresh();
if (systemSettings.sensitivity) if (systemSettings.sensitivity)
if (HAL_GetTick() - lastMovementTime > sleepThres && if (HAL_GetTick() - lastMovementTime > sleepThres
HAL_GetTick() - lastButtonTime > sleepThres) { && HAL_GetTick() - lastButtonTime > sleepThres) {
if (gui_SolderingSleepingMode()) { if (gui_SolderingSleepingMode()) {
return; // If the function returns non-0 then exit return; // If the function returns non-0 then exit
} }
@@ -667,11 +692,13 @@ void startGUITask(void const *argument) {
uint8_t tempWarningState = 0; uint8_t tempWarningState = 0;
HAL_IWDG_Refresh(&hiwdg); HAL_IWDG_Refresh(&hiwdg);
if (showBootLogoIfavailable()) waitForButtonPressOrTimeout(2000); if (showBootLogoIfavailable())
waitForButtonPressOrTimeout(2000);
HAL_IWDG_Refresh(&hiwdg); HAL_IWDG_Refresh(&hiwdg);
if (systemSettings.autoStartMode) { if (systemSettings.autoStartMode) {
// jump directly to the autostart mode // jump directly to the autostart mode
if (systemSettings.autoStartMode == 1) gui_solderingMode(); if (systemSettings.autoStartMode == 1)
gui_solderingMode();
} }
#if ACCELDEBUG #if ACCELDEBUG
@@ -684,7 +711,8 @@ void startGUITask(void const *argument) {
for (;;) { for (;;) {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (tempWarningState == 2) buttons = BUTTON_F_SHORT; if (tempWarningState == 2)
buttons = BUTTON_F_SHORT;
switch (buttons) { switch (buttons) {
case BUTTON_NONE: case BUTTON_NONE:
// Do nothing // Do nothing
@@ -699,7 +727,7 @@ void startGUITask(void const *argument) {
lcd.clearScreen(); // Ensure the buffer starts clean lcd.clearScreen(); // Ensure the buffer starts clean
lcd.setCursor(0, 0); // Position the cursor at the 0,0 (top left) lcd.setCursor(0, 0); // Position the cursor at the 0,0 (top left)
lcd.setFont(1); // small font lcd.setFont(1); // small font
lcd.print((char *)"V2.01"); // Print version number lcd.print((char *) "V2.03"); // Print version number
lcd.setCursor(0, 8); // second line lcd.setCursor(0, 8); // second line
lcd.print(__DATE__); // print the compile date lcd.print(__DATE__); // print the compile date
lcd.refresh(); lcd.refresh();
@@ -722,8 +750,7 @@ void startGUITask(void const *argument) {
lcd.displayOnOff(true); // turn lcd on lcd.displayOnOff(true); // turn lcd on
gui_settingsMenu(); // enter the settings menu gui_settingsMenu(); // enter the settings menu
saveSettings(); saveSettings();
setCalibrationOffset( setCalibrationOffset(systemSettings.CalibrationOffset); // ensure cal offset is applied
systemSettings.CalibrationOffset); // ensure cal offset is applied
break; break;
default: default:
break; break;
@@ -731,17 +758,17 @@ void startGUITask(void const *argument) {
currentlyActiveTemperatureTarget = 0; // ensure tip is off currentlyActiveTemperatureTarget = 0; // ensure tip is off
if (systemSettings.sensitivity) { if (systemSettings.sensitivity) {
if ((HAL_GetTick() - lastMovementTime) > 60000 && if ((HAL_GetTick() - lastMovementTime) > 60000
(HAL_GetTick() - lastButtonTime) > 60000) && (HAL_GetTick() - lastButtonTime) > 60000)
lcd.displayOnOff(false); // turn lcd off when no movement lcd.displayOnOff(false); // turn lcd off when no movement
else if (HAL_GetTick() - lastMovementTime < 1000 || else if (HAL_GetTick() - lastMovementTime < 1000
HAL_GetTick() - lastButtonTime < || HAL_GetTick() - lastButtonTime < 1000) /*Use short time for test, and prevent lots of I2C
1000) /*Use short time for test, and prevent lots of I2C
writes for no need*/ writes for no need*/
lcd.displayOnOff(true); // turn lcd back on lcd.displayOnOff(true); // turn lcd back on
} }
uint16_t tipTemp = tipMeasurementToC(getTipRawTemp(0)); uint16_t tipTemp = tipMeasurementToC(getTipRawTemp(0));
if (tipTemp > 600) tipTemp = 0; if (tipTemp > 600)
tipTemp = 0;
if (tipTemp > 50) { if (tipTemp > 50) {
if (tempWarningState == 0) { if (tempWarningState == 0) {
currentlyActiveTemperatureTarget = 0; // ensure tip is off currentlyActiveTemperatureTarget = 0; // ensure tip is off
@@ -771,9 +798,11 @@ void startGUITask(void const *argument) {
} }
lcd.setCursor(0, 8); lcd.setCursor(0, 8);
lcd.print(InputVoltageString); lcd.print(InputVoltageString);
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
2);
lcd.drawChar('.'); lcd.drawChar('.');
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
1);
lcd.print("V"); lcd.print("V");
} else { } else {
@@ -839,9 +868,12 @@ void startPIDTask(void const *argument) {
/*Compute PID Output*/ /*Compute PID Output*/
int32_t output = (rawTempError / kp); int32_t output = (rawTempError / kp);
if (ki) output += integralCount; if (ki)
if (kd) output -= (dInput / kd); output += integralCount;
if (kb) output -= backoffOverflow / kb; if (kd)
output -= (dInput / kd);
if (kb)
output -= backoffOverflow / kb;
if (output > 100) { if (output > 100) {
backoffOverflow = output; backoffOverflow = output;
@@ -882,7 +914,8 @@ void startMOVTask(void const *argument) {
memset(dataz, 0, MOVFilter * sizeof(int16_t)); memset(dataz, 0, MOVFilter * sizeof(int16_t));
int16_t tx, ty, tz; int16_t tx, ty, tz;
int32_t avgx, avgy, avgz; int32_t avgx, avgy, avgz;
if (systemSettings.sensitivity > 9) systemSettings.sensitivity = 9; if (systemSettings.sensitivity > 9)
systemSettings.sensitivity = 9;
#if ACCELDEBUG #if ACCELDEBUG
uint32_t max = 0; uint32_t max = 0;
#endif #endif
@@ -976,9 +1009,9 @@ void startRotationTask(void const *argument) {
break; break;
} }
for (;;) { for (;;) {
if (xSemaphoreTake(rotationChangedSemaphore, portMAX_DELAY) == pdTRUE || if (xSemaphoreTake(rotationChangedSemaphore, portMAX_DELAY) == pdTRUE
(HAL_GPIO_ReadPin(INT_Orientation_GPIO_Port, INT_Orientation_Pin) == || (HAL_GPIO_ReadPin(INT_Orientation_GPIO_Port,
GPIO_PIN_RESET)) { INT_Orientation_Pin) == GPIO_PIN_RESET)) {
// a rotation event has occured // a rotation event has occured
bool rotation = accel.getOrientation(); bool rotation = accel.getOrientation();
if (systemSettings.OrientationMode == 2) if (systemSettings.OrientationMode == 2)
@@ -992,7 +1025,8 @@ void startRotationTask(void const *argument) {
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
static signed long xHigherPriorityTaskWoken; static signed long xHigherPriorityTaskWoken;
if (GPIO_Pin == INT_Orientation_Pin) { if (GPIO_Pin == INT_Orientation_Pin) {
xSemaphoreGiveFromISR(rotationChangedSemaphore, &xHigherPriorityTaskWoken); xSemaphoreGiveFromISR(rotationChangedSemaphore,
&xHigherPriorityTaskWoken);
} else if (GPIO_Pin == INT_Movement_Pin) { } else if (GPIO_Pin == INT_Movement_Pin) {
// New data is available for reading from the unit // New data is available for reading from the unit
// xSemaphoreGiveFromISR(accelDataAvailableSemaphore, // xSemaphoreGiveFromISR(accelDataAvailableSemaphore,
@@ -1017,10 +1051,14 @@ bool showBootLogoIfavailable() {
temp8[i * 2 + 1] = temp[i] & 0xFF; temp8[i * 2 + 1] = temp[i] & 0xFF;
} }
if (temp8[0] != 0xAA) return false; if (temp8[0] != 0xAA)
if (temp8[1] != 0x55) return false; return false;
if (temp8[2] != 0xF0) return false; if (temp8[1] != 0x55)
if (temp8[3] != 0x0D) return false; return false;
if (temp8[2] != 0xF0)
return false;
if (temp8[3] != 0x0D)
return false;
lcd.drawArea(0, 0, 96, 16, (uint8_t *) (temp8 + 4)); lcd.drawArea(0, 0, 96, 16, (uint8_t *) (temp8 + 4));
lcd.refresh(); lcd.refresh();

View File

@@ -73,7 +73,6 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
} }
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) { void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) {
GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitTypeDef GPIO_InitStruct;
@@ -92,38 +91,10 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) {
__HAL_RCC_I2C1_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE()
; ;
/* I2C1 DMA Init */
/* I2C1_RX Init */
hdma_i2c1_rx.Instance = DMA1_Channel7;
hdma_i2c1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_i2c1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_i2c1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_i2c1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_i2c1_rx.Init.Mode = DMA_NORMAL;
hdma_i2c1_rx.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&hdma_i2c1_rx);
__HAL_LINKDMA(hi2c, hdmarx, hdma_i2c1_rx);
/* I2C1_TX Init */
hdma_i2c1_tx.Instance = DMA1_Channel6;
hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&hdma_i2c1_tx);
__HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
} }
} }
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) {
if (htim_base->Instance == TIM3) { if (htim_base->Instance == TIM3) {
/* Peripheral clock enable */ /* Peripheral clock enable */

View File

@@ -63,16 +63,6 @@ void DMA1_Channel1_IRQHandler(void) {
HAL_DMA_IRQHandler(&hdma_adc1); HAL_DMA_IRQHandler(&hdma_adc1);
} }
// DMA used for transmitting I2C packets
void DMA1_Channel6_IRQHandler(void) {
HAL_DMA_IRQHandler(&hdma_i2c1_tx);
}
//DMA used for receiving I2C packets
void DMA1_Channel7_IRQHandler(void) {
HAL_DMA_IRQHandler(&hdma_i2c1_rx);
}
//ADC interrupt used for DMA //ADC interrupt used for DMA
void ADC1_2_IRQHandler(void) { void ADC1_2_IRQHandler(void) {
HAL_ADC_IRQHandler(&hadc1); HAL_ADC_IRQHandler(&hadc1);