#include "stdafx.h" #include "signal.h" #include "User_Api.h" #include "PET_Type.h" #include "time.h" #include "stdio.h" static volatile sig_atomic_t keep_running = 1; static void sig_handler(int _) { (void)_; keep_running = 0; } void delay(int sec) { int ms = 1000 * sec; clock_t start_time = clock(); while (clock() < start_time + ms); } int main(void) { signal(SIGINT, sig_handler); // init portwell API PET_API_Init(); // set GPIO 1 and 2 to outputs PET_GPIO_SetPinDirection (1, 2, 0); // blink! while (keep_running) { PET_GPIO_WritePin(1, 2, 1); delay(75); PET_GPIO_WritePin(1, 2, 0); delay(100); PET_GPIO_WritePin(1, 2, 1); delay(75); PET_GPIO_WritePin(1, 2, 0); //delay(500); sleep(2); } // turn both LEDs off PET_GPIO_WritePin(1, 2, 0); // close portwell API PET_API_Uninit (); return EXIT_SUCCESS; }