aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/main.c b/src/main.c
index 8deb257..525db53 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,6 +18,7 @@
#include "system.h"
#include "systick.h"
#include "ws2812b.h"
+#include "gpio.h"
#ifndef LED_BYTE_ORDER
#define LED_BYTE_ORDER GRB
@@ -61,7 +62,6 @@ uint8_t amp(uint8_t in, uint8_t n)
return min(out, 255);
}
-
static void set_system_clock_60Mhz(void)
{
clock_cfg_t clk_cfg = {0};
@@ -74,7 +74,7 @@ static void set_system_clock_60Mhz(void)
}
#define N_LEDS 255
-#define N_DMA_XFER 3
+#define N_DMA_XFER 4
extern int uart1_FILE_get(FILE* f);
@@ -89,24 +89,26 @@ static size_t debounce = 0;
On_SysTick()
{
if (debounce > 0) {
- debounce --;
+ debounce--;
}
time++;
spin_lock = 0;
}
-On_BootSelPress()
+On_Gpio(gpio_pin_t pin)
{
- if (debounce > 0) return;
- debounce = 10;
-
- size_t tmp = current_pattern_idx;
- tmp ++;
- if (tmp >= n_patterns) {
- tmp = 0;
+ if (pin == PIN_PB7) {
+ if (debounce > 0) return;
+ debounce = 10;
+
+ size_t tmp = current_pattern_idx;
+ tmp++;
+ if (tmp >= n_patterns) {
+ tmp = 0;
+ }
+ current_pattern_idx = tmp;
+ printf("Switch to '%s'\n", patterns[current_pattern_idx].name);
}
- current_pattern_idx = tmp;
- printf("Switch to '%s'\n", patterns[current_pattern_idx].name);
}
/*
@@ -117,12 +119,6 @@ int main(void)
char buf[N_LEDS * TOTAL_BYTES_PER_LED];
PFIC_I.vector_table_control.set(PFIC, 1);
- PFIC->interrupt_priority_threshold = 0x10;
- PFIC->interrupt_enable |= IRQ_SysTick;
- PFIC->interrupt_priority_threshold = 0x10;
- PFIC->interrupt_enable |= IRQ_GpioA;
- PFIC->interrupt_priority_threshold = 0x10;
- PFIC->interrupt_enable |= IRQ_GpioB;
set_system_clock_60Mhz();
set_systick(250000);
@@ -148,7 +144,9 @@ int main(void)
printf("\nRunning Pattern '%s'\n", patterns[current_pattern_idx].name);
- enable_bootsel_button();
+ configure_gpio(PIN_PB7, PIN_CFG_INPUT_PULL_UP);
+ enable_gpio_interrupt(PIN_PB7, INT_MODE_FALLING_EDGE);
+ // enable_bootsel_button();
size_t n = sizeof(buf);
struct ws2812b_buf ws_buf;