Fix advanced claimed pin/package timer search
This commit is contained in:
parent
9c38f5dcb1
commit
2bcc5c06c2
@ -89,6 +89,8 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
|
|||||||
|
|
||||||
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
|
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
|
||||||
never_reset_pins[pin_port] |= 1<<pin_number;
|
never_reset_pins[pin_port] |= 1<<pin_number;
|
||||||
|
// Make sure never reset pins are also always claimed
|
||||||
|
claimed_pins[pin_port] |= 1<<pin_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
|
void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
|
||||||
|
@ -99,30 +99,30 @@ void timers_reset(void) {
|
|||||||
|
|
||||||
TIM_TypeDef * stm_peripherals_find_timer(void) {
|
TIM_TypeDef * stm_peripherals_find_timer(void) {
|
||||||
// Check for timers on pins outside the package size
|
// Check for timers on pins outside the package size
|
||||||
// for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
|
for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
|
||||||
// bool timer_in_package = false;
|
bool timer_in_package = false;
|
||||||
// // Find each timer instance on the given bank
|
// Find each timer instance on the given bank
|
||||||
// for (size_t j = 0; j < MP_ARRAY_SIZE(mcu_tim_pin_list); j++) {
|
for (size_t j = 0; j < MP_ARRAY_SIZE(mcu_tim_pin_list); j++) {
|
||||||
// // If a pin is claimed, we skip it
|
// If a pin is claimed, we skip it
|
||||||
// if ( (mcu_tim_pin_list[j].tim_index == i)
|
if ( (mcu_tim_pin_list[j].tim_index == i + 1)
|
||||||
// && (common_hal_mcu_pin_is_free(mcu_tim_pin_list[j].pin) == true) ) {
|
&& (common_hal_mcu_pin_is_free(mcu_tim_pin_list[j].pin) == true) ) {
|
||||||
// // Search whether any pins in the package array match it
|
// Search whether any pins in the package array match it
|
||||||
// for (size_t k = 0; k < mcu_pin_globals.map.alloc; k++) {
|
for (size_t k = 0; k < mcu_pin_globals.map.alloc; k++) {
|
||||||
// if ( (mcu_tim_pin_list[j].pin == (mcu_pin_obj_t*)(mcu_pin_globals.map.table[k].value)) ) {
|
if ( (mcu_tim_pin_list[j].pin == (mcu_pin_obj_t*)(mcu_pin_globals.map.table[k].value)) ) {
|
||||||
// timer_in_package = true;
|
timer_in_package = true;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// // If no results are found, no unclaimed pins with this timer are in this package,
|
// If no results are found, no unclaimed pins with this timer are in this package,
|
||||||
// // and it is safe to pick
|
// and it is safe to pick
|
||||||
// if (timer_in_package == false && mcu_tim_banks[i] != NULL) {
|
if (timer_in_package == false && mcu_tim_banks[i] != NULL) {
|
||||||
// return mcu_tim_banks[i];
|
return mcu_tim_banks[i];
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Work backwards - higher index timers have fewer pin allocations
|
// Work backwards - higher index timers have fewer pin allocations
|
||||||
for (size_t i = (MP_ARRAY_SIZE(mcu_tim_banks) - 1); i>=0; i--) {
|
for (size_t i = (MP_ARRAY_SIZE(mcu_tim_banks) - 1); i >= 0; i--) {
|
||||||
if ((!stm_timer_reserved[i]) && (mcu_tim_banks[i] != NULL)) {
|
if ((!stm_timer_reserved[i]) && (mcu_tim_banks[i] != NULL)) {
|
||||||
return mcu_tim_banks[i];
|
return mcu_tim_banks[i];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user