📄 lld_gpio.c
字号:
wr16_reg(GpioB,Pc1,u16Buffer & ~(1<<u8Pin)); /* clear bit u8Pin. */ u16Buffer = rd16_reg(GpioB,Pc2); wr16_reg(GpioB,Pc2,u16Buffer & ~(1<<u8Pin)); /* clear bit u8Pin. */ }}/************************************************************************* ** FUNCTIONS ** ** LLD_GPIO_GetState ** ** DESCRIPTION ** ** Get the state of the u8Pin of the id GPIO port. ** ** CALLS ** ** LLD macros ** ** INPUTS ** ** GPIO_ID id: GPIO identificator ** tU8 u8in: Pin number ** ** OUTPUTS ** ** Pin state. ** *************************************************************************/tU8 LLD_GPIO_GetState(GPIO_ID id, tU8 u8Pin){ if( GPIO_A == id ) { return(rd16_reg(GpioA,Pd) & (1<<u8Pin))?1:0; } if( GPIO_B == id ) { return(rd16_reg(GpioB,Pd) & (1<<u8Pin))?1:0; } return(0); /* Unreachable point, implemented to avoid warning. */}/************************************************************************* ** FUNCTIONS ** ** LLD_GPIO_SetStatelHigh ** ** DESCRIPTION ** ** Set the state of the u8Pin of the id GPIO port. ** ** CALLS ** ** LLD macros ** ** INPUTS ** ** GPIO_ID id: GPIO identificator ** tU8 u8in: Pin number ** ** OUTPUTS ** ** None ** *************************************************************************/tVoid LLD_GPIO_SetStateHigh(GPIO_ID id, tU8 u8Pin){ tU16 u16Buffer; if( GPIO_A == id ) { u16Buffer = rd16_reg(GpioA,Pd); u16Buffer |= (1<<u8Pin); wr16_reg(GpioA,Pd,u16Buffer); } if( GPIO_B == id ) { u16Buffer = rd16_reg(GpioB,Pd); u16Buffer |= (1<<u8Pin); wr16_reg(GpioB,Pd,u16Buffer); }}/************************************************************************* ** FUNCTIONS ** ** LLD_GPIO_SetStatelLow ** ** DESCRIPTION ** ** Clear the state of the u8Pin of the id GPIO port. ** ** CALLS ** ** LLD macros ** ** INPUTS ** ** GPIO_ID id: GPIO identificator ** tU8 u8in: Pin number ** ** OUTPUTS ** ** None ** *************************************************************************/tVoid LLD_GPIO_SetStateLow(GPIO_ID id, tU8 u8Pin){ tU16 u16Buffer; if( GPIO_A == id ) { u16Buffer = rd16_reg(GpioA,Pd); u16Buffer &= ~(1<<u8Pin); wr16_reg(GpioA,Pd,u16Buffer); } if( GPIO_B == id ) { u16Buffer = rd16_reg(GpioB,Pd); u16Buffer &= ~(1<<u8Pin); wr16_reg(GpioB,Pd,u16Buffer); }}/************************************************************************* ** FUNCTIONS ** ** LLD_GPIO_SetStateToggle ** ** DESCRIPTION ** ** Toggle the state of the u8Pin of the id GPIO port. ** ** CALLS ** ** LLD macros ** ** INPUTS ** ** GPIO_ID id: GPIO identificator ** tU8 u8in: Pin number ** ** OUTPUTS ** ** None ** *************************************************************************/tVoid LLD_GPIO_SetStateToggle(GPIO_ID id, tU8 u8Pin){ tU16 u16Buffer; if( GPIO_A == id ) { u16Buffer = rd16_reg(GpioA,Pd); u16Buffer ^= (1<<u8Pin); wr16_reg(GpioA,Pd,u16Buffer); } if( GPIO_B == id ) { u16Buffer = rd16_reg(GpioB,Pd); u16Buffer ^= (1<<u8Pin); wr16_reg(GpioB,Pd,u16Buffer); }}/************************************************************************* ** FUNCTIONS ** ** LLD_GPIO_AFToGpioSwitch ** ** DESCRIPTION ** ** Toggle the configuration of the u8Pin of the id GPIO2 port. ** To use for I2C funtionality ** CALLS ** ** LLD macros ** ** INPUTS ** ** tU8 u8in: Pin number ** ** OUTPUTS ** ** None ** *************************************************************************/tVoid LLD_GPIO_AFToGpioSwitch(tU8 u8Pin){ /* The Output configuration is Pc1=0 */ tU16 u16Buffer; u16Buffer = rd16_reg(GpioA,Pc1); wr16_reg(GpioA,Pc1,u16Buffer & ~(1<<u8Pin)); /* clear bit u8Pin. */}/************************************************************************* ** FUNCTIONS ** ** LLD_GPIO_GpioToAFSwitch ** ** DESCRIPTION ** ** Toggle the configuration of the u8Pin of the id GPIO2 port. ** To use for I2C funtionality ** CALLS ** ** LLD macros ** ** INPUTS ** ** tU8 u8in: Pin number ** ** OUTPUTS ** ** None ** *************************************************************************/tVoid LLD_GPIO_GpioToAFSwitch(tU8 u8Pin){ /* The Output configuration is Pc1=0 */ tU16 u16Buffer; u16Buffer = rd16_reg(GpioA,Pc1); wr16_reg(GpioA,Pc1,u16Buffer | (1<<u8Pin)); /* clear bit u8Pin. */} #ifdef __cplusplus}#endif/* End of file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -