auto-sync

This commit is contained in:
rusEfi 2015-01-24 08:06:53 -06:00
parent c77926af70
commit 67ce304d08
4 changed files with 67 additions and 17 deletions

View File

@ -5,8 +5,8 @@
* @author Andrey Belomutskiy, (c) 2012-2015 * @author Andrey Belomutskiy, (c) 2012-2015
*/ */
#ifndef STATUS_LEDS_H_ #ifndef IO_PINS_H_
#define STATUS_LEDS_H_ #define IO_PINS_H_
#include "rusefi_enums.h" #include "rusefi_enums.h"
@ -66,17 +66,10 @@ typedef enum {
void initPrimaryPins(void); void initPrimaryPins(void);
void initOutputPins(void); void initOutputPins(void);
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if EFI_GPIO #if EFI_GPIO
void turnAllPinsOff(void); void turnAllPinsOff(void);
#else #else
#define turnAllPinsOff() {} #define turnAllPinsOff() {}
#endif #endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* STATUS_LEDS_H_ */ #endif /* IO_PINS_H_ */

View File

@ -106,8 +106,16 @@ static brain_pin_e BLINK_PINS[] = { GPIOE_8, // HIGH DRIVER 1
GPIOB_7, // OUT12 Frankenso GPIOB_7, // OUT12 Frankenso
}; };
int pinsCount = sizeof(BLINK_PINS) / sizeof(brain_pin_e);
static THD_WORKING_AREA(btThreadStack, UTILITY_THREAD_STACK_SIZE); static THD_WORKING_AREA(btThreadStack, UTILITY_THREAD_STACK_SIZE);
static void setCurrentPinValue(bool value) {
GPIO_TypeDef *hwPort = getHwPort(currentPin);
uint32_t hwPin = getHwPin(currentPin);
palWritePad(hwPort, hwPin, value);
}
static msg_t ivThread(int param) { static msg_t ivThread(int param) {
(void) param; (void) param;
chRegSetThreadName("board test blinking"); chRegSetThreadName("board test blinking");
@ -117,9 +125,7 @@ static msg_t ivThread(int param) {
while (TRUE) { while (TRUE) {
chThdSleepMilliseconds(250); chThdSleepMilliseconds(250);
value = 1 - value; value = 1 - value;
GPIO_TypeDef *hwPort = getHwPort(currentPin); setCurrentPinValue(value);
uint32_t hwPin = getHwPin(currentPin);
palWritePad(hwPort, hwPin, value);
} }
#if defined __GNUC__ #if defined __GNUC__
return 0; return 0;
@ -144,13 +150,48 @@ void printBoardTestState(void) {
} }
} }
static void btInitOutputPins() {
for (int i = 0; i < pinsCount; i++) {
currentPin = BLINK_PINS[i];
mySetPadMode2("test", currentPin, PAL_STM32_MODE_OUTPUT);
}
}
static void blinkAllOutputPins() {
for (int k = 0; k < 6; k++) {
for (int i = 0; i < pinsCount; i++) {
currentPin = BLINK_PINS[i];
setCurrentPinValue(k % 2);
}
chThdSleepMilliseconds(250);
}
currentPin = GPIO_UNASSIGNED;
/**
* Now let's blink all pins one by one
*/
for (int k = 0; k < 2; k++) {
for (int i = 0; i < pinsCount; i++) {
if (currentPin != GPIO_UNASSIGNED)
setCurrentPinValue(false); // turn off previous pin
currentPin = BLINK_PINS[i];
setCurrentPinValue(true);
chThdSleepMilliseconds(250);
}
}
setCurrentPinValue(false);
currentPin = GPIO_UNASSIGNED;
}
void initBoardTest(void) { void initBoardTest(void) {
is_board_test_mode = true; is_board_test_mode = true;
addConsoleAction("n", nextStep); addConsoleAction("n", nextStep);
addConsoleActionI("set", setIndex); addConsoleActionI("set", setIndex);
chThdCreateStatic(btThreadStack, sizeof(btThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL); btInitOutputPins();
blinkAllOutputPins();
chThdCreateStatic(btThreadStack, sizeof(btThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL);
// this code is ugly as hell, I had no time to think. Todo: refactor // this code is ugly as hell, I had no time to think. Todo: refactor
#if HAL_USE_ADC || defined(__DOXYGEN__) #if HAL_USE_ADC || defined(__DOXYGEN__)
@ -163,12 +204,10 @@ void initBoardTest(void) {
currentIndex = 0; currentIndex = 0;
int pinsCount = sizeof(BLINK_PINS) / sizeof(brain_pin_e);
while (currentIndex < pinsCount) { while (currentIndex < pinsCount) {
currentPin = BLINK_PINS[currentIndex]; currentPin = BLINK_PINS[currentIndex];
printBoardTestState(); printBoardTestState();
mySetPadMode2("test", currentPin, PAL_STM32_MODE_OUTPUT);
currentIndex++; currentIndex++;
waitForKey(); waitForKey();

View File

@ -1904,6 +1904,12 @@
<name>config</name> <name>config</name>
<group> <group>
<name>engines</name> <name>engines</name>
<file>
<name>$PROJ_DIR$\..\config\engines\acura_rsx.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\config\engines\acura_rsx.h</name>
</file>
<file> <file>
<name>$PROJ_DIR$\..\config\engines\audi_aan.cpp</name> <name>$PROJ_DIR$\..\config\engines\audi_aan.cpp</name>
</file> </file>
@ -1922,6 +1928,12 @@
<file> <file>
<name>$PROJ_DIR$\..\config\engines\citroenBerlingoTU3JP.h</name> <name>$PROJ_DIR$\..\config\engines\citroenBerlingoTU3JP.h</name>
</file> </file>
<file>
<name>$PROJ_DIR$\..\config\engines\custom_engine.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\config\engines\custom_engine.h</name>
</file>
<file> <file>
<name>$PROJ_DIR$\..\config\engines\dodge_neon.cpp</name> <name>$PROJ_DIR$\..\config\engines\dodge_neon.cpp</name>
</file> </file>
@ -1967,6 +1979,12 @@
<file> <file>
<name>$PROJ_DIR$\..\config\engines\mazda_323.h</name> <name>$PROJ_DIR$\..\config\engines\mazda_323.h</name>
</file> </file>
<file>
<name>$PROJ_DIR$\..\config\engines\mazda_626.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\config\engines\mazda_626.h</name>
</file>
<file> <file>
<name>$PROJ_DIR$\..\config\engines\mazda_miata.cpp</name> <name>$PROJ_DIR$\..\config\engines\mazda_miata.cpp</name>
</file> </file>

View File

@ -262,5 +262,5 @@ int getRusEfiVersion(void) {
return 1; // this is here to make the compiler happy about the unused array return 1; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE == 0) if (UNUSED_CCM_SIZE == 0)
return 1; // this is here to make the compiler happy about the unused array return 1; // this is here to make the compiler happy about the unused array
return 20150123; return 20150124;
} }