int USART_GetChar(void) { return RingBufferGet(&RingBufferUART4RX); }
void OnAxisTimerOverflow () { PORTE.OUTSET = 0x01; if (time == 0) { // Nothing to do if (!buffer_lock && !RingBufferIsEmpty(&location_buffer)) { Location_t next = RingBufferGet(&location_buffer); x_axis.delta = next.x - x_axis.location; y_axis.delta = next.y - y_axis.location; z_axis.delta = next.z - z_axis.location; time = next.time; ovf_count = 0; } //if(location_buffer_size > 0) //{ // x_axis.delta = nextLocation.x - x_axis.location; // y_axis.delta = nextLocation.y - y_axis.location; // z_axis.delta = nextLocation.z - z_axis.location; // time = nextLocation.time; // ovf_count = 1; // location_buffer_size--; //} //else //{ // x_axis.delta = 0; // y_axis.delta = 0; // z_axis.delta = 0; //} } else { UpdateAxis (&x_axis); UpdateAxis (&y_axis); UpdateAxis (&z_axis); if (ovf_count >= time) { time = 0; if (!buffer_lock && !RingBufferIsEmpty(&location_buffer)) { Location_t next = RingBufferGet(&location_buffer); x_axis.delta = next.x - x_axis.location; y_axis.delta = next.y - y_axis.location; z_axis.delta = next.z - z_axis.location; time = next.time; ovf_count = 0; } //if(location_buffer_size > 0) //{ // x_axis.delta = nextLocation.x - x_axis.location; // y_axis.delta = nextLocation.y - y_axis.location; // z_axis.delta = nextLocation.z - z_axis.location; // time = nextLocation.time; // ovf_count = 0; // location_buffer_size--; //} //else //{ // // TODO: If there's a buffer of positions, move to the next one here // // (set delta, time, and count accordingly) // x_axis.delta = 0; // y_axis.delta = 0; // z_axis.delta = 0; // time = 0; // ovf_count = 0; //} PORTE.OUTTGL = 0x02; } else { ovf_count++; } } PORTE.OUTCLR = 0x01; }