extern void debugRGB(int rgbBits, int wait);

extern void __libc_csu_init (int argc, char **argv, char **envp);

extern void sketchEarlyInits();

extern void sketchLateInits();

extern void runSketch();

extern void flashAll(int);

#include "SFBAssert.h"
#include "SFBHWMisc.h"
#include "lpc/LPC23xx.h"
#include "clock.h"

static void low_hw_init() {
  setClockSpeed(CSC_72MHZ); 
}

int main() {

  debugRGB(3,0);                /* show blue-green if we hang after this */

  low_hw_init();                /* init clocks etc */

  debugRGB(2,0);                /* show green if we hang after this */

  __libc_csu_init (0, 0, 0);  /* run C++ static initializers */

  /*
   * As of this point, (at least) the following services are now
   * initialized:
   *
   * - SFBAlarms: Can schedule alarms on Alarms
   *
   * - SFBReactor: Can register packet handlers on Body
   */

  debugRGB(4,0);                /* show red if we hang after this */

  sketchEarlyInits();

  debugRGB(1,0);                /* show blue if we hang after this */

  sketchLateInits();

  debugRGB(0,1);                /* grand pause */

  runSketch();

  return 0; /* NOT REACHED */
}
