diff --git a/.gitignore b/.gitignore index 8c83e5cc..7f16f71a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ reference/hardware/v0.4/gerbers/Archive.zip .vscode/c_cpp_properties.json .vscode/launch.json .vscode/.browse.c_cpp.db* -*samd21.* +speeduino/*samd21.* diff --git a/speeduino/auxiliaries.h b/speeduino/auxiliaries.h index db537d3f..c3d582b8 100644 --- a/speeduino/auxiliaries.h +++ b/speeduino/auxiliaries.h @@ -12,46 +12,6 @@ void initialiseFan(); void nitrousControl(); void fanControl(); -#if defined(CORE_AVR) - #define ENABLE_BOOST_TIMER() TIMSK1 |= (1 << OCIE1A) - #define DISABLE_BOOST_TIMER() TIMSK1 &= ~(1 << OCIE1A) - #define ENABLE_VVT_TIMER() TIMSK1 |= (1 << OCIE1B) - #define DISABLE_VVT_TIMER() TIMSK1 &= ~(1 << OCIE1B) - - #define BOOST_TIMER_COMPARE OCR1A - #define BOOST_TIMER_COUNTER TCNT1 - #define VVT_TIMER_COMPARE OCR1B - #define VVT_TIMER_COUNTER TCNT1 - -#elif defined(CORE_TEENSY) - - -#elif defined(CORE_STM32) - #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core - #define ENABLE_BOOST_TIMER() (TIM1)->CCER |= TIM_CCER_CC2E - #define DISABLE_BOOST_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC2E - - #define ENABLE_VVT_TIMER() (TIM1)->CCER |= TIM_CCER_CC3E - #define DISABLE_VVT_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC3E - - #define BOOST_TIMER_COMPARE (TIM1)->CCR2 - #define BOOST_TIMER_COUNTER (TIM1)->CNT - #define VVT_TIMER_COMPARE (TIM1)->CCR3 - #define VVT_TIMER_COUNTER (TIM1)->CNT - #else //libmaple core aka STM32DUINO - #define ENABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC2E - #define DISABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC2E - - #define ENABLE_VVT_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC3E - #define DISABLE_VVT_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC3E - - #define BOOST_TIMER_COMPARE (TIMER1->regs).gen->CCR2 - #define BOOST_TIMER_COUNTER (TIMER1->regs).gen->CNT - #define VVT_TIMER_COMPARE (TIMER1->regs).gen->CCR3 - #define VVT_TIMER_COUNTER (TIMER1->regs).gen->CNT - #endif -#endif - #define BOOST_PIN_LOW() *boost_pin_port &= ~(boost_pin_mask) #define BOOST_PIN_HIGH() *boost_pin_port |= (boost_pin_mask) #define VVT_PIN_LOW() *vvt_pin_port &= ~(vvt_pin_mask) @@ -91,10 +51,8 @@ volatile bool vvt_pwm_state; unsigned int vvt_pwm_max_count; //Used for variable PWM frequency volatile unsigned int vvt_pwm_cur_value; long vvt_pwm_target_value; -#if defined (CORE_TEENSY) || defined(CORE_STM32) - static inline void boostInterrupt(); - static inline void vvtInterrupt(); -#endif +static inline void boostInterrupt(); +static inline void vvtInterrupt(); #endif diff --git a/speeduino/board_avr2560.h b/speeduino/board_avr2560.h index 5d922e8c..006d79fd 100644 --- a/speeduino/board_avr2560.h +++ b/speeduino/board_avr2560.h @@ -9,5 +9,121 @@ #define PORT_TYPE uint8_t //Size of the port variables (Eg inj1_pin_port). void initBoard(); +/* +*********************************************************************************************************** +* Schedules +*/ + #include + #include + + //Refer to http://svn.savannah.nongnu.org/viewvc/trunk/avr-libc/include/avr/iomxx0_1.h?root=avr-libc&view=markup + #define FUEL1_COUNTER TCNT3 + #define FUEL2_COUNTER TCNT3 + #define FUEL3_COUNTER TCNT3 + #define FUEL4_COUNTER TCNT4 + #define FUEL5_COUNTER TCNT1 + #define FUEL6_COUNTER TCNT4 //Replaces ignition 4 + #define FUEL7_COUNTER TCNT5 //Replaces ignition 3 + #define FUEL8_COUNTER TCNT5 //Replaces ignition 2 + + #define IGN1_COUNTER TCNT5 + #define IGN2_COUNTER TCNT5 + #define IGN3_COUNTER TCNT5 + #define IGN4_COUNTER TCNT4 + #define IGN5_COUNTER TCNT1 + #define IGN6_COUNTER TCNT4 //Replaces injector 4 + #define IGN7_COUNTER TCNT3 //Replaces injector 3 + #define IGN8_COUNTER TCNT3 //Replaces injector 2 + + #define FUEL1_COMPARE OCR3A + #define FUEL2_COMPARE OCR3B + #define FUEL3_COMPARE OCR3C + #define FUEL4_COMPARE OCR4B + #define FUEL5_COMPARE OCR1C //Shared with FUEL1 + #define FUEL6_COMPARE OCR4A //Replaces ignition4 + #define FUEL7_COMPARE OCR5C //Replaces ignition3 + #define FUEL8_COMPARE OCR5B //Replaces ignition2 + + #define IGN1_COMPARE OCR5A + #define IGN2_COMPARE OCR5B + #define IGN3_COMPARE OCR5C + #define IGN4_COMPARE OCR4A + #define IGN5_COMPARE OCR1C + #define IGN6_COMPARE OCR4B //Replaces injector 4 + #define IGN7_COMPARE OCR3C //Replaces injector 3 + #define IGN8_COMPARE OCR3B //Replaces injector 2 + + #define FUEL1_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3A) //Turn on the A compare unit (ie turn on the interrupt) + #define FUEL2_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3B) //Turn on the B compare unit (ie turn on the interrupt) + #define FUEL3_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3C) //Turn on the C compare unit (ie turn on the interrupt) + #define FUEL4_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4B) //Turn on the B compare unit (ie turn on the interrupt) + #define FUEL5_TIMER_ENABLE() TIMSK1 |= (1 << OCIE1C) // + #define FUEL6_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4A) // + #define FUEL7_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5C) // + #define FUEL8_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5B) // + + #define FUEL1_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3A); //Turn off this output compare unit + #define FUEL2_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3B); //Turn off this output compare unit + #define FUEL3_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3C); //Turn off this output compare unit + #define FUEL4_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4B); //Turn off this output compare unit + #define FUEL5_TIMER_DISABLE() TIMSK1 &= ~(1 << OCIE1C); // + #define FUEL6_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4A); // + #define FUEL7_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5C); // + #define FUEL8_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5B); // + + #define IGN1_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5A) //Turn on the A compare unit (ie turn on the interrupt) + #define IGN2_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5B) //Turn on the B compare unit (ie turn on the interrupt) + #define IGN3_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5C) //Turn on the C compare unit (ie turn on the interrupt) + #define IGN4_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4A) //Turn on the A compare unit (ie turn on the interrupt) + #define IGN5_TIMER_ENABLE() TIMSK1 |= (1 << OCIE1C) //Turn on the A compare unit (ie turn on the interrupt) + #define IGN6_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4B) //Replaces injector 4 + #define IGN7_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3C) //Replaces injector 3 + #define IGN8_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3B) //Replaces injector 2 + + #define IGN1_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5A) //Turn off this output compare unit + #define IGN2_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5B) //Turn off this output compare unit + #define IGN3_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5C) //Turn off this output compare unit + #define IGN4_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4A) //Turn off this output compare unit + #define IGN5_TIMER_DISABLE() TIMSK1 &= ~(1 << OCIE1C) //Turn off this output compare unit + #define IGN6_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4B) //Replaces injector 4 + #define IGN7_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3C) //Replaces injector 3 + #define IGN8_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3B) //Replaces injector 2 + + #define MAX_TIMER_PERIOD 262140UL //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 4, as each timer tick is 4uS) + #define MAX_TIMER_PERIOD_SLOW 1048560UL //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 16, as each timer tick is 16uS) + #define uS_TO_TIMER_COMPARE(uS1) (uS1 >> 2) //Converts a given number of uS into the required number of timer ticks until that time has passed + //This is a hack until I make all the AVR timers run at the same speed + #define uS_TO_TIMER_COMPARE_SLOW(uS1) (uS1 >> 4) + +/* +*********************************************************************************************************** +* Auxilliaries +*/ + #define ENABLE_BOOST_TIMER() TIMSK1 |= (1 << OCIE1A) + #define DISABLE_BOOST_TIMER() TIMSK1 &= ~(1 << OCIE1A) + #define ENABLE_VVT_TIMER() TIMSK1 |= (1 << OCIE1B) + #define DISABLE_VVT_TIMER() TIMSK1 &= ~(1 << OCIE1B) + + #define BOOST_TIMER_COMPARE OCR1A + #define BOOST_TIMER_COUNTER TCNT1 + #define VVT_TIMER_COMPARE OCR1B + #define VVT_TIMER_COUNTER TCNT1 + +/* +*********************************************************************************************************** +* Idle +*/ + #define IDLE_COUNTER TCNT4 + #define IDLE_COMPARE OCR4C + + #define IDLE_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4C) + #define IDLE_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4C) + +/* +*********************************************************************************************************** +* CAN / Second serial +*/ + + #endif //CORE_AVR #endif //AVR2560_H diff --git a/speeduino/board_samd21.h b/speeduino/board_samd21.h index 79eb558e..cb619856 100644 --- a/speeduino/board_samd21.h +++ b/speeduino/board_samd21.h @@ -1,4 +1,4 @@ - #ifndef SAMD21_H +#ifndef SAMD21_H #define SAMD21_H #if defined(CORE_SAMD21) @@ -18,6 +18,7 @@ #define PIN_A7 (9ul) #define PIN_A8 (10ul) #define PIN_A9 (11ul) + //These don't work: #define PIN_A13 (9ul) #define PIN_A14 (9ul) #define PIN_A15 (9ul) diff --git a/speeduino/board_stm32.h b/speeduino/board_stm32.h index 7e9c12ae..d224b87e 100644 --- a/speeduino/board_stm32.h +++ b/speeduino/board_stm32.h @@ -9,24 +9,270 @@ #define PORT_TYPE uint8_t void initBoard(); + //Much of the below is not correct, but included to allow compilation + //STM32F1/variants/.../board.cpp + #if defined (STM32F4) + #define A0 PA0 + #define A1 PA1 + #define A2 PA2 + #define A3 PA3 + #define A4 PA4 + #define A5 PA5 + #define A6 PA6 + #define A7 PA7 + #define A8 PB0 + #define A9 PB1 + #define A10 PC0 + #define A11 PC1 + #define A12 PC2 + #define A13 PC3 + #define A14 PC4 + #define A15 PC5 + #else + #define A0 PB0 + #define A1 PA7 + #define A2 PA6 + #define A3 PA5 + #define A4 PA4 + #define A5 PA3 + #define A6 PA2 + #define A7 PA1 + #define A8 PA0 + //STM32F1 have only 9 12bit adc + #define A9 PB0 + #define A10 PA7 + #define A11 PA6 + #define A12 PA5 + #define A13 PA4 + #define A14 PA3 + #define A15 PA2 + #endif + /* *********************************************************************************************************** * Schedules */ - + #define MAX_TIMER_PERIOD 131070 //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 2, as each timer tick is 2uS) + #define MAX_TIMER_PERIOD_SLOW 131070 //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 2, as each timer tick is 2uS) + #define uS_TO_TIMER_COMPARE(uS) (uS >> 1) //Converts a given number of uS into the required number of timer ticks until that time has passed. + #define uS_TO_TIMER_COMPARE_SLOW(uS) (uS >> 1) //Converts a given number of uS into the required number of timer ticks until that time has passed. + #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core + #include "HardwareTimer.h" + #define FUEL1_COUNTER (TIM2)->CNT + #define FUEL2_COUNTER (TIM2)->CNT + #define FUEL3_COUNTER (TIM2)->CNT + #define FUEL4_COUNTER (TIM2)->CNT + + #define FUEL1_COMPARE (TIM2)->CCR1 + #define FUEL2_COMPARE (TIM2)->CCR2 + #define FUEL3_COMPARE (TIM2)->CCR3 + #define FUEL4_COMPARE (TIM2)->CCR4 + + #define IGN1_COUNTER (TIM3)->CNT + #define IGN2_COUNTER (TIM3)->CNT + #define IGN3_COUNTER (TIM3)->CNT + #define IGN4_COUNTER (TIM3)->CNT + + #define IGN1_COMPARE (TIM3)->CCR1 + #define IGN2_COMPARE (TIM3)->CCR2 + #define IGN3_COMPARE (TIM3)->CCR3 + #define IGN4_COMPARE (TIM3)->CCR4 + + #ifndef SMALL_FLASH_MODE + #define FUEL5_COUNTER (TIM5)->CNT + #define FUEL6_COUNTER (TIM5)->CNT + #define FUEL7_COUNTER (TIM5)->CNT + #define FUEL8_COUNTER (TIM5)->CNT + + #define FUEL5_COMPARE (TIM5)->CCR1 + #define FUEL6_COMPARE (TIM5)->CCR2 + #define FUEL7_COMPARE (TIM5)->CCR3 + #define FUEL8_COMPARE (TIM5)->CCR4 + + #define IGN5_COUNTER (TIM4)->CNT + #define IGN6_COUNTER (TIM4)->CNT + #define IGN7_COUNTER (TIM4)->CNT + #define IGN8_COUNTER (TIM4)->CNT + + #define IGN5_COMPARE (TIM4)->CCR1 + #define IGN6_COMPARE (TIM4)->CCR2 + #define IGN7_COMPARE (TIM4)->CCR3 + #define IGN8_COMPARE (TIM4)->CCR4 + #endif + //https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/754bc2969921f1ef262bd69e7faca80b19db7524/STM32F1/system/libmaple/include/libmaple/timer.h#L444 + #define FUEL1_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC1E + #define FUEL2_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC2E + #define FUEL3_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC3E + #define FUEL4_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC4E + + #define FUEL1_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC1E + #define FUEL2_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC2E + #define FUEL3_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC3E + #define FUEL4_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC4E + + #define IGN1_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC1E + #define IGN2_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC2E + #define IGN3_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC3E + #define IGN4_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC4E + + #define IGN1_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC1E + #define IGN2_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC2E + #define IGN3_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC3E + #define IGN4_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC4E + + #ifndef SMALL_FLASH_MODE + #define FUEL5_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC1E + #define FUEL6_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC2E + #define FUEL7_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC3E + #define FUEL8_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC4E + + #define FUEL5_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC1E + #define FUEL6_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC2E + #define FUEL7_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC3E + #define FUEL8_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC4E + + #define IGN5_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC1E + #define IGN6_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC2E + #define IGN7_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC3E + #define IGN8_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC4E + + #define IGN5_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC1E + #define IGN6_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC2E + #define IGN7_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC3E + #define IGN8_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC4E + #endif + #else //libmaple core aka STM32DUINO + #define FUEL1_COUNTER (TIMER2->regs).gen->CNT + #define FUEL2_COUNTER (TIMER2->regs).gen->CNT + #define FUEL3_COUNTER (TIMER2->regs).gen->CNT + #define FUEL4_COUNTER (TIMER2->regs).gen->CNT + + #define FUEL1_COMPARE (TIMER2->regs).gen->CCR1 + #define FUEL2_COMPARE (TIMER2->regs).gen->CCR2 + #define FUEL3_COMPARE (TIMER2->regs).gen->CCR3 + #define FUEL4_COMPARE (TIMER2->regs).gen->CCR4 + + #define IGN1_COUNTER (TIMER3->regs).gen->CNT + #define IGN2_COUNTER (TIMER3->regs).gen->CNT + #define IGN3_COUNTER (TIMER3->regs).gen->CNT + #define IGN4_COUNTER (TIMER3->regs).gen->CNT + + #define IGN1_COMPARE (TIMER3->regs).gen->CCR1 + #define IGN2_COMPARE (TIMER3->regs).gen->CCR2 + #define IGN3_COMPARE (TIMER3->regs).gen->CCR3 + #define IGN4_COMPARE (TIMER3->regs).gen->CCR4 + + #ifndef SMALL_FLASH_MODE + #define FUEL5_COUNTER (TIMER5->regs).gen->CNT + #define FUEL6_COUNTER (TIMER5->regs).gen->CNT + #define FUEL7_COUNTER (TIMER5->regs).gen->CNT + #define FUEL8_COUNTER (TIMER5->regs).gen->CNT + + #define FUEL5_COMPARE (TIMER5->regs).gen->CCR1 + #define FUEL6_COMPARE (TIMER5->regs).gen->CCR2 + #define FUEL7_COMPARE (TIMER5->regs).gen->CCR3 + #define FUEL8_COMPARE (TIMER5->regs).gen->CCR4 + + #define IGN5_COUNTER (TIMER4->regs).gen->CNT + #define IGN6_COUNTER (TIMER4->regs).gen->CNT + #define IGN7_COUNTER (TIMER4->regs).gen->CNT + #define IGN8_COUNTER (TIMER4->regs).gen->CNT + + #define IGN5_COMPARE (TIMER4->regs).gen->CCR1 + #define IGN6_COMPARE (TIMER4->regs).gen->CCR2 + #define IGN7_COMPARE (TIMER4->regs).gen->CCR3 + #define IGN8_COMPARE (TIMER4->regs).gen->CCR4 + #endif + //https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/754bc2969921f1ef262bd69e7faca80b19db7524/STM32F1/system/libmaple/include/libmaple/timer.h#L444 + #define FUEL1_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC1E + #define FUEL2_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC2E + #define FUEL3_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC3E + #define FUEL4_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC4E + + #define FUEL1_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC1E + #define FUEL2_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC2E + #define FUEL3_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC3E + #define FUEL4_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC4E + + #define IGN1_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC1E + #define IGN2_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC2E + #define IGN3_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC3E + #define IGN4_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC4E + + #define IGN1_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC1E + #define IGN2_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC2E + #define IGN3_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC3E + #define IGN4_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC4E + + #ifndef SMALL_FLASH_MODE + #define FUEL5_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC1E + #define FUEL6_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC2E + #define FUEL7_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC3E + #define FUEL8_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC4E + + #define IGN5_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC1E + #define IGN6_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC2E + #define IGN7_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC3E + #define IGN8_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC4E + + #define FUEL5_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC1E + #define FUEL6_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC2E + #define FUEL7_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC3E + #define FUEL8_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC4E + + #define IGN5_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC1E + #define IGN6_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC2E + #define IGN7_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC3E + #define IGN8_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC4E + #endif +#endif /* *********************************************************************************************************** * Auxilliaries */ - + #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core + #define ENABLE_BOOST_TIMER() (TIM1)->CCER |= TIM_CCER_CC2E + #define DISABLE_BOOST_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC2E + + #define ENABLE_VVT_TIMER() (TIM1)->CCER |= TIM_CCER_CC3E + #define DISABLE_VVT_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC3E + + #define BOOST_TIMER_COMPARE (TIM1)->CCR2 + #define BOOST_TIMER_COUNTER (TIM1)->CNT + #define VVT_TIMER_COMPARE (TIM1)->CCR3 + #define VVT_TIMER_COUNTER (TIM1)->CNT + #else //libmaple core aka STM32DUINO + #define ENABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC2E + #define DISABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC2E + + #define ENABLE_VVT_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC3E + #define DISABLE_VVT_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC3E + + #define BOOST_TIMER_COMPARE (TIMER1->regs).gen->CCR2 + #define BOOST_TIMER_COUNTER (TIMER1->regs).gen->CNT + #define VVT_TIMER_COMPARE (TIMER1->regs).gen->CCR3 + #define VVT_TIMER_COUNTER (TIMER1->regs).gen->CNT + #endif /* *********************************************************************************************************** * Idle */ - + #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core + #define IDLE_COUNTER (TIM1)->CNT + #define IDLE_COMPARE (TIM1)->CCR4 + + #define IDLE_TIMER_ENABLE() (TIM1)->CCER |= TIM_CCER_CC4E + #define IDLE_TIMER_DISABLE() (TIM1)->CCER &= ~TIM_CCER_CC4E + #else //libmaple core aka STM32DUINO + #define IDLE_COUNTER (TIMER1->regs).gen->CNT + #define IDLE_COMPARE (TIMER1->regs).gen->CCR4 + + #define IDLE_TIMER_ENABLE() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC4E + #define IDLE_TIMER_DISABLE() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC4E + #endif /* *********************************************************************************************************** diff --git a/speeduino/idle.h b/speeduino/idle.h index 9d1d21ca..243d6b0c 100644 --- a/speeduino/idle.h +++ b/speeduino/idle.h @@ -28,33 +28,6 @@ struct StepperIdle byte moreAirDirection; }; -#if defined(CORE_AVR) - #define IDLE_COUNTER TCNT4 - #define IDLE_COMPARE OCR4C - - #define IDLE_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4C) - #define IDLE_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4C) - -#elif defined(CORE_TEENSY) - - -#elif defined(CORE_STM32) - #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core - #define IDLE_COUNTER (TIM1)->CNT - #define IDLE_COMPARE (TIM1)->CCR4 - - #define IDLE_TIMER_ENABLE() (TIM1)->CCER |= TIM_CCER_CC4E - #define IDLE_TIMER_DISABLE() (TIM1)->CCER &= ~TIM_CCER_CC4E - #else //libmaple core aka STM32DUINO - #define IDLE_COUNTER (TIMER1->regs).gen->CNT - #define IDLE_COMPARE (TIMER1->regs).gen->CCR4 - - #define IDLE_TIMER_ENABLE() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC4E - #define IDLE_TIMER_DISABLE() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC4E - #endif - -#endif - struct table2D iacClosedLoopTable; struct table2D iacPWMTable; struct table2D iacStepTable; @@ -87,8 +60,6 @@ static inline void enableIdle(); static inline byte isStepperHomed(); static inline byte checkForStepping(); static inline void doStep(); -#if defined(CORE_STM32) - static inline void idleInterrupt(); -#endif +static inline void idleInterrupt(); #endif diff --git a/speeduino/scheduler.h b/speeduino/scheduler.h index ffb1b82c..f185181a 100644 --- a/speeduino/scheduler.h +++ b/speeduino/scheduler.h @@ -27,268 +27,6 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd #define USE_IGN_REFRESH #define IGNITION_REFRESH_THRESHOLD 30 //Time in uS that the refresh functions will check to ensure there is enough time before changing the end compare -#if defined(CORE_AVR) - #include - #include - - //Refer to http://svn.savannah.nongnu.org/viewvc/trunk/avr-libc/include/avr/iomxx0_1.h?root=avr-libc&view=markup - #define FUEL1_COUNTER TCNT3 - #define FUEL2_COUNTER TCNT3 - #define FUEL3_COUNTER TCNT3 - #define FUEL4_COUNTER TCNT4 - #define FUEL5_COUNTER TCNT1 - #define FUEL6_COUNTER TCNT4 //Replaces ignition 4 - #define FUEL7_COUNTER TCNT5 //Replaces ignition 3 - #define FUEL8_COUNTER TCNT5 //Replaces ignition 2 - - #define IGN1_COUNTER TCNT5 - #define IGN2_COUNTER TCNT5 - #define IGN3_COUNTER TCNT5 - #define IGN4_COUNTER TCNT4 - #define IGN5_COUNTER TCNT1 - #define IGN6_COUNTER TCNT4 //Replaces injector 4 - #define IGN7_COUNTER TCNT3 //Replaces injector 3 - #define IGN8_COUNTER TCNT3 //Replaces injector 2 - - #define FUEL1_COMPARE OCR3A - #define FUEL2_COMPARE OCR3B - #define FUEL3_COMPARE OCR3C - #define FUEL4_COMPARE OCR4B - #define FUEL5_COMPARE OCR1C //Shared with FUEL1 - #define FUEL6_COMPARE OCR4A //Replaces ignition4 - #define FUEL7_COMPARE OCR5C //Replaces ignition3 - #define FUEL8_COMPARE OCR5B //Replaces ignition2 - - #define IGN1_COMPARE OCR5A - #define IGN2_COMPARE OCR5B - #define IGN3_COMPARE OCR5C - #define IGN4_COMPARE OCR4A - #define IGN5_COMPARE OCR1C - #define IGN6_COMPARE OCR4B //Replaces injector 4 - #define IGN7_COMPARE OCR3C //Replaces injector 3 - #define IGN8_COMPARE OCR3B //Replaces injector 2 - - #define FUEL1_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3A) //Turn on the A compare unit (ie turn on the interrupt) - #define FUEL2_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3B) //Turn on the B compare unit (ie turn on the interrupt) - #define FUEL3_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3C) //Turn on the C compare unit (ie turn on the interrupt) - #define FUEL4_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4B) //Turn on the B compare unit (ie turn on the interrupt) - #define FUEL5_TIMER_ENABLE() TIMSK1 |= (1 << OCIE1C) // - #define FUEL6_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4A) // - #define FUEL7_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5C) // - #define FUEL8_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5B) // - - #define FUEL1_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3A); //Turn off this output compare unit - #define FUEL2_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3B); //Turn off this output compare unit - #define FUEL3_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3C); //Turn off this output compare unit - #define FUEL4_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4B); //Turn off this output compare unit - #define FUEL5_TIMER_DISABLE() TIMSK1 &= ~(1 << OCIE1C); // - #define FUEL6_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4A); // - #define FUEL7_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5C); // - #define FUEL8_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5B); // - - #define IGN1_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5A) //Turn on the A compare unit (ie turn on the interrupt) - #define IGN2_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5B) //Turn on the B compare unit (ie turn on the interrupt) - #define IGN3_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5C) //Turn on the C compare unit (ie turn on the interrupt) - #define IGN4_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4A) //Turn on the A compare unit (ie turn on the interrupt) - #define IGN5_TIMER_ENABLE() TIMSK1 |= (1 << OCIE1C) //Turn on the A compare unit (ie turn on the interrupt) - #define IGN6_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4B) //Replaces injector 4 - #define IGN7_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3C) //Replaces injector 3 - #define IGN8_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3B) //Replaces injector 2 - - #define IGN1_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5A) //Turn off this output compare unit - #define IGN2_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5B) //Turn off this output compare unit - #define IGN3_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5C) //Turn off this output compare unit - #define IGN4_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4A) //Turn off this output compare unit - #define IGN5_TIMER_DISABLE() TIMSK1 &= ~(1 << OCIE1C) //Turn off this output compare unit - #define IGN6_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4B) //Replaces injector 4 - #define IGN7_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3C) //Replaces injector 3 - #define IGN8_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3B) //Replaces injector 2 - - #define MAX_TIMER_PERIOD 262140UL //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 4, as each timer tick is 4uS) - #define MAX_TIMER_PERIOD_SLOW 1048560UL //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 16, as each timer tick is 16uS) - #define uS_TO_TIMER_COMPARE(uS1) (uS1 >> 2) //Converts a given number of uS into the required number of timer ticks until that time has passed - //This is a hack until I make all the AVR timers run at the same speed - #define uS_TO_TIMER_COMPARE_SLOW(uS1) (uS1 >> 4) - -#elif defined(CORE_TEENSY) - - -#elif defined(CORE_STM32) - #define MAX_TIMER_PERIOD 131070 //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 2, as each timer tick is 2uS) - #define MAX_TIMER_PERIOD_SLOW 131070 //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 2, as each timer tick is 2uS) - #define uS_TO_TIMER_COMPARE(uS) (uS >> 1) //Converts a given number of uS into the required number of timer ticks until that time has passed. - #define uS_TO_TIMER_COMPARE_SLOW(uS) (uS >> 1) //Converts a given number of uS into the required number of timer ticks until that time has passed. - #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core - #include "HardwareTimer.h" - #define FUEL1_COUNTER (TIM2)->CNT - #define FUEL2_COUNTER (TIM2)->CNT - #define FUEL3_COUNTER (TIM2)->CNT - #define FUEL4_COUNTER (TIM2)->CNT - - #define FUEL1_COMPARE (TIM2)->CCR1 - #define FUEL2_COMPARE (TIM2)->CCR2 - #define FUEL3_COMPARE (TIM2)->CCR3 - #define FUEL4_COMPARE (TIM2)->CCR4 - - #define IGN1_COUNTER (TIM3)->CNT - #define IGN2_COUNTER (TIM3)->CNT - #define IGN3_COUNTER (TIM3)->CNT - #define IGN4_COUNTER (TIM3)->CNT - - #define IGN1_COMPARE (TIM3)->CCR1 - #define IGN2_COMPARE (TIM3)->CCR2 - #define IGN3_COMPARE (TIM3)->CCR3 - #define IGN4_COMPARE (TIM3)->CCR4 - -#ifndef SMALL_FLASH_MODE - #define FUEL5_COUNTER (TIM5)->CNT - #define FUEL6_COUNTER (TIM5)->CNT - #define FUEL7_COUNTER (TIM5)->CNT - #define FUEL8_COUNTER (TIM5)->CNT - - #define FUEL5_COMPARE (TIM5)->CCR1 - #define FUEL6_COMPARE (TIM5)->CCR2 - #define FUEL7_COMPARE (TIM5)->CCR3 - #define FUEL8_COMPARE (TIM5)->CCR4 - - #define IGN5_COUNTER (TIM4)->CNT - #define IGN6_COUNTER (TIM4)->CNT - #define IGN7_COUNTER (TIM4)->CNT - #define IGN8_COUNTER (TIM4)->CNT - - #define IGN5_COMPARE (TIM4)->CCR1 - #define IGN6_COMPARE (TIM4)->CCR2 - #define IGN7_COMPARE (TIM4)->CCR3 - #define IGN8_COMPARE (TIM4)->CCR4 -#endif - //https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/754bc2969921f1ef262bd69e7faca80b19db7524/STM32F1/system/libmaple/include/libmaple/timer.h#L444 - #define FUEL1_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC1E - #define FUEL2_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC2E - #define FUEL3_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC3E - #define FUEL4_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC4E - - #define FUEL1_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC1E - #define FUEL2_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC2E - #define FUEL3_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC3E - #define FUEL4_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC4E - - #define IGN1_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC1E - #define IGN2_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC2E - #define IGN3_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC3E - #define IGN4_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC4E - - #define IGN1_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC1E - #define IGN2_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC2E - #define IGN3_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC3E - #define IGN4_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC4E - -#ifndef SMALL_FLASH_MODE - #define FUEL5_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC1E - #define FUEL6_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC2E - #define FUEL7_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC3E - #define FUEL8_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC4E - - #define FUEL5_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC1E - #define FUEL6_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC2E - #define FUEL7_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC3E - #define FUEL8_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC4E - - #define IGN5_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC1E - #define IGN6_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC2E - #define IGN7_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC3E - #define IGN8_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC4E - - #define IGN5_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC1E - #define IGN6_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC2E - #define IGN7_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC3E - #define IGN8_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC4E -#endif - #else //libmaple core aka STM32DUINO - #define FUEL1_COUNTER (TIMER2->regs).gen->CNT - #define FUEL2_COUNTER (TIMER2->regs).gen->CNT - #define FUEL3_COUNTER (TIMER2->regs).gen->CNT - #define FUEL4_COUNTER (TIMER2->regs).gen->CNT - - #define FUEL1_COMPARE (TIMER2->regs).gen->CCR1 - #define FUEL2_COMPARE (TIMER2->regs).gen->CCR2 - #define FUEL3_COMPARE (TIMER2->regs).gen->CCR3 - #define FUEL4_COMPARE (TIMER2->regs).gen->CCR4 - - #define IGN1_COUNTER (TIMER3->regs).gen->CNT - #define IGN2_COUNTER (TIMER3->regs).gen->CNT - #define IGN3_COUNTER (TIMER3->regs).gen->CNT - #define IGN4_COUNTER (TIMER3->regs).gen->CNT - - #define IGN1_COMPARE (TIMER3->regs).gen->CCR1 - #define IGN2_COMPARE (TIMER3->regs).gen->CCR2 - #define IGN3_COMPARE (TIMER3->regs).gen->CCR3 - #define IGN4_COMPARE (TIMER3->regs).gen->CCR4 - -#ifndef SMALL_FLASH_MODE - #define FUEL5_COUNTER (TIMER5->regs).gen->CNT - #define FUEL6_COUNTER (TIMER5->regs).gen->CNT - #define FUEL7_COUNTER (TIMER5->regs).gen->CNT - #define FUEL8_COUNTER (TIMER5->regs).gen->CNT - - #define FUEL5_COMPARE (TIMER5->regs).gen->CCR1 - #define FUEL6_COMPARE (TIMER5->regs).gen->CCR2 - #define FUEL7_COMPARE (TIMER5->regs).gen->CCR3 - #define FUEL8_COMPARE (TIMER5->regs).gen->CCR4 - - #define IGN5_COUNTER (TIMER4->regs).gen->CNT - #define IGN6_COUNTER (TIMER4->regs).gen->CNT - #define IGN7_COUNTER (TIMER4->regs).gen->CNT - #define IGN8_COUNTER (TIMER4->regs).gen->CNT - - #define IGN5_COMPARE (TIMER4->regs).gen->CCR1 - #define IGN6_COMPARE (TIMER4->regs).gen->CCR2 - #define IGN7_COMPARE (TIMER4->regs).gen->CCR3 - #define IGN8_COMPARE (TIMER4->regs).gen->CCR4 -#endif - //https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/754bc2969921f1ef262bd69e7faca80b19db7524/STM32F1/system/libmaple/include/libmaple/timer.h#L444 - #define FUEL1_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC1E - #define FUEL2_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC2E - #define FUEL3_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC3E - #define FUEL4_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC4E - - #define FUEL1_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC1E - #define FUEL2_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC2E - #define FUEL3_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC3E - #define FUEL4_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC4E - - #define IGN1_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC1E - #define IGN2_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC2E - #define IGN3_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC3E - #define IGN4_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC4E - - #define IGN1_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC1E - #define IGN2_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC2E - #define IGN3_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC3E - #define IGN4_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC4E - -#ifndef SMALL_FLASH_MODE - #define FUEL5_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC1E - #define FUEL6_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC2E - #define FUEL7_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC3E - #define FUEL8_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC4E - - #define IGN5_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC1E - #define IGN6_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC2E - #define IGN7_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC3E - #define IGN8_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC4E - - #define FUEL5_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC1E - #define FUEL6_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC2E - #define FUEL7_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC3E - #define FUEL8_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC4E - - #define IGN5_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC1E - #define IGN6_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC2E - #define IGN7_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC3E - #define IGN8_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC4E -#endif - #endif -#endif void initialiseSchedulers(); void setFuelSchedule1(unsigned long timeout, unsigned long duration); diff --git a/speeduino/utils.h b/speeduino/utils.h index 46e14c06..6878f388 100644 --- a/speeduino/utils.h +++ b/speeduino/utils.h @@ -10,45 +10,5 @@ uint16_t freeRam (); void setResetControlPinState(); byte pinTranslate(byte); -//This is dumb, but it'll do for now to get things compiling -#if defined(CORE_STM32) - //STM32F1/variants/.../board.cpp - #if defined (STM32F4) - #define A0 PA0 - #define A1 PA1 - #define A2 PA2 - #define A3 PA3 - #define A4 PA4 - #define A5 PA5 - #define A6 PA6 - #define A7 PA7 - #define A8 PB0 - #define A9 PB1 - #define A10 PC0 - #define A11 PC1 - #define A12 PC2 - #define A13 PC3 - #define A14 PC4 - #define A15 PC5 - #else - #define A0 PB0 - #define A1 PA7 - #define A2 PA6 - #define A3 PA5 - #define A4 PA4 - #define A5 PA3 - #define A6 PA2 - #define A7 PA1 - #define A8 PA0 - //STM32F1 have only 9 12bit adc - #define A9 PB0 - #define A10 PA7 - #define A11 PA6 - #define A12 PA5 - #define A13 PA4 - #define A14 PA3 - #define A15 PA2 - #endif -#endif #endif // UTILS_H