static void sam3x_dac_start(struct Dac *dac, void *_buf, size_t len, size_t slice_len) { ASSERT(dac); ASSERT(len >= slice_len); /* Reset the previous status. */ dac->hw->end = false; sample_buff = (uint16_t *)_buf; next_idx = 0; chunk_size = slice_len; remaing_size = len; /* Program the dma with the first and second chunk of samples and update counter */ dac->ctx.callback(dac, &sample_buff[0], chunk_size); DACC_TPR = (uint32_t)&sample_buff[0]; DACC_TCR = chunk_size; remaing_size -= chunk_size; next_idx += chunk_size; if (chunk_size <= remaing_size) { dac->ctx.callback(dac, &sample_buff[next_idx], chunk_size); DACC_TNPR = (uint32_t)&sample_buff[next_idx]; DACC_TNCR = chunk_size; remaing_size -= chunk_size; next_idx += chunk_size; } DACC_PTCR |= BV(DACC_PTCR_TXTEN); DACC_IER = BV(DACC_ENDTX); /* Set up timer and trig the conversions */ tc_setup(dac->hw->rate, len); tc_start(); while (1) { event_wait(&buff_emtpy); if (dac->hw->end) break; remaing_size -= chunk_size; next_idx += chunk_size; if (remaing_size <= 0) { remaing_size = len; next_idx = 0; } dac->ctx.callback(dac, &sample_buff[next_idx], chunk_size); } }
static void sam3x_dac_conversion(struct Dac *dac, void *buf, size_t len) { /* setup timer and start it */ tc_setup(dac->hw->rate, len); tc_start(); /* Setup dma and start it */ DACC_TPR = (uint32_t)buf; DACC_TCR = len; DACC_PTCR |= BV(DACC_PTCR_TXTEN); }
/* Initialize the map display, at the beginning of the game.. */ init_screen() { int a, b; tc_setup(); clear_screen(); for(a = 1; a <= 28; a++) { for(b = 1; b <= 28; b++) { if(!off_map(a, b)) { disp_hex(a, b, '.'); } } } disp_craters(); }