/**
******************************************************************************
* @file : main.c
* @author : Auto-generated by STM32CubeIDE
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include <stdint.h>
#include "ARMIO.h"
#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif
int main(void){
/* In GPIO_mode, it is possible to configure any pin of any PORT as INPUT or OUTPUT */
/* GPIO_mode(GPIO_name, pin_number, IN/OUT) */
GPIO_mode(PA5, IN); // Make 5th bit of GPIOA as INPUT
GPIO_mode(PA6, OUT); // Make 6th bit of GPIOA as OUTPUT
GPIO_mode(PA7, OUT);
GPIO_mode(PB7, IN);
GPIO_mode(PB3, OUT);
GPIO_mode(PB4, OUT);
GPIO_mode(PC13, IN);
GPIO_mode(PC14, OUT);
GPIO_mode(PC15, OUT);
while(1){
/* In this method, we can read or write any particular pin of any PORT */
/* GPIO_read(GPIO_name, pin_number) */
/* GPIO_write(GPIO_name, pin_number, 1/0) */
if(GPIO_read(PA5) == 0){ // Read the 5th pin of GPIOA and check whether the switch is pressed or not
GPIO_write(PA6, 1); // Make the 6th bit HIGH of GPIOA
GPIO_write(PA7, 1); // Make the 7th bit HIGH of GPIOA
delay_ms(1500);
}
else{
GPIO_write(PA6, 0); // Make the 6th bit LOW of GPIOA
GPIO_write(PA7, 0); // Make the 7th bit LOW of GPIOA
}
/* In this method, we can read or write the 16 bit data of any PORT */
if((GPIOB_IN & (1 << 7)) == 0){ // Read the 7th pin of GPIOB and check whether the switch is pressed or not
GPIOB_OUT |= (3 << 3); // Make the 3rd and 4th bit HIGH of GPIOB
delay_ms(1500);
}
else GPIOB_OUT &= ~(3 << 3); // Make the 3rd and 4th bit LOW of GPIOB
/* In this method, we can read or write any particular pin of any PORT */
/* GPIO_read(GPIO_name, pin_number) */
/* GPIO_write(GPIO_name, pin_number, 1/0) */
if(GPIO_read(PC13) == 0){
GPIO_write(PC14, 1);
GPIO_write(PC15, 1);
delay_ms(1500);
}
else{
GPIO_write(PC14, 0);
GPIO_write(PC15, 0);
}
}
}
Loading
stm32-bluepill
stm32-bluepill