diff --git a/src/A1/gpio.c b/src/A1/gpio.c index c703e40ffaa895cc0e2a8f62fbf1c5e1a31331df..91ab62f6cad916c4c990a7231c3d29fc040ac93f 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 a6dc1587818cceeaf4479a7dcb369fe8b17730b4..adc4a28c6cb1f8f54584ff69528a24e01278636f 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 e49fe3e2c519e2fce3cadf7d71dfddd35a7cab37..c6e365801f01bb4071728172d137da884f347308 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 1c8ced5809f8717530d7f683cae82b027c9616d8..ab91447823e8b2a55ddf385c7990e449913ddbab 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. // ======================================================================