Comprehensive Peer Review of GPIO Driver Code Implementation
School
Brigham Young University, Idaho**We aren't endorsed by this school
Course
ECEN 390
Subject
Information Systems
Date
Dec 12, 2024
Pages
4
Uploaded by ProfessorOpossumMaster1110
Peer Review Report.The code was formatted properly and easily comprehended and operated with no major bug issues.Here is the Code for my partner:/** drivers.c** Created for: ECEN 260*/// include the drivers header file#include"drivers.h"// Enable clock for GPIO Port AvoidGPIOA_ClkEnable(void){*AHB2ENR |= 0b001; // set bit 0 for Port A}voidGPIOB_ClkEnable(void){*AHB2ENR |= 0b010; // set bit 1 for Port B}voidGPIOC_ClkEnable(void){*AHB2ENR |= 0b100; // set bit 2 for Port C}// Configure mode for given pin on given port// - mode: GPIO_MODE_INPUT or GPIO_MODE_OUTPUT
voidGPIO_Mode(Port* GPIOx, uint32_tpin, uint32_tmode){if(mode == GPIO_MODE_INPUT){// MODER bits = 00uint32_ttemp = GPIOx->MODER;temp &= ~BITPAIR(pin);GPIOx->MODER = temp;} elseif(mode == GPIO_MODE_OUTPUT) {// MODER bits = 01uint32_ttemp = GPIOx->MODER; // read the MODERtemp &= ~UBIT(pin); // reset the upper bittemp |= LBIT(pin); // set the lower bitGPIOx->MODER = temp; // place back in MODER}}voidGPIO_Pull(Port* GPIOx, uint32_tpin, uint32_tpull){if(pull == GPIO_NOPULL){uint32_ttemp = GPIOx->PUPDR;temp &= ~BITPAIR(pin);GPIOx->PUPDR = temp;}
elseif(state != 1) {GPIOx->ODR &= ~BIT(pin);}}uint32_tGPIO_ReadPin(Port* GPIOx, uint32_tpin){uint32_ttemp = GPIOx->IDR;return((temp & BIT(pin)) >> pin);}// Toggles current value of given pin on given port// - if pin is high -> makes pin low, if pin is low -> makes pin highvoidGPIO_TogglePin(Port* GPIOx, uint32_tpin){GPIOx->ODR ^= BIT(pin); // toggle the bit}The demonstration was perfect and the updated Alarm system was operable in the program.In conclusion the program and it was working for the lab.