8 void DrvGpio::init(DrvTypes::PORT port, DrvTypes::PIN pin, DrvTypes::GPIO_MODE mode, DrvTypes::GPIO_PUPD pupd) {
14 case DrvTypes::DRV_PORTA:
17 case DrvTypes::DRV_PORTB:
20 case DrvTypes::DRV_PORTC:
23 case DrvTypes::DRV_PORTD:
26 case DrvTypes::DRV_PORTE:
29 case DrvTypes::DRV_PORTF:
32 case DrvTypes::DRV_PORTG:
41 setPinFuncMode(mPort, mPin, mode, pupd);
44 void DrvGpio::setPinFuncMode(DrvTypes::GPIO_MODE mode, DrvTypes::GPIO_PUPD pupd) {
45 setPinFuncMode(mPort, mPin, mode);
48 void DrvGpio::setPinFuncMode(DrvTypes::PORT port, DrvTypes::PIN pin, DrvTypes::GPIO_MODE mode, DrvTypes::GPIO_PUPD pupd) {
52 case DrvTypes::DRV_PORTA:
55 case DrvTypes::DRV_PORTB:
58 case DrvTypes::DRV_PORTC:
61 case DrvTypes::DRV_PORTD:
64 case DrvTypes::DRV_PORTE:
67 case DrvTypes::DRV_PORTF:
70 case DrvTypes::DRV_PORTG:
77 volatile uint32_t* crl;
85 shift = (pin - 8) * 4;
87 (*crl) &= ~(0b1111 << shift);
90 case DrvTypes::DRV_MODE_INPUT:
92 case DrvTypes::PUPD_NONE:
93 (*crl) |= (0b0100 << shift);
95 case DrvTypes::PUPD_PULL_UP:
96 (*crl) |= (0b1000 << shift);
97 gpio->BSRR = 1 << pin;
99 case DrvTypes::PUPD_PULL_DOWN:
100 (*crl) |= (0b1000 << shift);
101 gpio->BRR = 1 << pin;
105 case DrvTypes::DRV_MODE_OUTPUT_PUSH_PULL:
106 (*crl) |= (0b0011 << shift);
108 case DrvTypes::DRV_MODE_OUTPUT_OPEN_DRAIN:
109 (*crl) |= (0b0111 << shift);
111 case DrvTypes::DRV_MODE_ALTERNATE_FUNCTION:
112 (*crl) |= (0b1011 << shift);
114 case DrvTypes::DRV_MODE_ANALOG:
115 (*crl) |= (0b0000 << shift);