File tree Expand file tree Collapse file tree 2 files changed +76
-2
lines changed Expand file tree Collapse file tree 2 files changed +76
-2
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ INC += -I../../lib/contiki-core
5555INC += -I../../lib/lego
5656INC += -I../../lib/libfixmath/libfixmath
5757INC += -Inxt-firmware-drivers
58+ INC += -Inxt-firmware-drivers/nxt
5859INC += -I../../lib/pbio/include
5960INC += -I../../lib/pbio/platform/$(PBIO_PLATFORM )
6061INC += -I../../lib/pbio
@@ -113,7 +114,6 @@ SRC_C_NXT := $(addprefix nxt-firmware-drivers/nxt/,\
113114 flashwrite.c \
114115 hs.c \
115116 i2c.c \
116- maininit.c \
117117 nxt_avr.c \
118118 nxt_lcd.c \
119119 nxt_motors.c \
Original file line number Diff line number Diff line change 2626#include "py/mphal.h"
2727
2828#include <nxt/display.h>
29- #include <nxt/maininit.h>
29+
30+ #define _INIT_H_
31+ #include "interrupts.h"
32+ #include "aic.h"
33+ #include "at91sam7.h"
34+ #include "uart.h"
35+ #include "systick.h"
36+ #include "stdio.h"
37+ #include "flashprog.h"
38+ #include "nxt_avr.h"
39+ #include "twi.h"
40+ #include "sensors.h"
41+
42+ #include "nxt_avr.h"
43+ #include "nxt_lcd.h"
44+ #include "i2c.h"
45+ #include "nxt_motors.h"
46+
47+ #include "lejos_nxt.h"
48+
49+ #include "display.h"
50+ #include "sound.h"
51+ #include "bt.h"
52+ #include "udp.h"
53+ #include "flashprog.h"
54+ #include "hs.h"
55+
56+ #include <string.h>
57+
58+ void shutdown (int update_mode ) {
59+ nxt_lcd_enable (0 );
60+ for (;;) {
61+ if (update_mode ) {
62+ nxt_avr_firmware_update_mode ();
63+ } else {
64+ nxt_avr_power_down ();
65+ }
66+ }
67+ }
68+
69+ void nxt_init () {
70+ aic_initialise ();
71+ sp_init ();
72+ interrupts_enable ();
73+ systick_init ();
74+ sound_init ();
75+ nxt_avr_init ();
76+ nxt_motor_init ();
77+ i2c_init ();
78+ bt_init ();
79+ hs_init ();
80+ udp_init ();
81+ systick_wait_ms (100 );
82+ sound_freq (500 , 100 , 30 );
83+ systick_wait_ms (1000 );
84+ display_init ();
85+ sp_init ();
86+ display_set_auto_update_period (DEFAULT_UPDATE_PERIOD );
87+ }
88+
89+ void nxt_deinit () {
90+
91+ sound_freq (1000 , 100 , 30 );
92+ display_reset ();
93+ nxt_motor_reset_all ();
94+ udp_reset ();
95+ bt_reset ();
96+ bt_disable ();
97+ hs_disable ();
98+ i2c_disable_all ();
99+ sound_reset ();
100+
101+ // Erase firmware on shutdown, for easy development
102+ shutdown (1 );
103+ }
30104
31105static char * stack_top ;
32106#if MICROPY_ENABLE_GC
You can’t perform that action at this time.
0 commit comments