void HAL_init() { // Support the 4 LEDs some LPC176x boards have #if PIN_EXISTS(LED) SET_DIR_OUTPUT(LED_PIN); WRITE_PIN_CLR(LED_PIN); #if PIN_EXISTS(LED2) SET_DIR_OUTPUT(LED2_PIN); WRITE_PIN_CLR(LED2_PIN); #if PIN_EXISTS(LED3) SET_DIR_OUTPUT(LED3_PIN); WRITE_PIN_CLR(LED3_PIN); #if PIN_EXISTS(LED4) SET_DIR_OUTPUT(LED4_PIN); WRITE_PIN_CLR(LED4_PIN); #endif #endif #endif // Flash status LED 3 times to indicate Marlin has started booting for (uint8_t i = 0; i < 6; ++i) { TOGGLE(LED_PIN); delay(100); } #endif //debug_frmwrk_init(); //_DBG("\n\nDebug running\n"); // Initialise the SD card chip select pins as soon as possible #if PIN_EXISTS(SS) WRITE(SS_PIN, HIGH); SET_OUTPUT(SS_PIN); #endif #if defined(ONBOARD_SD_CS) && ONBOARD_SD_CS > -1 WRITE(ONBOARD_SD_CS, HIGH); SET_OUTPUT(ONBOARD_SD_CS); #endif USB_Init(); // USB Initialization USB_Connect(FALSE); // USB clear connection delay(1000); // Give OS time to notice USB_Connect(TRUE); #if DISABLED(USB_SD_DISABLED) MSC_SD_Init(0); // Enable USB SD card access #endif const millis_t usb_timeout = millis() + 2000; while (!USB_Configuration && PENDING(millis(), usb_timeout)) { delay(50); HAL_idletask(); #if PIN_EXISTS(LED) TOGGLE(LED_PIN); // Flash quickly during USB initialization #endif } #if NUM_SERIAL > 0 MYSERIAL0.begin(BAUDRATE); #if NUM_SERIAL > 1 MYSERIAL1.begin(BAUDRATE); #endif SERIAL_PRINTF("\n\necho:%s (%dMhz) Initialized\n", isLPC1769() ? "LPC1769" : "LPC1768", SystemCoreClock / 1000000); SERIAL_FLUSHTX(); #endif HAL_timer_init(); }
int main(void){ init(); while (1){ /* * This function will look for new messages from the AFSK channel. * It will call the message_callback() function when a new message is received. * If there's nothing to do, this function will call cpu_relax() */ ax25_poll(&g_ax25); check_run_mode(); switch(currentMode){ case MODE_CFG: #if MOD_CONSOLE console_poll(); #endif #if MOD_BEACON beacon_broadcast_poll(); #endif break; #if MOD_TRACKER case MODE_TRACKER: tracker_poll(); break; #endif #if MOD_KISS case MODE_KISS:{ kiss_poll(); break; } #endif #if MOD_DIGI case MODE_DIGI:{ console_poll(); beacon_broadcast_poll(); break; } #endif default: break; }// end of switch(runMode) #if DEBUG_FREE_RAM { static ticks_t ts = 0; if(timer_clock_unlocked() - ts > ms_to_ticks(5000)){ ts = timer_clock_unlocked(); uint16_t ram = freeRam(); SERIAL_PRINTF((&g_serial),"%u\r\n",ram); } } #endif #if DEBUG_SOFT_SER // Dump the isr changes { SoftSerial *softSer = radioPort; static uint32_t i = 0; //static uint32_t j = 0; if(i++ == 30000){ i = 0; char c; while(softser_avail(softSer)){ c = softser_read(softSer); kfile_putc(c,&(g_serial.fd)); } char buf[8]; sprintf_P(buf,PSTR("0K\n\r")); softser_print(softSer,buf); } } #endif } // end of while(1) return 0; }