rework #4
@ -48,7 +48,7 @@ void gpio_configure(enum GpioPort port, enum GpioPin pin_mask,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
regs->PORTS[port].CRL.word &= ~(0xF * mask);
|
regs->PORTS[port].CRL.word &= ~(0xF * mask);
|
||||||
regs->PORTS[port].CRL.word |= (config << 2) | (mode << 0) * mask;
|
regs->PORTS[port].CRL.word |= ((config << 2) | (mode << 0)) * mask;
|
||||||
|
|
||||||
//clear config for selected port, then apply new config, 8 last pins
|
//clear config for selected port, then apply new config, 8 last pins
|
||||||
mask = 0;
|
mask = 0;
|
||||||
@ -61,7 +61,7 @@ void gpio_configure(enum GpioPort port, enum GpioPin pin_mask,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
regs->PORTS[port].CRH.word &= ~(0xF * mask);
|
regs->PORTS[port].CRH.word &= ~(0xF * mask);
|
||||||
regs->PORTS[port].CRH.word |= (config << 2) | (mode << 0) * mask;
|
regs->PORTS[port].CRH.word |= ((config << 2) | (mode << 0)) * mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_reset(enum GpioPort port, enum GpioPin pin_mask)
|
void gpio_reset(enum GpioPort port, enum GpioPin pin_mask)
|
||||||
@ -85,3 +85,4 @@ bool gpio_read(enum GpioPort port, enum GpioPin pin_mask)
|
|||||||
|
|
||||||
|
|
||||||
//--local functions-------------------------------------------------------------
|
//--local functions-------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -55,8 +55,9 @@ enum GpioPin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available modes for a pin. To have a pin in both modes simultaneously, see
|
* Available modes for a pin. To have a pin in both modes simultaneously, use
|
||||||
* push-pull configuration in input mode
|
* push-pull configuration in input mode but note that the power may be
|
||||||
|
* limited
|
||||||
*/
|
*/
|
||||||
enum GpioMode {
|
enum GpioMode {
|
||||||
GPIO_MODE_INPUT = 0,
|
GPIO_MODE_INPUT = 0,
|
||||||
@ -66,7 +67,7 @@ enum GpioMode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available configurations for a pin. Some configurations onlly apply in input
|
* Available configurations for a pin. Some configurations only apply in input
|
||||||
* mode (denoted "IN") while others only apply in output mode (denoted "OUT")
|
* mode (denoted "IN") while others only apply in output mode (denoted "OUT")
|
||||||
*/
|
*/
|
||||||
enum GpioConfig {
|
enum GpioConfig {
|
||||||
@ -115,3 +116,4 @@ bool gpio_read(enum GpioPort port, enum GpioPin pin_mask);
|
|||||||
|
|
||||||
|
|
||||||
#endif //_RCC_H_
|
#endif //_RCC_H_
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user