diff --git a/.gitignore b/.gitignore index b028dd1fed81113bb8a80d96d31dec5aaddfd50f..5825b1b18abdbfd17bf9ce10475a271a04b54c4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/** +submission/** *.swp diff --git a/buzz_cycle_stubs/CMakeLists.txt b/buzz_cycle_stubs/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3190487b9a699745195911963c6ece5061ef25b1 --- /dev/null +++ b/buzz_cycle_stubs/CMakeLists.txt @@ -0,0 +1,17 @@ +if (TARGET tinyusb_device) + +add_library(buzzer STATIC buzzer.h) +target_link_libraries(buzzer hardware_pwm picostdlib) + +add_executable(buzz_cycle buzz_cycle.c) +target_link_libraries(buzz_cycle buzzer pico_stdlib) + +pico_enable_stdio_usb(buzz_cycle 1) +pico_enable_stdio_uart(buzz_cycle 0) + +pico_add_extra_outputs(buzz_cycle) + +elseif(PICO_ON_DEVICE) + message(WARNING "cannot build buzz_cycle because TinyUSB submodule is not initialised in the SDK") +endif() + diff --git a/buzz_cycle_stubs/buzz_cycle.c b/buzz_cycle_stubs/buzz_cycle.c new file mode 100644 index 0000000000000000000000000000000000000000..2ae99701f3e552aafba376b5af1456dcff217336 --- /dev/null +++ b/buzz_cycle_stubs/buzz_cycle.c @@ -0,0 +1,37 @@ +#include <stdint.h> +#include <stdbool.h> +#include <stdio.h> +#include "pico/stdlib.h" +#include "buzzer.h" + +static int64_t period = 1000000; +static bool alarm_status = false; + +// timer callback that controls the buzzer +static int64_t buzz_isr(alarm_id_t id, void* data) { + +} + +// initialise stdio and the buzzer +static inline void init() { + +} + +static inline void start_timer() { + +} + +// allow the user to enter a period in microseconds +int64_t get_period() { + +} + +int main(void) { + init(); + start_timer(); + + while (true) { + period = get_period(); + } +} + diff --git a/buzz_cycle_stubs/buzzer.h b/buzz_cycle_stubs/buzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c84a66f1ac0fe2995b309587957f979f271418ac --- /dev/null +++ b/buzz_cycle_stubs/buzzer.h @@ -0,0 +1,24 @@ +#pragma once + +#include <stdint.h> +#include "pico/stdlib.h" +#include "hardware/pwm.h" + +const unsigned int buzzer = 18u; + +static inline void buzzer_enable() { + +} + +static inline void buzzer_disable() { + +} + +static inline void buzzer_toggle(uint64_t time) { + +} + +void buzzer_init() { + +} + diff --git a/fixmath_stubs/fixmath.c b/fixmath_stubs/fixmath.c new file mode 100644 index 0000000000000000000000000000000000000000..cf35cf7e533b51be86c03ba5ff2ee31148a641f5 --- /dev/null +++ b/fixmath_stubs/fixmath.c @@ -0,0 +1,28 @@ +#include "fixmath.h" + +#include <stdint> + +fix_t fix_emul(fix_t x, fix_t y) { + +} + +fix_t fix_ediv(fix_t x, fix_t y) { + +} + +fix_t fix_esqrt(fix_t x) { + +} + +fix_unit_t fix_umul(fix_unit_t x, fix_unit_t y) { + +} + +fix_unit_t fix_udiv(fix_unit_t x, fix_unit_t y) { + +} + +fix_unit_t fix_usqrt(fix_unit_t x) { + +} + diff --git a/fixmath_stubs/fixmath.h b/fixmath_stubs/fixmath.h new file mode 100644 index 0000000000000000000000000000000000000000..ffc1a48102e27b97f5b9c97538b82ed712d172a7 --- /dev/null +++ b/fixmath_stubs/fixmath.h @@ -0,0 +1,66 @@ +#pragma once + +#include <stdint> + +// standard, even type (16.16) with range [-32768, 32768) +typedef struct { + uint32_t raw; +} fix_t; + +// unit type (1.31) with range [-1, 1) +typedef struct { + uint32_t raw; +} fix_unit_t; + +// fix_t functions +static inline fix_t fix_eadd(fix_t x, fix_t y) { + +} + +static inline fix_t fix_esub(fix_t x, fix_t y) { + +} + +static inline fix_t fix_eneg(fix_t x) { + +} + +fix_t fix_emul(fix_t x, fix_t y); +fix_t fix_ediv(fix_t x, fix_t y); + +fix_t fix_esqrt(fix_t x); + +static inline fix_t fix_efrom_int(int x) { + +} + +// fix_unit_t functions +static inline fix_unit_t fix_uadd(fix_unit_t x, fix_unit_t y) { + +} + +static inline fix_unit_t fix_usub(fix_unit_t x, fix_unit_t y) { + +} + +static inline fix_unit_t fix_eneg(fix_t x) { + +} + +fix_unit_t fix_umul(fix_unit_t x, fix_unit_t y); +fix_unit_t fix_udiv(fix_unit_t x, fix_unit_t y); + +fix_unit_t fix_usqrt(fix_unit_t x); + +static inline fix_unit_t fix_ufrom_reciprocal(int x) { + +} + +// generic macros +# define fix_add(x, y) _Generic(x, fix_t: fix_eadd, fix_unit_t: fix_uadd)(x, y) +# define fix_sub(x, y) _Generic(x, fix_t: fix_esub, fix_unit_t: fix_usub)(x, y) +# define fix_mul(x, y) _Generic(x, fix_t: fix_emul, fix_unit_t: fix_umul)(x, y) +# define fix_div(x, y) _Generic(x, fix_t: fix_ediv, fix_unit_t: fix_udiv)(x, y) + +# define fix_sqrt(x) _Generic(x, fix_t: fix_esqrt, fix_unit_t: fix_usqrt)(x) +