From 2587af1113ac079f854b25eefc8cec318b7b0c72 Mon Sep 17 00:00:00 2001 From: Matteo Valentini <matteo.valentini@student.tugraz.at> Date: Sun, 8 Dec 2024 03:31:51 +0100 Subject: [PATCH] improved documentation, added stdio_init_all() --- src/A1/gpio.c | 8 +++++--- src/A1/gpio.h | 6 +++--- src/A1/main.c | 2 ++ src/A1/vault.c | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/A1/gpio.c b/src/A1/gpio.c index c703e40..91ab62f 100644 --- a/src/A1/gpio.c +++ b/src/A1/gpio.c @@ -10,12 +10,13 @@ volatile uint32_t* sio_base = (uint32_t *)0xd0000000; /** Configures the pin to be in the given mode using IO_BANK0 * @param pin id of the gpio pin, make sure that it is between 0 and 31 - * @param function function of the pin. Functions are predefined as GPIO_FUNC_... + * @param function function of the pin, make sure it is between 0 and 31. Functions are predefined as GPIO_FUNC_... */ void set_gpio_function(const int pin, const int function) { // TODO student: // - ensure that the pin is between 0 and 29, otherwise return + // - ensure that the function is between 0 and 31, otherwise return // - configure the pin to use the given function by modifying the IO_BANK0 registers // ====================================================================== @@ -26,7 +27,7 @@ void set_gpio_function(const int pin, const int function) // TODO end ============================================================== } -/** Sets the input/output mode of the given pin using the SIO. +/** Sets the input/output mode of the given pin using the SIO. Furthermore, the input enable bit in the corresponding PADS_BANK0 register is set. * @param pin id of the gpio pin, make sure that it is between 0 and 31 * @param mode input/output mode, GPIO_IN for input, GPIO_OUT for output */ @@ -35,7 +36,8 @@ void set_gpio_mode(const int pin, const int mode) // TODO student: // - ensure that the pin is between 0 and 29, otherwise return // - ensure that a valid mode is given, otherwise return - // - configure weather the pin is an input or output by modifying the SIO registers + // - configure the pin as either an input or output by modifying the SIO registers + // - set the input enable bit in the corresponding PADS_BANK0 register // Hint: have a look at the OE registers // ====================================================================== diff --git a/src/A1/gpio.h b/src/A1/gpio.h index a6dc158..adc4a28 100644 --- a/src/A1/gpio.h +++ b/src/A1/gpio.h @@ -1,7 +1,7 @@ #pragma once #include <stdint.h> -// GPIO functions, see table 279 in the RP2040 datasheet +// GPIO functions /** Pin is used for SPI */ #define FUNC_SPI 1 /** Pin is used for UART */ @@ -35,11 +35,11 @@ /** Configures the pin to be in the given mode using IO_BANK0. * @param pin id of the gpio pin, make sure that it is between 0 and 29 - * @param function function of the pin. Functions are predefined as GPIO_FUNC_... + * @param function function of the pin, make sure it is between 0 and 31. Functions are predefined as GPIO_FUNC_... */ void set_gpio_function(int pin, int function); -/** Sets the input/output mode of the given pin using the SIO. +/** Sets the input/output mode of the given pin using the SIO. Furthermore, the input enable bit in the corresponding PADS_BANK0 register is set. * @param pin id of the gpio pin, make sure that it is between 0 and 29 * @param mode input/output mode, GPIO_IN for input, GPIO_OUT for output */ diff --git a/src/A1/main.c b/src/A1/main.c index e49fe3e..c6e3658 100644 --- a/src/A1/main.c +++ b/src/A1/main.c @@ -1,9 +1,11 @@ #include "vault.h" #include <stdio.h> +#include <pico/stdio.h> // You can modify this file for local testing, but it will be overridden by the testsystem int main() { + stdio_init_all(); vault_logic(); } \ No newline at end of file diff --git a/src/A1/vault.c b/src/A1/vault.c index 1c8ced5..ab91447 100644 --- a/src/A1/vault.c +++ b/src/A1/vault.c @@ -11,6 +11,7 @@ void vault_logic() //TODO student: // - implement the vault logic as described in the assignment // - use your functions defined in gpio.c and adc.c +// - set the ZERO_OFFSET define in vault.h to the correct value for your board // Do not use the gpio functions from the RPI Pico SDK. // ====================================================================== -- GitLab