// // main.cpp // blinky // // Created by NXP, modified by Taylor Trimble // Copyright (c) 2013 Taylor Trimble. All rights reserved. // #ifdef __USE_CMSIS #include "LPC177x_8x.h" #endif // Variable to store CRP value in. Will be placed automatically by the linker when "Enable Code Read Protect" selected. #include <cr_section_macros.h> #include <NXP/crp.h> __CRP extern const unsigned int CRP_WORD = CRP_NO_CRP ; #include "board.h" #include <stdio.h> #include "../../ribsy/include/pt.h" // ============================================================================= // Globals // ============================================================================= // ============================================================================= // Threads // ============================================================================= // ============================================================================= // main // ============================================================================= static int Event; static int DriveEvents(struct pt *pt) { PT_BEGIN(pt); Event = Board_UARTGetChar(); if (Event != EOF) { Board_UARTPutChar(Event); } PT_END(pt); } static int A(struct pt *pt) { PT_BEGIN(pt); PT_WAIT_UNTIL(pt, Event == 'a'); Board_UARTPutSTR("AAAHH!\r\n"); PT_END(pt); } static struct pt pt1, pt2; void Setup() { // General board initialization Board_Init(); // Serial debug Board_Debug_Init(); // Initialize protothreads PT_INIT(&pt1); PT_INIT(&pt2); } int main(void) { Setup(); Board_UARTPutSTR("Ready; let's do this.\r\n"); while(1) { DriveEvents(&pt1); A(&pt2); } } |
PT_WAIT_UNTIL |
Board_* |