aboutsummaryrefslogtreecommitdiff
path: root/src/kern/main.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-12-09 15:20:40 -0700
committerJosh Rahm <joshuarahm@gmail.com>2022-12-09 15:20:40 -0700
commitac25063e15d7aa645f7567b9bdb0726e5c332fd6 (patch)
tree1a18f6d80cbcc25ce50ebb23c3a81f2d802130e9 /src/kern/main.c
parent2aaf2180aa352c71c43efd548893fffe506397e5 (diff)
downloadstm32l4-broken_linker.tar.gz
stm32l4-broken_linker.tar.bz2
stm32l4-broken_linker.zip
Refactor the linker script to make more sense.broken_linker
Specifically this moves the inits into the .text section. This also move the data and bss segments into sram2 to give the heap and stack more space to work with in sram1.
Diffstat (limited to 'src/kern/main.c')
-rw-r--r--src/kern/main.c105
1 files changed, 57 insertions, 48 deletions
diff --git a/src/kern/main.c b/src/kern/main.c
index 61e60c9..7c0b65d 100644
--- a/src/kern/main.c
+++ b/src/kern/main.c
@@ -35,7 +35,7 @@ volatile struct {
signed int timetick;
ws2812b_t* drv;
uint8_t brightness;
- uint8_t n_leds;
+ uint16_t n_leds;
uint8_t off;
uint8_t n_snow;
uint8_t n_red;
@@ -201,7 +201,8 @@ static void reset_state()
memset((void*)&state, 0, sizeof(state));
state.drv = tmp;
state.brightness = 255;
- state.n_leds = 250;
+ state.n_leds = 300;
+ state.n_red = 100;
state.off = 8;
state.timetick = 10;
state.power = 1;
@@ -211,52 +212,60 @@ static void reset_state()
/* Main function. This gets executed from the interrupt vector defined above. */
int main()
{
- klogf("Entering Main (%p).\n", main);
-
- // systick_add_callback(on_systick, NULL);
- // enable_systick(10000);
- // configure_gpio();
-
- // ir_begin_listen();
- // enable_ir_control();
-
- // add_ir_code_callback(RC_HIGH, printit, "RC_HIGH");
- // add_ir_code_callback(RC_TEMP_UP, timetick_up, NULL);
- // add_ir_code_callback(RC_DRY, set_red, NULL);
- // add_ir_code_callback(RC_LOW, printit, "RC_LOW");
- // add_ir_code_callback(RC_TEMP_DOWN, timetick_down, NULL);
- // add_ir_code_callback(RC_COOL, toggle_cool, NULL);
- // add_ir_code_callback(RC_CONTINUOUS, set_snow, "RC_CONTINUOUS");
- // add_ir_code_callback(RC_FAN, toggle_brightness, NULL);
- // add_ir_code_callback(RC_SLEEP, toggle_sleep, NULL);
- // add_ir_code_callback(RC_UNITS, printit, "RC_UNITS");
- // add_ir_code_callback(RC_TIMER, reset_state, NULL);
- // add_ir_code_callback(RC_POWER, toggle_power, NULL);
-
- // int ec;
- // state.drv = ws2812b_new(SPI_SELECT_SPI1, &ec);
-
- // if (ec || !state.drv) {
- // panic("Unable to create WS2812b driver :( (%d)\n", ec);
- // }
-
- // reset_state();
-
- // for (int i = 0; i < state.n_leds; ++i) {
- // /* Clear the LED strip. */
- // disable_all_interrupts();
- // ws2812b_write_rgb_sync(state.drv, 0, 0, 0);
- // enable_all_interrupts();
- // }
- // ws2812b_latch(state.drv);
-
- // for (;;) {
- // // while (!do_redraw)
- // // ;
- // // do_redraw = 0;
- // if (!state.sleep) redraw();
- // }
- for (;;);
+ klogf("Entering Main\n");
+
+ gpio_reserved_pin_t pin3 = get_sysled();
+
+ systick_add_callback(on_systick, NULL);
+ enable_systick(10000);
+ configure_gpio();
+
+ ir_begin_listen();
+ enable_ir_control();
+
+ add_ir_code_callback(RC_HIGH, printit, "RC_HIGH");
+ add_ir_code_callback(RC_TEMP_UP, timetick_up, NULL);
+ add_ir_code_callback(RC_DRY, set_red, NULL);
+ add_ir_code_callback(RC_LOW, printit, "RC_LOW");
+ add_ir_code_callback(RC_TEMP_DOWN, timetick_down, NULL);
+ add_ir_code_callback(RC_COOL, toggle_cool, NULL);
+ add_ir_code_callback(RC_CONTINUOUS, set_snow, "RC_CONTINUOUS");
+ add_ir_code_callback(RC_FAN, toggle_brightness, NULL);
+ add_ir_code_callback(RC_SLEEP, toggle_sleep, NULL);
+ add_ir_code_callback(RC_UNITS, printit, "RC_UNITS");
+ add_ir_code_callback(RC_TIMER, reset_state, NULL);
+ add_ir_code_callback(RC_POWER, toggle_power, NULL);
+
+ int ec;
+ state.drv = ws2812b_new(SPI_SELECT_SPI1, &ec);
+
+ if (ec || !state.drv) {
+ panic("Unable to create WS2812b driver :( (%d)\n", ec);
+ }
+
+ reset_state();
+
+ for (int i = 0; i < state.n_leds; ++i) {
+ /* Clear the LED strip. */
+ disable_all_interrupts();
+ ws2812b_write_rgb_sync(state.drv, 0, 0, 0);
+ enable_all_interrupts();
+ }
+ ws2812b_latch(state.drv);
+
+ for (int i = 0; ; ++ i) {
+ if (i % 64 == 0) {
+ set_gpio_pin_high(pin3);
+ }
+ // while (!do_redraw)
+ // ;
+ // do_redraw = 0;
+ if (!state.sleep) redraw();
+
+ if (i % 64 == 0) {
+ set_gpio_pin_low(pin3);
+ }
+ }
}
#endif