Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 #include "mbed.h"
nexpaq 0:6c56fb4bc5f0 2 #include "test_env.h"
nexpaq 0:6c56fb4bc5f0 3
nexpaq 0:6c56fb4bc5f0 4 void print_char(char c = '*')
nexpaq 0:6c56fb4bc5f0 5 {
nexpaq 0:6c56fb4bc5f0 6 printf("%c", c);
nexpaq 0:6c56fb4bc5f0 7 fflush(stdout);
nexpaq 0:6c56fb4bc5f0 8 }
nexpaq 0:6c56fb4bc5f0 9
nexpaq 0:6c56fb4bc5f0 10 Ticker flipper_1;
nexpaq 0:6c56fb4bc5f0 11 DigitalOut led1(LED1);
nexpaq 0:6c56fb4bc5f0 12
nexpaq 0:6c56fb4bc5f0 13 void flip_1() {
nexpaq 0:6c56fb4bc5f0 14 static int led1_state = 0;
nexpaq 0:6c56fb4bc5f0 15 if (led1_state) {
nexpaq 0:6c56fb4bc5f0 16 led1 = 0; led1_state = 0;
nexpaq 0:6c56fb4bc5f0 17 } else {
nexpaq 0:6c56fb4bc5f0 18 led1 = 1; led1_state = 1;
nexpaq 0:6c56fb4bc5f0 19 }
nexpaq 0:6c56fb4bc5f0 20 print_char();
nexpaq 0:6c56fb4bc5f0 21 }
nexpaq 0:6c56fb4bc5f0 22
nexpaq 0:6c56fb4bc5f0 23 Ticker flipper_2;
nexpaq 0:6c56fb4bc5f0 24 DigitalOut led2(LED2);
nexpaq 0:6c56fb4bc5f0 25
nexpaq 0:6c56fb4bc5f0 26 void flip_2() {
nexpaq 0:6c56fb4bc5f0 27 static int led2_state = 0;
nexpaq 0:6c56fb4bc5f0 28 if (led2_state) {
nexpaq 0:6c56fb4bc5f0 29 led2 = 0; led2_state = 0;
nexpaq 0:6c56fb4bc5f0 30 } else {
nexpaq 0:6c56fb4bc5f0 31 led2 = 1; led2_state = 1;
nexpaq 0:6c56fb4bc5f0 32 }
nexpaq 0:6c56fb4bc5f0 33 }
nexpaq 0:6c56fb4bc5f0 34
nexpaq 0:6c56fb4bc5f0 35 int main() {
nexpaq 0:6c56fb4bc5f0 36 MBED_HOSTTEST_TIMEOUT(15);
nexpaq 0:6c56fb4bc5f0 37 MBED_HOSTTEST_SELECT(wait_us_auto);
nexpaq 0:6c56fb4bc5f0 38 MBED_HOSTTEST_DESCRIPTION(Ticker Int);
nexpaq 0:6c56fb4bc5f0 39 MBED_HOSTTEST_START("MBED_11");
nexpaq 0:6c56fb4bc5f0 40
nexpaq 0:6c56fb4bc5f0 41 led1 = 0;
nexpaq 0:6c56fb4bc5f0 42 led2 = 0;
nexpaq 0:6c56fb4bc5f0 43 flipper_1.attach(&flip_1, 1.0); // the address of the function to be attached (flip) and the interval (1 second)
nexpaq 0:6c56fb4bc5f0 44 flipper_2.attach(&flip_2, 2.0); // the address of the function to be attached (flip) and the interval (2 seconds)
nexpaq 0:6c56fb4bc5f0 45
nexpaq 0:6c56fb4bc5f0 46 while (true) {
nexpaq 0:6c56fb4bc5f0 47 wait(1.0);
nexpaq 0:6c56fb4bc5f0 48 }
nexpaq 0:6c56fb4bc5f0 49 }