trigger signal debug pins - logic level output #2959
This commit is contained in:
parent
6c8e80285e
commit
b65c4b5612
|
@ -234,7 +234,7 @@ typedef enum __attribute__ ((__packed__)) {
|
|||
TLE6240_PIN_16 = 214,
|
||||
} brain_pin_e;
|
||||
|
||||
/* Plase keep updating these defines */
|
||||
/* Please keep updating these defines */
|
||||
#define BRAIN_PIN_ONCHIP_LAST GPIOI_15
|
||||
#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - GPIOA_0 + 1)
|
||||
#define BRAIN_PIN_LAST TLE8888_PIN_WAKE
|
||||
|
|
|
@ -277,7 +277,7 @@ static void turnOnHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
adcCallbackCounter = 0;
|
||||
#endif /* EFI_FASTER_UNIFORM_ADC */
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
#if EFI_PROD_CODE && EFI_SHAFT_POSITION_INPUT
|
||||
turnOnTriggerInputPins(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
}
|
||||
|
|
|
@ -11,19 +11,47 @@
|
|||
#include "io_pins.h"
|
||||
#include "efi_gpio.h"
|
||||
#include "engine.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
#include "pin_repository.h"
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
|
||||
#include "os_access.h"
|
||||
#include "drivers/gpio/gpio_ext.h"
|
||||
|
||||
#include "pin_repository.h"
|
||||
#include "status_loop.h"
|
||||
#include "engine_configuration.h"
|
||||
#include "console_io.h"
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
|
||||
void efiSetPadUnused(brain_pin_e brainPin) {
|
||||
#if EFI_PROD_CODE
|
||||
/* input with pull up, is it safe? */
|
||||
iomode_t mode = PAL_STM32_MODE_INPUT | PAL_STM32_PUPDR_PULLUP;
|
||||
|
||||
if (brain_pin_is_onchip(brainPin)) {
|
||||
ioportid_t port = getHwPort("unused", brainPin);
|
||||
ioportmask_t pin = getHwPin("unused", brainPin);
|
||||
|
||||
/* input with pull up, is it safe?
|
||||
* todo: shall we reuse 'default state' constants with board.h?
|
||||
* */
|
||||
palSetPadMode(port, pin, mode);
|
||||
palWritePad(port, pin, 0);
|
||||
}
|
||||
#if (BOARD_EXT_GPIOCHIPS > 0)
|
||||
else {
|
||||
gpiochips_setPadMode(brainPin, mode);
|
||||
}
|
||||
#endif
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
brain_pin_markUnused(brainPin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
|
||||
#if EFI_ENGINE_CONTROL
|
||||
#include "main_trigger_callback.h"
|
||||
|
@ -81,30 +109,6 @@ void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)
|
|||
}
|
||||
}
|
||||
|
||||
void efiSetPadUnused(brain_pin_e brainPin)
|
||||
{
|
||||
/* input with pull up, is it safe? */
|
||||
iomode_t mode = PAL_STM32_MODE_INPUT | PAL_STM32_PUPDR_PULLUP;
|
||||
|
||||
if (brain_pin_is_onchip(brainPin)) {
|
||||
ioportid_t port = getHwPort("unused", brainPin);
|
||||
ioportmask_t pin = getHwPin("unused", brainPin);
|
||||
|
||||
/* input with pull up, is it safe?
|
||||
* todo: shall we reuse 'default state' constants with board.h?
|
||||
* */
|
||||
palSetPadMode(port, pin, mode);
|
||||
palWritePad(port, pin, 0);
|
||||
}
|
||||
#if (BOARD_EXT_GPIOCHIPS > 0)
|
||||
else {
|
||||
gpiochips_setPadMode(brainPin, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
brain_pin_markUnused(brainPin);
|
||||
}
|
||||
|
||||
iomode_t getInputMode(pin_input_mode_e mode) {
|
||||
switch (mode) {
|
||||
case PI_PULLUP:
|
||||
|
|
|
@ -9,7 +9,26 @@
|
|||
* @author Andrey Belomutskiy, (c) 2012-2020
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "pin_repository.h"
|
||||
|
||||
static PinRepository pinRepository;
|
||||
|
||||
// todo: move this into PinRepository class
|
||||
static const char *PIN_USED[BRAIN_PIN_TOTAL_PINS];
|
||||
|
||||
unsigned int getBrainPinTotalNum(void) {
|
||||
return BRAIN_PIN_TOTAL_PINS;
|
||||
}
|
||||
|
||||
void initBrainUsedPins(void) {
|
||||
memset(PIN_USED, 0, sizeof(PIN_USED));
|
||||
}
|
||||
|
||||
const char* & getBrainUsedPin(unsigned int idx) {
|
||||
/*if (idx >= getBrainPinTotalNum())
|
||||
return NULL;*/
|
||||
return PIN_USED[idx];
|
||||
}
|
||||
|
||||
/* Common for firmware and unit tests */
|
||||
bool isBrainPinValid(brain_pin_e brainPin)
|
||||
|
@ -24,19 +43,6 @@ bool isBrainPinValid(brain_pin_e brainPin)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#include "os_access.h"
|
||||
#include "pin_repository.h"
|
||||
#include "eficonsole.h"
|
||||
#include "memstreams.h"
|
||||
#include "drivers/gpio/gpio_ext.h"
|
||||
#include "smart_gpio.h"
|
||||
#include "hardware.h"
|
||||
|
||||
EXTERN_CONFIG;
|
||||
|
||||
static PinRepository pinRepository;
|
||||
|
||||
static int brainPin_to_index(brain_pin_e brainPin)
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -52,6 +58,45 @@ static int brainPin_to_index(brain_pin_e brainPin)
|
|||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* See also brain_pin_markUsed()
|
||||
*/
|
||||
|
||||
void brain_pin_markUnused(brain_pin_e brainPin) {
|
||||
#if EFI_PROD_CODE
|
||||
int index = brainPin_to_index(brainPin);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
if (getBrainUsedPin(index) != nullptr)
|
||||
pinRepository.totalPinsUsed--;
|
||||
getBrainUsedPin(index) = nullptr;
|
||||
#endif /* EFI_PROD_CODE */
|
||||
}
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#include "memstreams.h"
|
||||
static MemoryStream portNameStream;
|
||||
static char portNameBuffer[20];
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
PinRepository::PinRepository() {
|
||||
#if EFI_PROD_CODE
|
||||
msObjectInit(&portNameStream, (uint8_t*) portNameBuffer, sizeof(portNameBuffer), 0);
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
initBrainUsedPins();
|
||||
}
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#include "os_access.h"
|
||||
#include "eficonsole.h"
|
||||
#include "drivers/gpio/gpio_ext.h"
|
||||
#include "smart_gpio.h"
|
||||
#include "hardware.h"
|
||||
|
||||
EXTERN_CONFIG;
|
||||
|
||||
static brain_pin_e index_to_brainPin(unsigned int i)
|
||||
{
|
||||
if (i < getBrainPinTotalNum())
|
||||
|
@ -60,15 +105,6 @@ static brain_pin_e index_to_brainPin(unsigned int i)
|
|||
return GPIO_INVALID;
|
||||
}
|
||||
|
||||
static MemoryStream portNameStream;
|
||||
static char portNameBuffer[20];
|
||||
|
||||
PinRepository::PinRepository() {
|
||||
msObjectInit(&portNameStream, (uint8_t*) portNameBuffer, sizeof(portNameBuffer), 0);
|
||||
|
||||
initBrainUsedPins();
|
||||
}
|
||||
|
||||
static void reportPins(void) {
|
||||
for (unsigned int i = 0; i < getBrainPinOnchipNum(); i++) {
|
||||
const char *pin_user = getBrainUsedPin(i);
|
||||
|
@ -230,20 +266,6 @@ bool brain_pin_markUsed(brain_pin_e brainPin, const char *msg) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* See also brain_pin_markUsed()
|
||||
*/
|
||||
|
||||
void brain_pin_markUnused(brain_pin_e brainPin) {
|
||||
int index = brainPin_to_index(brainPin);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
if (getBrainUsedPin(index) != NULL)
|
||||
pinRepository.totalPinsUsed--;
|
||||
getBrainUsedPin(index) = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks on-chip gpio port-pin as used. Works only for on-chip gpios
|
||||
* To be replaced with brain_pin_markUsed later
|
||||
|
|
|
@ -33,9 +33,6 @@ static brain_pin_e portMap[16] = {
|
|||
GPIOA_0, GPIOB_0, GPIOC_0, GPIOD_0, GPIOE_0, GPIOF_0, GPIO_INVALID, GPIOG_0, GPIO_INVALID, GPIO_INVALID, GPIOH_0, GPIOI_0, GPIOJ_0, GPIO_INVALID, GPIO_INVALID, GPIOK_0
|
||||
};
|
||||
|
||||
// todo: move this into PinRepository class
|
||||
static const char *PIN_USED[BRAIN_PIN_TOTAL_PINS];
|
||||
|
||||
#include "pin_repository.h"
|
||||
#include "io_pins.h"
|
||||
|
||||
|
@ -166,18 +163,4 @@ unsigned int getBrainPinOnchipNum(void) {
|
|||
return BRAIN_PIN_ONCHIP_PINS;
|
||||
}
|
||||
|
||||
unsigned int getBrainPinTotalNum(void) {
|
||||
return BRAIN_PIN_TOTAL_PINS;
|
||||
}
|
||||
|
||||
void initBrainUsedPins(void) {
|
||||
memset(PIN_USED, 0, sizeof(PIN_USED));
|
||||
}
|
||||
|
||||
const char* & getBrainUsedPin(unsigned int idx) {
|
||||
/*if (idx >= getBrainPinTotalNum())
|
||||
return NULL;*/
|
||||
return PIN_USED[idx];
|
||||
}
|
||||
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
|
||||
#if EFI_GPIO_HARDWARE
|
||||
|
||||
// todo: move this into PinRepository class
|
||||
static const char *PIN_USED[BRAIN_PIN_TOTAL_PINS];
|
||||
|
||||
// This is the radical departure from STM32
|
||||
#define PORT_SIZE 18
|
||||
|
||||
|
@ -128,18 +125,4 @@ unsigned int getBrainPinOnchipNum(void) {
|
|||
return BRAIN_PIN_ONCHIP_PINS;
|
||||
}
|
||||
|
||||
unsigned int getBrainPinTotalNum(void) {
|
||||
return BRAIN_PIN_TOTAL_PINS;
|
||||
}
|
||||
|
||||
void initBrainUsedPins(void) {
|
||||
memset(PIN_USED, 0, sizeof(PIN_USED));
|
||||
}
|
||||
|
||||
const char* & getBrainUsedPin(unsigned int idx) {
|
||||
/* if (idx >= getBrainPinTotalNum())
|
||||
return NULL; */
|
||||
return PIN_USED[idx];
|
||||
}
|
||||
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
|
||||
#if EFI_GPIO_HARDWARE
|
||||
|
||||
// todo: move this into PinRepository class
|
||||
static const char *PIN_USED[BRAIN_PIN_TOTAL_PINS];
|
||||
|
||||
#define PORT_SIZE 16
|
||||
|
||||
static ioportid_t ports[] = {GPIOA,
|
||||
|
@ -217,18 +214,4 @@ unsigned int getBrainPinOnchipNum(void) {
|
|||
return BRAIN_PIN_ONCHIP_PINS;
|
||||
}
|
||||
|
||||
unsigned int getBrainPinTotalNum(void) {
|
||||
return BRAIN_PIN_TOTAL_PINS;
|
||||
}
|
||||
|
||||
void initBrainUsedPins(void) {
|
||||
memset(PIN_USED, 0, sizeof(PIN_USED));
|
||||
}
|
||||
|
||||
const char* & getBrainUsedPin(unsigned int idx) {
|
||||
/* if (idx >= getBrainPinTotalNum())
|
||||
return NULL; */
|
||||
return PIN_USED[idx];
|
||||
}
|
||||
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
|
Loading…
Reference in New Issue