Set pin trigger hysteresis on T4.1
This commit is contained in:
parent
8794f51550
commit
b8b9cc2780
|
@ -10,6 +10,7 @@
|
|||
uint16_t freeRam();
|
||||
void doSystemReset();
|
||||
void jumpToBootloader();
|
||||
void setTriggerHysteresis();
|
||||
time_t getTeensy3Time();
|
||||
#define PORT_TYPE uint32_t //Size of the port variables
|
||||
#define PINMASK_TYPE uint32_t
|
||||
|
|
|
@ -78,7 +78,9 @@ void initBoard()
|
|||
//2uS resolution Min 8Hz, Max 5KHz
|
||||
boost_pwm_max_count = 1000000L / (2 * configPage6.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte) to allow frequencies up to 511Hz
|
||||
vvt_pwm_max_count = 1000000L / (2 * configPage6.vvtFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle
|
||||
#if defined(PWM_FAN_AVAILABLE)
|
||||
fan_pwm_max_count = 1000000L / (2 * configPage6.vvtFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle
|
||||
#endif
|
||||
|
||||
//TODO: Configure timers here
|
||||
|
||||
|
@ -290,4 +292,24 @@ time_t getTeensy3Time()
|
|||
void doSystemReset() { return; }
|
||||
void jumpToBootloader() { return; }
|
||||
|
||||
void setTriggerHysteresis()
|
||||
{
|
||||
//Refer to digital.c in the Teensyduino core for the following code
|
||||
//Refer also to Pgs 382 and 950 of the iMXRT1060 Reference Manual
|
||||
const struct digital_pin_bitband_and_config_table_struct *p;
|
||||
const uint32_t padConfig = IOMUXC_PAD_DSE(1) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_SPEED(0) | IOMUXC_PAD_HYS;
|
||||
|
||||
//Primary trigger
|
||||
p = digital_pin_to_info_PGM + pinTrigger;
|
||||
*(p->reg + 1) &= ~(p->mask); // TODO: atomic
|
||||
*(p->pad) = padConfig;
|
||||
*(p->mux) = 5 | 0x10;
|
||||
|
||||
//Secondary trigger
|
||||
p = digital_pin_to_info_PGM + pinTrigger2;
|
||||
*(p->reg + 1) &= ~(p->mask); // TODO: atomic
|
||||
*(p->pad) = padConfig;
|
||||
*(p->mux) = 5 | 0x10;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2904,9 +2904,6 @@ void setPinMapping(byte boardID)
|
|||
pinMode(pinBaro, INPUT);
|
||||
#endif
|
||||
#endif
|
||||
pinMode(pinTrigger, INPUT);
|
||||
pinMode(pinTrigger2, INPUT);
|
||||
pinMode(pinTrigger3, INPUT);
|
||||
|
||||
//Each of the below are only set when their relevant function is enabled. This can help prevent pin conflicts that users aren't aware of with unused functions
|
||||
if( (configPage2.flexEnabled > 0) && (!pinIsOutput(pinFlex)) )
|
||||
|
@ -3085,7 +3082,12 @@ void initialiseTriggers(void)
|
|||
pinMode(pinTrigger, INPUT);
|
||||
pinMode(pinTrigger2, INPUT);
|
||||
pinMode(pinTrigger3, INPUT);
|
||||
//digitalWrite(pinTrigger, HIGH);
|
||||
|
||||
#if defined(CORE_TEENSY41)
|
||||
//Teensy 4 requires a HYSTERESIS flag to be set on the trigger pins to prevent false interrupts
|
||||
setTriggerHysteresis();
|
||||
#endif
|
||||
|
||||
detachInterrupt(triggerInterrupt);
|
||||
detachInterrupt(triggerInterrupt2);
|
||||
detachInterrupt(triggerInterrupt3);
|
||||
|
|
Loading…
Reference in New Issue