Hallo,
auf einem XMC Mikrocontroller soll während dem Betrieb der Pin Modus
geändert werden. Hierfür gibt es eine spezielle Funktion die dies
ermöglicht. Nun soll diese Funktion außerhalb in der Klasse nicht
sichtbar sein. Es soll nur mit einer Variable/Zeiger der Modus geändert
werden. Wie könnte man sowas realisieren?
1 | void XMC_GPIO_SetMode(XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_MODE_t mode)
|
2 | {
|
3 | XMC_ASSERT("XMC_GPIO_SetMode: Invalid port", XMC_GPIO_CHECK_PORT(port));
|
4 | XMC_ASSERT("XMC_GPIO_SetMode: Invalid mode", XMC_GPIO_IsModeValid(mode));
|
5 |
|
6 | port->IOCR[(uint32_t)pin >> 2U] &= ~(uint32_t)((uint32_t)PORT_IOCR_PC_Msk << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)pin & 0x3U)));
|
7 | port->IOCR[(uint32_t)pin >> 2U] |= (uint32_t)mode << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)pin & 0x3U));
|
8 | }
|