Finish common-hal pin API

This commit is contained in:
Lucian Copeland 2020-07-24 12:29:18 -04:00
parent c735dceed5
commit 356b1a8d6d

View File

@ -41,12 +41,19 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
claimed_pins[pin_port] &= ~(1<<pin_number);
}
void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
reset_pin_number(0, pin->number);
}
void claim_pin(const mcu_pin_obj_t* pin) {
// Set bit in claimed_pins bitmask.
claimed_pins[0] |= 1<<pin->number;
}
void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
claim_pin(pin);
}
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
return !(claimed_pins[pin_port] & 1<<pin_number);
}