void init(FMSynth * synth) { /* // ---------- SysTick timer -------- // if (SysTick_Config(SystemCoreClock / 1000)) { // Capture error while (1){}; } */ // ---------- GPIO -------- // // GIPO Periph clock enable RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); leds_setup(); buttons_setup(); dac_setup(synth); midi::init(); adc::init(); }
/* main work function */ void work(void) { unsigned short i, j; unsigned char mailbox_num = 0; volatile ProtoIOMBox * mbox; /* setup status */ status_setup(); /* setup serial console */ usart1_setup(); /* setup proto */ proto_setup(); mbox = proto_srv_dat.mailboxes[mailbox_num]; /* setup button */ buttons_setup(); /* lcd setup */ LCD_Setup(); LCD_Clear(BLACK); for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { LCD_Pixel(j + 10, i + 10, test.data[i * 10 + j]); } } LCD_Window(0, 0, 9, 9); LCD_RS_LOW; LCD_SELECT; for (i = 0; i < 100; i++) { LCD_Send(test.data[i] >> 8); LCD_Send(test.data[i] & 0x00ff); } LCD_Cursor(0, 0); LCD_DESEL; /* check status */ check_status(); /* send ping */ mbox->outbox->header = 'C'; /* Command */ mbox->outbox->size = 0x00; /* 0 for ping request */ mbox->outbox_s = PROTO_IO_MBOX_READY; /* Box ready */ mbox->inbox->size = 64; /* buffer len for control */ mbox->inbox_s = PROTO_IO_MBOX_READY; /* Box ready */ /* wait connection estabilished */ while (status == 0); /* send ping message */ proto_send_msg(mailbox_num); /* wait to send message */ while (mbox->outbox_s <= PROTO_IO_MBOX_SEND); if (mbox->outbox_s == PROTO_IO_MBOX_COMPLETE) LCD_String("Con", 36, 6, 1, WHITE, GLASSY); else LCD_String("Un", 36, 6, 1, RED, GLASSY); /* get ping message */ /* FIXME wtf? this not work or work parity */ //proto_get_msg(mailbox_num); /* wait to get message */ while (mbox->inbox_s <= PROTO_IO_MBOX_SEND); if (mbox->inbox_s == PROTO_IO_MBOX_COMPLETE) { LCD_String("OK", 36 + 3 * 7, 6, 1, GREEN, GLASSY); for (i = 0; i < mbox->inbox->size; i++) LCD_Char(mbox->inbox->message[i], 70 + i * 6, 6, 1, WHITE, GLASSY); } else LCD_String("ERR", 36 + 3 * 7, 6, 1, RED, GLASSY); /* infinity loop */ while (1) { if (button_state.state[B_LGHT] == B_CLICK) { sender('+'); button_state.state[B_LGHT] = B_RELEASE; } if (button_state.state[B_MOD] == B_CLICK) { sender('m'); button_state.state[B_MOD] = B_RELEASE; } if (button_state.state[B_SET] == B_CLICK) { sender('-'); button_state.state[B_SET] = B_RELEASE; } if (button_state.state[B_UP] == B_CLICK) { sender('<'); button_state.state[B_UP] = B_RELEASE; } if (button_state.state[B_SU] == B_CLICK) { sender('p'); button_state.state[B_SU] = B_RELEASE; } if (button_state.state[B_DWN] == B_CLICK) { sender('>'); button_state.state[B_DWN] = B_RELEASE; } } }
void dc_electronic_load_setup() { setCurrentMilliamps = 0; readCurrentMilliamps = 0; readMilliVolts = 0; setRateIndex = 0; readCurrentMilliampsDisplay = DISPLAY_MILLI; gfxState = GFX_STATE_MEASURE; dma_ring_buffer_init(&g_debugUsartDmaInputRingBuffer, DEBUG_USART_RX_DMA_CH, g_debugUsartRxBuffer, DEBUG_USART_RX_BUFFER_SIZE); debug_setup(); debug_write_line("?BEGIN setup"); process_init(); process_start(&etimer_process, NULL); process_start(&debug_process, NULL); #ifdef DISP6800_ENABLE process_start(&gfx_update_process, NULL); process_poll(&gfx_update_process); #endif spi_setup(); #ifdef DISP6800_ENABLE disp6800_setup(); gfx_setup(); #endif #ifdef ENCODER_ENABLE encoder_setup(); #endif #ifdef FLASH_ENABLE flashsst25_setup(); #endif #ifdef MAC_ENABLE mac25aa02e48_setup(); mac25aa02e48_read_eui48(); #endif #ifdef ADC_ENABLE adc_setup(); #endif #ifdef DAC_ENABLE dac_setup(); dac_set(0); #endif #ifdef NETWORK_ENABLE network_setup(EUI48); #endif #ifdef FAN_ENABLE fan_setup(); #endif #ifdef BUTTONS_ENABLE buttons_setup(); #endif time_setup(); recorder_setup(); debug_write_line("?END setup"); }