// Insert compiler directives to set the optimization to zero
// We do not want the compiler to optimize out any code
#pragma GCC push_options
#pragma GCC optimize ("O0")
// Include the header file.
// In STM32 microcontroller programming, the header files provided by the
// manufacturer (STMicroelectronics) contain the necessary definitions,
// constants, and function prototypes specific to the microcontroller's peripherals
// and features.
#include "stm32c0xx.h"
// Include function declarations
void myDelay(unsigned int val);
uint32_t turnOn[]={0x0,0x1,0x2,0x3,0x20,0x21,0x22,0x23};
uint32_t counter = 0;
int main(void)
{
RCC->IOPENR |= 1;
GPIOA->MODER=0b10000010101;
GPIOA->OTYPER=0x0;
GPIOA->PUPDR=0x140;
setup();
while (1)
{
if(((GPIOA->IDR)&0x8) == 0){
counter++;
if(counter>7){
counter=0;
}
}
if(((GPIOA->IDR)&0x10) == 0){
counter--;
if(counter>9){
counter = 7;
}
}
GPIOA->BSRR = 0xFFFF0000;
myDelay(2000);
GPIOA->BSRR =turnOn[counter];
myDelay(200000);
}
}
// Add function definitions here
void myDelay(unsigned int val)
{
int i;
for (i = 0; i < val; i++);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, STM32 BERR CLASS!");
}