This repository is going to be used to upload every task assigned in the Microcontrollers Programming class.
The project consists of two main files:
-
Inc/main.h: Declarations and prototypes for a delay structure and its associated functions are added in this file.
-
Src/main.c: The actual implementation of the delay structure and functions is provided here.
The main function initiates the LED and the delay structure. It enters a loop that follows this sequence:
- Turns the LED on for 100 ms.
- Waits for the delay to complete.
- Turns the LED off for 100 ms.
- Waits for the delay to complete.
This loop results in the LED blinking on and off in a periodic manner.
After implementing the code, it needs to be built and uploaded to the development board. This process activates the LED, causing it to blink in the specified pattern.
Feel free to explore each task directory for further details and specific implementations.
This task was tested using QEMU simulator.
The project consists of four main files:
-
Inc/main.h: Includes <API_delay.h>
-
Src/main.c: The actual implementation of the delay structure and functions is provided here.
-
Drivers/API/INC/API_delay.h: Declarations and prototypes for a delay structure and its associated functions are added in this file.
-
Drivers/API/SRC/API_delay.c: Where main functions and flow of the functionality is.
The flow of the code is as follows:
-
The functionInit() function is called to initialize the LEDs and the delay variable.
-
The ledCycle() function is called repeatedly in an infinite loop.
-
Inside the ledCycle() function, the LEDs are turned on and off in a specific pattern.
-
For each LED, the BSP_LED_On() function is called to turn the LED on, and the BSP_LED_Off() function is called to turn the LED off.
-
The delayWrite() function is called to set the delay for each LED, and the delayRead() function is called to wait for the delay to finish.
-
The pattern is repeated 5 times for each LED.
-
After all the LEDs have been cycled through, the ledCycle() function is called again to start the pattern over from the beginning.
-
This process continues indefinitely until the program is stopped or reset.
After implementing the code, it needs to be built and uploaded to the development board. This process activates the LEDS, causing it to blink in the specified pattern.
Feel free to explore each task directory for further details and specific implementations.
The project consists of four main files:
-
Inc/main.h: Includes <API_delay.h>
-
Src/main.c: The actual implementation of the delay structure and functions is provided here.
-
Drivers/API/INC/API_delay.h: Declarations and prototypes for a delay structure and its associated functions are added in this file.
-
Drivers/API/SRC/API_delay.c: Where functions and flow of the functionality is.
-
Drivers/API/INC/API_debounce.h: Declarations and prototypes for a debounce structure and its associated functions are added in this file.
-
Drivers/API/SRC/API_debounce.c: Where functions and flow of the functionality is.
The flow of the code is as follows:
-
Initialize the debounce state:
Call the debounceFSM_init() function to set the initial state to BUTTON_UP.
-
Read the button input:
Use the HAL library function HAL_GPIO_ReadPin() to read the state of the button.
-
Check the time difference:
Calculate the time difference between the current time and the last debounce time.
-
Update the debounce state:
Use a switch statement to handle the different debounce states.
For each state, check the button input and time difference to determine the next state.
-
Handle button press and release events:
If the button is pressed (BUTTON_DOWN state), call the buttonPressed() function to turn on the LED.
If the button is released (BUTTON_UP state), call the buttonReleased() function to turn off the LED.
-
Update the last debounce time:
Update the lastDebounceTime variable with the current time.
-
Call the debounceFSM_update() function periodically:
Call the debounceFSM_update() function in your main loop or using a timer interrupt to continuously update the debounce state.
After implementing the code, it needs to be built and uploaded to the development board.
Feel free to explore each task directory for further details and specific implementations.
The project consists of four main files:
-
Inc/main.h: Includes <API_delay.h>
-
Src/main.c: The actual implementation of the delay structure and functions is provided here.
-
Drivers/API/INC/API_delay.h: Declarations and prototypes for a delay structure and its associated functions are added in this file.
-
Drivers/API/SRC/API_delay.c: Where functions and flow of the functionality is.
-
Drivers/API/INC/API_debounce.h: Declarations and prototypes for a debounce structure and its associated functions are added in this file.
-
Drivers/API/SRC/API_debounce.c: Where functions and flow of the functionality is.
The flow of the code is as follows:
-
Initialization (main.c): Hardware and system initialization. Setup GPIO and system clock. Initialize debounce and other necessary components.
-
Main Loop (main.c): Continuous loop: Update debounce state machine. Add a small delay for proper debounce operation.
-
Debounce State Machine Update (API_debounce.c): Check button state transitions. Update debounce state and handle button press/release. Control LED blinking based on debounce.
-
Key State Reading (API_debounce.c): Read the current state of the key/button.
-
Error Handling (main.c): Handle initialization errors by turning on LED2 and entering an infinite loop.
After implementing the code, it needs to be built and uploaded to the development board.
Feel free to explore each task directory for further details and specific implementations.
The project consists of six main files:
-
Inc/main.h: Includes <API_delay.h>
-
Src/main.c: The actual implementation of the delay structure and functions is provided here.
-
Drivers/API/INC/API_delay.h: Declarations and prototypes for a delay structure and its associated functions are added in this file.
-
Drivers/API/SRC/API_delay.c: Where functions and flow of the functionality is.
-
Drivers/API/INC/API_debounce.h: Declarations and prototypes for a debounce structure and its associated functions are added in this file.
-
Drivers/API/SRC/API_debounce.c: Where functions and flow of the functionality is.
-
Drivers/API/SRC/API_uart.h: Declarations for uart use.
-
Drivers/API/SRC/API_uart.c: Uart usage and functions.
The flow of the code is as follows:
Same as "practica4.2" but using UART and showing the status of the button in the terminal.
After implementing the code, it needs to be built and uploaded to the development board.
Feel free to explore each task directory for further details and specific implementations.