Exemple #1
0
int main(void)
{
	sysclk_init();

	init_dbg_rs232(FMCK_HZ);

	init_gpio();
	assign_main_event_handlers();
	init_events();
	init_tc();
	init_spi();
	init_adc();

	irq_initialize_vectors();
	register_interrupts();
	cpu_irq_enable();

	init_usb_host();
	init_monome();

	if(flash_is_fresh()) {
		// nothing has been stored in the flash memory so far
		// so you need to initialize any variables you store in flash here with appropriate default values
	}
	else {
		// read from flash
		flash_read();
	}

	clock_pulse = &clock;
	clock_external = !gpio_get_pin_value(B09);

	// start timers that track clock, ADCs (including the clock and the param knobs) and the front panel button
	timer_add(&clockTimer,120,&clockTimer_callback, NULL);
	timer_add(&keyTimer,50,&keyTimer_callback, NULL);
	timer_add(&adcTimer,100,&adcTimer_callback, NULL);
	clock_temp = 10000; // out of ADC range to force tempo

	// main loop - you probably don't need to do anything here as everything should be done by handlers
	while (true) {
		check_events();
	}
}
Exemple #2
0
// top-level peripheral init
static void init_avr32(void) {
  volatile avr32_tc_t *tc = APP_TC;
  // clocks
  // setup clocks
  sysclk_init();

  // not sure why but when need to explictly enable clock for static mem ctlr
  sysclk_enable_pbb_module(SYSCLK_SMC_REGS);
  flashc_set_bus_freq(FCPU_HZ);
  // need this for high-speed operation
  flashc_set_wait_state(1);

  /// interrupts
  //  print_dbg("\r\n  irq_initialize_vectors() ");
  irq_initialize_vectors();
  // disable all interrupts for now
  //  print_dbg("\r\n  cpu_irq_disable() ");
  cpu_irq_disable();

  // serial usb
  print_dbg("\r\n  init_ftdi_usart() ");
  init_ftdi_usart();
  // external sram
  print_dbg("\r\n  smc_init(FHSB_HZ) ");
  smc_init(FHSB_HZ);

  // initialize spi1: OLED, ADC, SD/MMC
  print_dbg("\r\n  init_spi1() ");
  init_spi1();
  // initialize PDCA controller

  print_dbg("\r\n  init_local_pdca() ");
  init_local_pdca();

  // initialize blackfin resources
  print_dbg("\r\n  init_bfin_resources() ");
  init_bfin_resources();

  // initialize application timer
  print_dbg("\r\n  init_tc(tc) ");
  init_tc(tc);

  // initialize other GPIO
  print_dbg("\r\n  init_gpio() ");
  init_gpio();

  // register interrupts
  print_dbg("\r\n  register_interrupts() ");
  register_interrupts();

  // initialize the OLED screen
  print_dbg("\r\n  init_oled() ");
  init_oled();

  // enable interrupts
  print_dbg("\r\n  cpu_irq_enable() ");
  cpu_irq_enable();

  // usb host controller
  init_usb_host();
  // initialize usb classes
  print_dbg("\r\n init_monome ");
  init_monome();
  //  init_midi();
  //  init_hid();
}
Exemple #3
0
int main(void) {
	u8 i1;

	sysclk_init();

	init_dbg_rs232(FMCK_HZ);

	init_gpio();
	assign_main_event_handlers();
	init_events();
	init_tc();
	init_spi();
	init_adc();

	irq_initialize_vectors();
	register_interrupts();
	cpu_irq_enable();

	init_usb_host();
	init_monome();

	init_i2c_slave(0x30);

	print_dbg("\r\n\n// meadowphysics //////////////////////////////// ");
	print_dbg_ulong(sizeof(flashy));

	print_dbg(" ");
	print_dbg_ulong(sizeof(m));


	if(flash_is_fresh()) {
		print_dbg("\r\nfirst run.");
		flash_unfresh();
		flashc_memset32((void*)&(flashy.preset_select), 0, 4, true);


		// clear out some reasonable defaults
		for(i1=0;i1<8;i1++) {
			m.positions[i1] = i1;
			m.points[i1] = i1;
			m.points_save[i1] = i1;
			m.triggers[i1] = 0;
			m.trig_dests[i1] = 0;
			m.rules[i1] = 0;
			m.rule_dests[i1] = i1;
		}

		m.positions[0] = m.points[0] = 3;
		m.trig_dests[0] = 254;

		// save all presets, clear glyphs
		for(i1=0;i1<8;i1++) {
			flashc_memcpy((void *)&flashy.m[i1], &m, sizeof(m), true);
			glyph[i1] = (1<<i1);
			flashc_memcpy((void *)&flashy.glyph[i1], &glyph, sizeof(glyph), true);
		}
	}
	else {
		// load from flash at startup
		preset_select = flashy.preset_select;
		flash_read();
		for(i1=0;i1<8;i1++)
			glyph[i1] = flashy.glyph[preset_select][i1];
	}

	LENGTH = 15;
	SIZE = 16;

	re = &refresh;

	process_ii = &mp_process_ii;

	clock_pulse = &clock;
	clock_external = !gpio_get_pin_value(B09);

	timer_add(&clockTimer,120,&clockTimer_callback, NULL);
	timer_add(&keyTimer,50,&keyTimer_callback, NULL);
	timer_add(&adcTimer,100,&adcTimer_callback, NULL);
	clock_temp = 10000; // out of ADC range to force tempo

	while (true) {
		check_events();
	}
}