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) {
|
||||
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) {
|
||||
|
@ -99,27 +99,27 @@ void timers_reset(void) {
|
||||
|
||||
TIM_TypeDef * stm_peripherals_find_timer(void) {
|
||||
// Check for timers on pins outside the package size
|
||||
// for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
|
||||
// bool timer_in_package = false;
|
||||
// // Find each timer instance on the given bank
|
||||
// for (size_t j = 0; j < MP_ARRAY_SIZE(mcu_tim_pin_list); j++) {
|
||||
// // If a pin is claimed, we skip it
|
||||
// if ( (mcu_tim_pin_list[j].tim_index == i)
|
||||
// && (common_hal_mcu_pin_is_free(mcu_tim_pin_list[j].pin) == true) ) {
|
||||
// // Search whether any pins in the package array match it
|
||||
// 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)) ) {
|
||||
// timer_in_package = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // If no results are found, no unclaimed pins with this timer are in this package,
|
||||
// // and it is safe to pick
|
||||
// if (timer_in_package == false && mcu_tim_banks[i] != NULL) {
|
||||
// return mcu_tim_banks[i];
|
||||
// }
|
||||
// }
|
||||
for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
|
||||
bool timer_in_package = false;
|
||||
// Find each timer instance on the given bank
|
||||
for (size_t j = 0; j < MP_ARRAY_SIZE(mcu_tim_pin_list); j++) {
|
||||
// If a pin is claimed, we skip it
|
||||
if ( (mcu_tim_pin_list[j].tim_index == i + 1)
|
||||
&& (common_hal_mcu_pin_is_free(mcu_tim_pin_list[j].pin) == true) ) {
|
||||
// Search whether any pins in the package array match it
|
||||
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)) ) {
|
||||
timer_in_package = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If no results are found, no unclaimed pins with this timer are in this package,
|
||||
// and it is safe to pick
|
||||
if (timer_in_package == false && mcu_tim_banks[i] != NULL) {
|
||||
return mcu_tim_banks[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Work backwards - higher index timers have fewer pin allocations
|
||||
for (size_t i = (MP_ARRAY_SIZE(mcu_tim_banks) - 1); i >= 0; i--) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user