3 //Display unsigned 32-bit number through m15
4 //Read as follows: 1230 = || ||| |||| | (note always ending toggle)
5 void m15_print(uint32_t x)
12 else if (x < 100) t = 1;
13 else if (x < 1000) t = 2;
14 else if (x < 10000) t = 3;
15 else if (x < 100000) t = 4;
16 else if (x < 1000000) t = 5;
17 else if (x < 10000000) t = 6;
18 else if (x < 100000000) t = 7;
19 else if (x < 1000000000) t = 8;
35 //Will always end with an extra toggle
42 //Display unsigned 32-bit number through debug led
43 //Read as follows: 1230 = [*] [* *] [* * *] [**] (note zero is fast double flash)
44 #define DLED_ONTIME 1000000
45 #define DLED_PAUSE 1500000
47 void dled_print(uint32_t x, uint8_t long_pause)
54 else if (x < 100) t = 1;
55 else if (x < 1000) t = 2;
56 else if (x < 10000) t = 3;
57 else if (x < 100000) t = 4;
58 else if (x < 1000000) t = 5;
59 else if (x < 10000000) t = 6;
60 else if (x < 100000000) t = 7;
61 else if (x < 1000000000) t = 8;
74 for (w = DLED_ONTIME / 4; w; w--);
76 for (w = DLED_ONTIME / 4; w; w--);
78 for (w = DLED_ONTIME / 4; w; w--);
80 for (w = DLED_ONTIME / 4; w; w--);
88 for (w = DLED_ONTIME; w; w--);
90 for (w = DLED_ONTIME / 2; w; w--);
95 for (w = DLED_PAUSE; w; w--);
101 for (w = DLED_PAUSE * 4; w; w--);
105 #ifdef DEBUG_BOOT_TRACING
107 volatile uint32_t debug_code;
109 void EIC_15_Handler()
111 //This is only for non-functional keyboard troubleshooting and should be disabled after boot
112 //Intention is to lock up the keyboard here with repeating debug led code
115 dled_print(debug_code, 1);
119 void debug_code_init(void)
123 //Configure Ports for EIC on PB31
124 PORT->Group[1].DIRCLR.reg = 1 << 31; //Input
125 PORT->Group[1].OUTSET.reg = 1 << 31; //High
126 PORT->Group[1].PINCFG[31].bit.INEN = 1; //Input Enable
127 PORT->Group[1].PINCFG[31].bit.PULLEN = 1; //Pull Enable
128 PORT->Group[1].PINCFG[31].bit.PMUXEN = 1; //Mux Enable
129 PORT->Group[1].PMUX[15].bit.PMUXO = 0; //Mux A
132 MCLK->APBAMASK.bit.EIC_ = 1;
135 EIC->CTRLA.bit.SWRST = 1;
136 while (EIC->SYNCBUSY.bit.SWRST) {}
137 EIC->ASYNCH.reg = 1 << 15;
138 EIC->INTENSET.reg = 1 << 15;
139 EIC->CONFIG[1].bit.SENSE7 = 2;
140 EIC->CTRLA.bit.ENABLE = 1;
141 while (EIC->SYNCBUSY.bit.ENABLE) {}
144 NVIC_EnableIRQ(EIC_15_IRQn);
147 void debug_code_disable(void)
150 NVIC_DisableIRQ(EIC_15_IRQn);
153 EIC->CTRLA.bit.ENABLE = 0;
154 while (EIC->SYNCBUSY.bit.ENABLE) {}
156 //Disable CLK_EIC_APB
157 MCLK->APBAMASK.bit.EIC_ = 0;
162 void debug_code_init(void) {}
163 void debug_code_disable(void) {}
165 #endif //DEBUG_BOOT_TRACING