Skip to content

Commit

Permalink
restore const and enum in gpio
Browse files Browse the repository at this point in the history
  • Loading branch information
dobaj committed Nov 10, 2023
1 parent 3e79973 commit e8f85d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Q24ECU/core/include/hal/hal_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define GPIO(bank) ((GPIO_TypeDef *) (GPIOA_BASE + 0x400U * (bank)))
enum { GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_AF, GPIO_MODE_ANALOG };
enum { GPIO_PULLUP, GPIO_PULLDOWN, GPIO_RESET };
enum { GPIO_RESET, GPIO_PULLUP, GPIO_PULLDOWN, GPIO_RESERV};



Expand Down Expand Up @@ -64,19 +64,19 @@ static inline void gpio_toggle_pin(uint16_t pin){
}

static inline bool gpio_read_idr(uint16_t pin) {
GPIO_TypeDef *gpio = GPIO(PINBANK(pin));
const GPIO_TypeDef *gpio = GPIO(PINBANK(pin));
return (gpio->IDR & (1U << PINNO(pin)));
}

static inline bool gpio_read_odr(uint16_t pin){
GPIO_TypeDef *gpio = GPIO(PINBANK(pin));
const GPIO_TypeDef *gpio = GPIO(PINBANK(pin));
return (gpio->ODR & (1U << PINNO(pin)));
}

static inline void gpio_pull(uint16_t pin, uint8_t mode){
GPIO_TypeDef *gpio = GPIO(PINBANK(pin));
gpio->PUPDR &= ~(3U << (PINNO(pin)*2));
if(mode!=3) gpio->PUPDR |= 1U << (2*(PINNO(pin))+mode); //3 is reserved
if(mode!=GPIO_RESERV) gpio->PUPDR |= mode << (2*(PINNO(pin)));
}

// t: expiration time, prd: period, now: current time. Return true if expired
Expand Down

0 comments on commit e8f85d1

Please sign in to comment.