void adc_complete(adc_channel_t *ch, volatile int16_t *dst, int len, void *param) { int n; for (n=0; n < len; n++) buf[n] += 32767; val = adc_read(ch); adc_handle_buffer((volatile uint16_t *)dst, len); vmemset(buf, 0x00, sizeof(buf)); adc_trace(ch, (volatile int16_t *)buf, sizeof(buf)/sizeof(uint16_t), 0, adc_complete, param); }
// Reset all stepper parameters, setup clocks, and make sure // there is no power to steppers. void initialize_stepper_state(void){ // Clock up all of the PITs SIM_SCGC6 |= SIM_SCGC6_PIT; PIT_MCR = 0x00; // Configure PIT 0 - main interrupt timer - as running at minimum steps/minute, but not // interrupting. set_step_events_per_minute(MINIMUM_STEPS_PER_MINUTE); // Configure PIT 1 and 2 - reset timer and sync timer PIT_TCTRL1 = TIE; PIT_TCTRL2 = TIE; // Zero all parameters, and go into idle vmemset(&st, 0, sizeof(st)); current_block = NULL; st.state = STATE_IDLE; if(init_hook_set) init_hook(); }
void init(void) { sys_init(); adc_channel_init(chan); vmemset(buf, 0x00, sizeof(buf)); }