hab ein paar änderungen gemacht

This commit is contained in:
2026-03-20 19:09:26 +01:00
parent d95e3f7923
commit 7e0e37a578
42 changed files with 1801 additions and 2297 deletions
@@ -309,3 +309,17 @@ Finished building: default.size.stdout
Finished building: task1.list
15:01:24 **** Incremental Build of configuration Debug for project task1 ****
make -j12 all
arm-none-eabi-gcc "../Src/task1.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DSTM32G431KBTx -DSTM32 -DSTM32G4 -DNUCLEO_G431KB -c -I../Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Src/task1.d" -MT"Src/task1.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Src/task1.o"
arm-none-eabi-gcc -o "task1.elf" @"objects.list" -mcpu=cortex-m4 -T"/home/tobii/02_Uni/09_Mikrocomputertechnik/praktikum/mct_bei_workspace_25w/task1/STM32G431KBTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="task1.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
Finished building target: task1.elf
arm-none-eabi-size task1.elf
arm-none-eabi-objdump -h -S task1.elf > "task1.list"
text data bss dec hex filename
1692 0 1568 3260 cbc task1.elf
Finished building: default.size.stdout
Finished building: task1.list
@@ -1,4 +1,4 @@
14:21:35 **** Incremental Build of configuration Debug for project task1 ****
15:01:24 **** Incremental Build of configuration Debug for project task1 ****
make -j12 all
arm-none-eabi-gcc "../Src/task1.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DSTM32G431KBTx -DSTM32 -DSTM32G4 -DNUCLEO_G431KB -c -I../Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Src/task1.d" -MT"Src/task1.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Src/task1.o"
arm-none-eabi-gcc -o "task1.elf" @"objects.list" -mcpu=cortex-m4 -T"/home/tobii/02_Uni/09_Mikrocomputertechnik/praktikum/mct_bei_workspace_25w/task1/STM32G431KBTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="task1.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
@@ -13,5 +13,5 @@ Finished building: default.size.stdout
Finished building: task1.list
14:21:36 Build Finished. 0 errors, 0 warnings. (took 332ms)
15:01:24 Build Finished. 0 errors, 0 warnings. (took 330ms)
@@ -0,0 +1,36 @@
/*
* sketch.c
*
* Created on: Mar 18, 2026
* Author: tobii
*/
int reihenfolge[6] = {0, 1, 2, 3, 2, 1};
int main(){
while(1){
while(/*schalter gedrückt*/){}
delay();
while(/*schalter losgelassen*/){}
delay();
int aktiv = 1;
while(aktiv){
for(int i; i < reihenfolge.length - 1 && aktiv = 1; i ++){
//alle LED einschalten
if(i = 0){/*alles bis auf LED0 auschalten*/}
if(i = 1){/*..*/}
//...
for(int zähler = 0; zähler < 333 && aktiv == 1; zähler++){
if(/*schalter gerückt*/){
aktiv = 0;
break;
}
else{
delay(1);
}
}
while(/*Taster gedrückt*/){}
}
}
}
}
@@ -1,211 +0,0 @@
/* ***************************************************************************************
* Project: task1 - C:GPIO
* File: task1.c
*
* Language: C
*
* Hardware: STefi Light v1.1
* Processor: STM32G431KBT6U
*
* Author: Manuel Lederhofer
* Datum: 10.09.2021
*
* Version: 2.1
* History:
* 10.09.2021 ML create project
* 09.03.2022 ML port from STM32F042K6T6 to STM32G431KBT6U
* 18.02.2025 TK changed projectname to "C: GPIO)
*
* Status: under development
*
* Description:
* Blinks the red LED of STefi Light, currently.
* This file contains the main routine and the initialization.
*
* Notes:
* - MCU speed at startup is 16 MHz
*
* Todo:
* - Change the example code to match the description and requirements
* of the requested application in the lab exercise guide.
*
************************************************************************************** */
/* ------------------------------------ INCLUDES -------------------------------------- */
#include "stm32g431xx.h"
#include "STefi-Light.h"
/* ------------------------------------ DEFINES --------------------------------------- */
#define LOOPS_PER_MS 1244 // NOP-loops for delay()
#define WAITTIME 333
/* ------------------------------------ TYPE DEFINITIONS ------------------------------ */
/* ------------------------------------ GLOBAL VARIABLES ------------------------------ */
int state = 0;
/* ------------------------------------ PRIVATE VARIABLES ----------------------------- */
/* ------------------------------------ PROTOTYPES ------------------------------------ */
static void GPIO_init(void);
static void delay(const uint16_t ms);
/* ------------------------------------ M A I N --------------------------------------- */
int main(void)
{
/* --- initialization --- */
__disable_irq(); // disable interrupts globally
GPIO_init();
__enable_irq(); // enable interrupts globally
/* --- one time tasks --- */
//s0 Hilfvariablen auserhalb von while deklarieren
int running = 0; //0 Lauflicht aus, 1 Lauflicht an
int lastButtonState = 1; // Hilfsvariable zur Flankenerkennung
/* --- infinite processing loop --- */
while (1)
{
int buttonState = GPIOB->IDR & (1 << 0);
// fallende Flanke erkennen
if (lastButtonState && !buttonState)
{
running ^= 1; // toggle running
/* delay(50); // entprellen */
}
lastButtonState = buttonState;
if(running)
{
switch (state)
{
case 0:
state++;
GPIOA->ODR &= ~(1 << 0);
delay(WAITTIME);
GPIOA->ODR |= (1 << 0);
break;
case 1:
state++;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 2:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 3:
state++;
GPIOA->ODR &= ~(1 << 3);
delay(WAITTIME);
GPIOA->ODR |= (1 << 3);
break;
case 4:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 5:
state=0;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 99:
GPIOA->ODR |= MASK_LED_ALL;
while(1){
if((GPIOB->IDR & (1 << 0)) == 0){
state=0;
break;
}
}
}
}
}
//aktuell geht er mit drücken durch die cases
// wegen break geht er ganz aus der if bedingung raus, nicht nur ausm switch case
return 1;
}
/* ------------------------------------ GLOBAL FUNCTIONS ------------------------------ */
/* ------------------------------------ PRIVATE FUNCTIONS ----------------------------- */
/* ------------------------------------------------------------------------------------ *\
* method: static void GPIO_init(void)
*
* Initializes GPIOs on STefi Light for pins with peripherals attached.
*
* requires: - nothing -
* parameters: - none -
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void GPIO_init(void)
{
/* enable port clocks */
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN; // LEDs: A
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN; //Taster versuch
/* --- LEDs --- */
GPIOA->ODR |= MASK_LED_ALL;
GPIOA->MODER &= ~(3 << 0);
GPIOA->MODER |= (1 << 0); // set LED pin to output
/* LED1 als Output */
GPIOA->MODER &= ~(3 << 2); // Versuch: LED 1 Mode löschen :klappt so
GPIOA->MODER |= (1 << 2); // Versuch: LED 1 PA1 = output :klappt so
/* LED2 als Output */
GPIOA->MODER &= ~(3 << 4); // Versuch: LED 2 Mode löschen :klappt
GPIOA->MODER |= (1 << 4); // Versuch: LED 2 PA1 = output :klappt
/* LED3 als output */
GPIOA->MODER &= ~(3 << 6);
GPIOA->MODER |= (1 << 6);
/* s0 (PB0) als Input Versuch */
GPIOB->MODER &= ~(3 << 0);
/* Pull-Up Aktivieren Versuch */
GPIOB->PUPDR &= ~(3 << 0);
GPIOB->PUPDR |= (1 << 0); // 01 = Pull-Up
}
/* ------------------------------------------------------------------------------------ *\
* method: static void delay(const uint16_t ms)
*
* Realizes a millisecond delay by very bad busy-wait.
*
* requires: - nothing -
* parameters: ms - delay time in milliseconds
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void delay(const uint16_t ms)
{
for (uint16_t i = 0; i < ms; ++i)
{
if((GPIOB->IDR & (1 << 0)) == 0){
state = 99;
break;
}
for (uint16_t j = 0; j < LOOPS_PER_MS; ++j)
{
__asm("NOP");
}
}
}
/* ************************************ E O F ***************************************** */
@@ -1,212 +0,0 @@
/* ***************************************************************************************
* Project: task1 - C:GPIO
* File: task1.c
*
* Language: C
*
* Hardware: STefi Light v1.1
* Processor: STM32G431KBT6U
*
* Author: Manuel Lederhofer
* Datum: 10.09.2021
*
* Version: 2.1
* History:
* 10.09.2021 ML create project
* 09.03.2022 ML port from STM32F042K6T6 to STM32G431KBT6U
* 18.02.2025 TK changed projectname to "C: GPIO)
*
* Status: under development
*
* Description:
* Blinks the red LED of STefi Light, currently.
* This file contains the main routine and the initialization.
*
* Notes:
* - MCU speed at startup is 16 MHz
*
* Todo:
* - Change the example code to match the description and requirements
* of the requested application in the lab exercise guide.
*
************************************************************************************** */
/* ------------------------------------ INCLUDES -------------------------------------- */
#include "stm32g431xx.h"
#include "STefi-Light.h"
/* ------------------------------------ DEFINES --------------------------------------- */
#define LOOPS_PER_MS 1244 // NOP-loops for delay()
#define WAITTIME 333
/* ------------------------------------ TYPE DEFINITIONS ------------------------------ */
/* ------------------------------------ GLOBAL VARIABLES ------------------------------ */
int state = 0;
/* ------------------------------------ PRIVATE VARIABLES ----------------------------- */
/* ------------------------------------ PROTOTYPES ------------------------------------ */
static void GPIO_init(void);
static void delay(const uint16_t ms);
/* ------------------------------------ M A I N --------------------------------------- */
int main(void)
{
/* --- initialization --- */
__disable_irq(); // disable interrupts globally
GPIO_init();
__enable_irq(); // enable interrupts globally
/* --- one time tasks --- */
//s0 Hilfvariablen auserhalb von while deklarieren
int running = 0; //0 Lauflicht aus, 1 Lauflicht an
int lastButtonState = 1; // Hilfsvariable zur Flankenerkennung
/* --- infinite processing loop --- */
while (1)
{
int buttonState = GPIOB->IDR & (1 << 0);
// fallende Flanke erkennen
if (lastButtonState && !buttonState)
{
running ^= 1; // toggle running
/* delay(50); // entprellen */
}
lastButtonState = buttonState;
if(running)
{
switch (state)
{
case 0:
state++;
GPIOA->ODR &= ~(1 << 0);
delay(WAITTIME);
GPIOA->ODR |= (1 << 0);
break;
case 1:
state++;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 2:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 3:
state++;
GPIOA->ODR &= ~(1 << 3);
delay(WAITTIME);
GPIOA->ODR |= (1 << 3);
break;
case 4:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 5:
state=0;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 99:
GPIOA->ODR |= MASK_LED_ALL;
while(1){
if((GPIOB->IDR & (1 << 0)) == 0){
delay(10);
state=0;
break;
}
}
}
}
}
//aktuell geht er mit drücken durch die cases
// wegen break geht er ganz aus der if bedingung raus, nicht nur ausm switch case
return 1;
}
/* ------------------------------------ GLOBAL FUNCTIONS ------------------------------ */
/* ------------------------------------ PRIVATE FUNCTIONS ----------------------------- */
/* ------------------------------------------------------------------------------------ *\
* method: static void GPIO_init(void)
*
* Initializes GPIOs on STefi Light for pins with peripherals attached.
*
* requires: - nothing -
* parameters: - none -
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void GPIO_init(void)
{
/* enable port clocks */
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN; // LEDs: A
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN; //Taster versuch
/* --- LEDs --- */
GPIOA->ODR |= MASK_LED_ALL;
GPIOA->MODER &= ~(3 << 0);
GPIOA->MODER |= (1 << 0); // set LED pin to output
/* LED1 als Output */
GPIOA->MODER &= ~(3 << 2); // Versuch: LED 1 Mode löschen :klappt so
GPIOA->MODER |= (1 << 2); // Versuch: LED 1 PA1 = output :klappt so
/* LED2 als Output */
GPIOA->MODER &= ~(3 << 4); // Versuch: LED 2 Mode löschen :klappt
GPIOA->MODER |= (1 << 4); // Versuch: LED 2 PA1 = output :klappt
/* LED3 als output */
GPIOA->MODER &= ~(3 << 6);
GPIOA->MODER |= (1 << 6);
/* s0 (PB0) als Input Versuch */
GPIOB->MODER &= ~(3 << 0);
/* Pull-Up Aktivieren Versuch */
GPIOB->PUPDR &= ~(3 << 0);
GPIOB->PUPDR |= (1 << 0); // 01 = Pull-Up
}
/* ------------------------------------------------------------------------------------ *\
* method: static void delay(const uint16_t ms)
*
* Realizes a millisecond delay by very bad busy-wait.
*
* requires: - nothing -
* parameters: ms - delay time in milliseconds
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void delay(const uint16_t ms)
{
for (uint16_t i = 0; i < ms; ++i)
{
if((GPIOB->IDR & (1 << 0) && state != 99) == 0){
state = 99;
break;
}
for (uint16_t j = 0; j < LOOPS_PER_MS; ++j)
{
__asm("NOP");
}
}
}
/* ************************************ E O F ***************************************** */
@@ -1,212 +0,0 @@
/* ***************************************************************************************
* Project: task1 - C:GPIO
* File: task1.c
*
* Language: C
*
* Hardware: STefi Light v1.1
* Processor: STM32G431KBT6U
*
* Author: Manuel Lederhofer
* Datum: 10.09.2021
*
* Version: 2.1
* History:
* 10.09.2021 ML create project
* 09.03.2022 ML port from STM32F042K6T6 to STM32G431KBT6U
* 18.02.2025 TK changed projectname to "C: GPIO)
*
* Status: under development
*
* Description:
* Blinks the red LED of STefi Light, currently.
* This file contains the main routine and the initialization.
*
* Notes:
* - MCU speed at startup is 16 MHz
*
* Todo:
* - Change the example code to match the description and requirements
* of the requested application in the lab exercise guide.
*
************************************************************************************** */
/* ------------------------------------ INCLUDES -------------------------------------- */
#include "stm32g431xx.h"
#include "STefi-Light.h"
/* ------------------------------------ DEFINES --------------------------------------- */
#define LOOPS_PER_MS 1244 // NOP-loops for delay()
#define WAITTIME 333
/* ------------------------------------ TYPE DEFINITIONS ------------------------------ */
/* ------------------------------------ GLOBAL VARIABLES ------------------------------ */
int state = 0;
/* ------------------------------------ PRIVATE VARIABLES ----------------------------- */
/* ------------------------------------ PROTOTYPES ------------------------------------ */
static void GPIO_init(void);
static void delay(const uint16_t ms);
/* ------------------------------------ M A I N --------------------------------------- */
int main(void)
{
/* --- initialization --- */
__disable_irq(); // disable interrupts globally
GPIO_init();
__enable_irq(); // enable interrupts globally
/* --- one time tasks --- */
//s0 Hilfvariablen auserhalb von while deklarieren
int running = 0; //0 Lauflicht aus, 1 Lauflicht an
int lastButtonState = 1; // Hilfsvariable zur Flankenerkennung
/* --- infinite processing loop --- */
while (1)
{
int buttonState = GPIOB->IDR & (1 << 0);
// fallende Flanke erkennen
if (lastButtonState && !buttonState)
{
running ^= 1; // toggle running
/* delay(50); // entprellen */
}
lastButtonState = buttonState;
if(running)
{
switch (state)
{
case 0:
state++;
GPIOA->ODR &= ~(1 << 0);
delay(WAITTIME);
GPIOA->ODR |= (1 << 0);
break;
case 1:
state++;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 2:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 3:
state++;
GPIOA->ODR &= ~(1 << 3);
delay(WAITTIME);
GPIOA->ODR |= (1 << 3);
break;
case 4:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 5:
state=0;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 99:
GPIOA->ODR |= MASK_LED_ALL;
while(1){
if((GPIOB->IDR & (1 << 0)) == 0){
//delay(10);
state=0;
break;
}
}
}
}
}
//aktuell geht er mit drücken durch die cases
// wegen break geht er ganz aus der if bedingung raus, nicht nur ausm switch case
return 1;
}
/* ------------------------------------ GLOBAL FUNCTIONS ------------------------------ */
/* ------------------------------------ PRIVATE FUNCTIONS ----------------------------- */
/* ------------------------------------------------------------------------------------ *\
* method: static void GPIO_init(void)
*
* Initializes GPIOs on STefi Light for pins with peripherals attached.
*
* requires: - nothing -
* parameters: - none -
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void GPIO_init(void)
{
/* enable port clocks */
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN; // LEDs: A
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN; //Taster versuch
/* --- LEDs --- */
GPIOA->ODR |= MASK_LED_ALL;
GPIOA->MODER &= ~(3 << 0);
GPIOA->MODER |= (1 << 0); // set LED pin to output
/* LED1 als Output */
GPIOA->MODER &= ~(3 << 2); // Versuch: LED 1 Mode löschen :klappt so
GPIOA->MODER |= (1 << 2); // Versuch: LED 1 PA1 = output :klappt so
/* LED2 als Output */
GPIOA->MODER &= ~(3 << 4); // Versuch: LED 2 Mode löschen :klappt
GPIOA->MODER |= (1 << 4); // Versuch: LED 2 PA1 = output :klappt
/* LED3 als output */
GPIOA->MODER &= ~(3 << 6);
GPIOA->MODER |= (1 << 6);
/* s0 (PB0) als Input Versuch */
GPIOB->MODER &= ~(3 << 0);
/* Pull-Up Aktivieren Versuch */
GPIOB->PUPDR &= ~(3 << 0);
GPIOB->PUPDR |= (1 << 0); // 01 = Pull-Up
}
/* ------------------------------------------------------------------------------------ *\
* method: static void delay(const uint16_t ms)
*
* Realizes a millisecond delay by very bad busy-wait.
*
* requires: - nothing -
* parameters: ms - delay time in milliseconds
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void delay(const uint16_t ms)
{
for (uint16_t i = 0; i < ms; ++i)
{
if((GPIOB->IDR & (1 << 0) && state != 99) == 0){
state = 99;
break;
}
for (uint16_t j = 0; j < LOOPS_PER_MS; ++j)
{
__asm("NOP");
}
}
}
/* ************************************ E O F ***************************************** */
@@ -1,212 +0,0 @@
/* ***************************************************************************************
* Project: task1 - C:GPIO
* File: task1.c
*
* Language: C
*
* Hardware: STefi Light v1.1
* Processor: STM32G431KBT6U
*
* Author: Manuel Lederhofer
* Datum: 10.09.2021
*
* Version: 2.1
* History:
* 10.09.2021 ML create project
* 09.03.2022 ML port from STM32F042K6T6 to STM32G431KBT6U
* 18.02.2025 TK changed projectname to "C: GPIO)
*
* Status: under development
*
* Description:
* Blinks the red LED of STefi Light, currently.
* This file contains the main routine and the initialization.
*
* Notes:
* - MCU speed at startup is 16 MHz
*
* Todo:
* - Change the example code to match the description and requirements
* of the requested application in the lab exercise guide.
*
************************************************************************************** */
/* ------------------------------------ INCLUDES -------------------------------------- */
#include "stm32g431xx.h"
#include "STefi-Light.h"
/* ------------------------------------ DEFINES --------------------------------------- */
#define LOOPS_PER_MS 1244 // NOP-loops for delay()
#define WAITTIME 333
/* ------------------------------------ TYPE DEFINITIONS ------------------------------ */
/* ------------------------------------ GLOBAL VARIABLES ------------------------------ */
int state = 0;
/* ------------------------------------ PRIVATE VARIABLES ----------------------------- */
/* ------------------------------------ PROTOTYPES ------------------------------------ */
static void GPIO_init(void);
static void delay(const uint16_t ms);
/* ------------------------------------ M A I N --------------------------------------- */
int main(void)
{
/* --- initialization --- */
__disable_irq(); // disable interrupts globally
GPIO_init();
__enable_irq(); // enable interrupts globally
/* --- one time tasks --- */
//s0 Hilfvariablen auserhalb von while deklarieren
int running = 0; //0 Lauflicht aus, 1 Lauflicht an
int lastButtonState = 1; // Hilfsvariable zur Flankenerkennung
/* --- infinite processing loop --- */
while (1)
{
int buttonState = GPIOB->IDR & (1 << 0);
// fallende Flanke erkennen
if (lastButtonState && !buttonState)
{
running ^= 1; // toggle running
/* delay(50); // entprellen */
}
lastButtonState = buttonState;
if(running)
{
switch (state)
{
case 0:
state++;
GPIOA->ODR &= ~(1 << 0);
delay(WAITTIME);
GPIOA->ODR |= (1 << 0);
break;
case 1:
state++;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 2:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 3:
state++;
GPIOA->ODR &= ~(1 << 3);
delay(WAITTIME);
GPIOA->ODR |= (1 << 3);
break;
case 4:
state++;
GPIOA->ODR &= ~(1 << 2);
delay(WAITTIME);
GPIOA->ODR |= (1 << 2);
break;
case 5:
state=0;
GPIOA->ODR &= ~(1 << 1);
delay(WAITTIME);
GPIOA->ODR |= (1 << 1);
break;
case 99:
GPIOA->ODR |= MASK_LED_ALL;
while(1){
if((GPIOB->IDR & (1 << 0)) == 0){
delay(10);
state=0;
break;
}
}
}
}
}
//aktuell geht er mit drücken durch die cases
// wegen break geht er ganz aus der if bedingung raus, nicht nur ausm switch case
return 1;
}
/* ------------------------------------ GLOBAL FUNCTIONS ------------------------------ */
/* ------------------------------------ PRIVATE FUNCTIONS ----------------------------- */
/* ------------------------------------------------------------------------------------ *\
* method: static void GPIO_init(void)
*
* Initializes GPIOs on STefi Light for pins with peripherals attached.
*
* requires: - nothing -
* parameters: - none -
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void GPIO_init(void)
{
/* enable port clocks */
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN; // LEDs: A
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOBEN; //Taster versuch
/* --- LEDs --- */
GPIOA->ODR |= MASK_LED_ALL;
GPIOA->MODER &= ~(3 << 0);
GPIOA->MODER |= (1 << 0); // set LED pin to output
/* LED1 als Output */
GPIOA->MODER &= ~(3 << 2); // Versuch: LED 1 Mode löschen :klappt so
GPIOA->MODER |= (1 << 2); // Versuch: LED 1 PA1 = output :klappt so
/* LED2 als Output */
GPIOA->MODER &= ~(3 << 4); // Versuch: LED 2 Mode löschen :klappt
GPIOA->MODER |= (1 << 4); // Versuch: LED 2 PA1 = output :klappt
/* LED3 als output */
GPIOA->MODER &= ~(3 << 6);
GPIOA->MODER |= (1 << 6);
/* s0 (PB0) als Input Versuch */
GPIOB->MODER &= ~(3 << 0);
/* Pull-Up Aktivieren Versuch */
GPIOB->PUPDR &= ~(3 << 0);
GPIOB->PUPDR |= (1 << 0); // 01 = Pull-Up
}
/* ------------------------------------------------------------------------------------ *\
* method: static void delay(const uint16_t ms)
*
* Realizes a millisecond delay by very bad busy-wait.
*
* requires: - nothing -
* parameters: ms - delay time in milliseconds
* returns: - nothing -
\* ------------------------------------------------------------------------------------ */
static void delay(const uint16_t ms)
{
for (uint16_t i = 0; i < ms; ++i)
{
if((GPIOB->IDR & (1 << 0)) == 0){
state = 99;
break;
}
for (uint16_t j = 0; j < LOOPS_PER_MS; ++j)
{
__asm("NOP");
}
}
}
/* ************************************ E O F ***************************************** */
@@ -0,0 +1,8 @@
/*
* sketch.c
*
* Created on: Mar 18, 2026
* Author: tobii
*/
@@ -125,7 +125,7 @@ int main(void)
GPIOA->ODR |= MASK_LED_ALL;
while(1){
if((GPIOB->IDR & (1 << 0)) == 0){
delay(10);
delay(150);
state=0;
break;
}
@@ -0,0 +1,24 @@
/*
* sketch.c
*
* Created on: Mar 18, 2026
* Author: tobii
*/
int reihenfolge[6] = {0, 1, 2, 3, 2, 1};
int main(){
while(1){
while(/*schalter gedrückt*/){}
delay();
while(/*schalter losgelassen*/){}
delay();
int aktiv = 1;
while(aktiv){
for(int i; i < reihenfolge.length - 1; i ++){
//alle LED einschalten
if(i = 0)
}
}
}
}
@@ -1,6 +1,6 @@
IMPORT_FILES_AND_FOLDERS_RELATIVE=true
IMPORT_FILES_AND_FOLDERS_TYPE=23,1
eclipse.preferences.version=1
platformState=1772304866315
platformState=1772304866316
quickStart=false
tipsAndTricks=true
File diff suppressed because one or more lines are too long