Fix formatting.

This commit is contained in:
jgillick 2020-11-22 01:15:05 -08:00
parent 63b0bf9075
commit 0b858440b0

View File

@ -52,20 +52,18 @@ GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD};
GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC};
#endif
#define GPIO_PORT_COUNT (MP_ARRAY_SIZE(ports))
STATIC uint16_t claimed_pins[GPIO_PORT_COUNT];
STATIC uint16_t __ALIGNED(4) never_reset_pins[GPIO_PORT_COUNT];
void reset_all_pins(void)
{
void reset_all_pins(void) {
// Reset claimed pins
for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++)
{
for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) {
claimed_pins[i] = never_reset_pins[i];
}
for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++)
{
for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) {
HAL_GPIO_DeInit(ports[i], ~never_reset_pins[i]);
}
@ -79,15 +77,12 @@ void reset_all_pins(void)
}
// Mark pin as free and return it to a quiescent state.
void reset_pin_number(uint8_t pin_port, uint8_t pin_number)
{
if (pin_number == NO_PIN)
{
void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
if ( pin_number == NO_PIN ) {
return;
}
if (pin_port == 0x0F)
{
if (pin_port == 0x0F) {
return;
}
// Clear claimed bit & reset
@ -96,8 +91,7 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number)
HAL_GPIO_DeInit(ports[pin_port], 1<<pin_number);
#ifdef MICROPY_HW_NEOPIXEL
if (pin_port == MICROPY_HW_NEOPIXEL->port && pin_number == MICROPY_HW_NEOPIXEL->number)
{
if (pin_port == MICROPY_HW_NEOPIXEL->port && pin_number == MICROPY_HW_NEOPIXEL->number) {
neopixel_in_use = false;
rgb_led_status_init();
return;
@ -114,10 +108,8 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number)
#endif
}
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number)
{
if (pin_number == NO_PIN)
{
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
if ( pin_number == NO_PIN ) {
return;
}
never_reset_pins[pin_port] |= 1<<pin_number;
@ -125,32 +117,26 @@ void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number)
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) {
never_reset_pin_number(pin->port, pin->number);
}
void common_hal_reset_pin(const mcu_pin_obj_t *pin)
{
void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
reset_pin_number(pin->port, pin->number);
}
void claim_pin(uint8_t pin_port, uint8_t pin_number)
{
void claim_pin(uint8_t pin_port, uint8_t pin_number) {
// Set bit in claimed_pins bitmask.
claimed_pins[pin_port] |= 1<<pin_number;
}
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number)
{
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
return !(claimed_pins[pin_port] & 1<<pin_number);
}
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin)
{
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
#ifdef MICROPY_HW_NEOPIXEL
if (pin == MICROPY_HW_NEOPIXEL)
{
if (pin == MICROPY_HW_NEOPIXEL) {
return !neopixel_in_use;
}
#endif
@ -168,27 +154,22 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin)
return pin_number_is_free(pin->port, pin->number);
}
GPIO_TypeDef *pin_port(uint8_t pin_port)
{
GPIO_TypeDef * pin_port(uint8_t pin_port) {
return ports[pin_port];
}
uint16_t pin_mask(uint8_t pin_number)
{
uint16_t pin_mask(uint8_t pin_number) {
return 1<<pin_number;
}
uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t *pin)
{
uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t* pin) {
return pin->port * 16 + pin->number;
}
void common_hal_mcu_pin_claim(const mcu_pin_obj_t *pin)
{
void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
claim_pin(pin->port, pin->number);
#ifdef MICROPY_HW_NEOPIXEL
if (pin == MICROPY_HW_NEOPIXEL)
{
if (pin == MICROPY_HW_NEOPIXEL) {
neopixel_in_use = true;
}
#endif
@ -204,7 +185,6 @@ void common_hal_mcu_pin_claim(const mcu_pin_obj_t *pin)
#endif
}
void common_hal_mcu_pin_reset_number(uint8_t pin_no)
{
void common_hal_mcu_pin_reset_number(uint8_t pin_no) {
reset_pin_number(pin_no / 16, pin_no % 16);
}