int main(int argc, char** argv) { PT_setup(); // Enable multivector interrupts INTEnableSystemMultiVectoredInt(); // Initialize threads PT_INIT(&pt_cap); PT_INIT(&pt_blink); PT_INIT(&pt_cap_read) //init the display tft_init_hw(); tft_begin(); tft_fillScreen(ILI9340_BLACK); // Set orientation of the display tft_setRotation(1); // Set up pins PerPinSetup(); while(1){ PT_SCHEDULE(protothread_blink(&pt_blink)); PT_SCHEDULE(protothread_cap(&pt_cap)); PT_SCHEDULE(protothread_cap_read(&pt_cap_read)); } }
//===================== Main ======================= // void main(void) { SYSTEMConfig( SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE); ANSELA = 0; ANSELB = 0; CM1CON = 0; CM2CON = 0; PT_setup(); INTEnableSystemMultiVectoredInt(); // initialize the threads PT_INIT(&pt_blink); PT_INIT(&pt_capture); // initialize the display tft_init_hw(); tft_begin(); tft_fillScreen(ILI9340_BLACK); tft_setRotation(0); //240x320 vertical display // initialize the comparator CMP1Open(CMP_ENABLE | CMP_OUTPUT_ENABLE | CMP1_NEG_INPUT_IVREF); // initialize the timer2 OpenTimer2(T2_ON | T2_SOURCE_INT | T2_PS_1_64, 0xffffffff); // initialize the input capture, uses timer2 OpenCapture1( IC_EVERY_RISE_EDGE | IC_FEDGE_RISE | IC_INT_1CAPTURE | IC_TIMER2_SRC | IC_ON); ConfigIntCapture1(IC_INT_ON | IC_INT_PRIOR_3 | IC_INT_SUB_PRIOR_3 ); INTClearFlag(INT_IC1); // initialize the input/output I/O mPORTBSetPinsDigitalOut(BIT_3); mPORTBClearBits(BIT_3); PPSOutput(4, RPB9, C1OUT); //set up output of comparator for debugging PPSInput(3, IC1, RPB13); //Either Pin 6 or Pin 24 idk //round-robin scheduler for threads while(1) { PT_SCHEDULE(protothread_blink(&pt_blink)); PT_SCHEDULE(protothread_capture(&pt_capture)); } } //main