Simple mbed OS 5 test application for X-NUCLEO-OUT01A1 Industrial Digital output expansion board.
Dependencies: X_NUCLEO_OUT1A1
main.cpp
00001 00002 #include "XNucleoOUT01A1.h" 00003 00004 XNucleoOUT01A1 *out01a1; 00005 DigitalOut led1(LED1); 00006 00007 // main() runs in its own thread in the OS 00008 int main() { 00009 00010 printf("X-NUCLEO-OUT01A1 simple test application\n\r"); 00011 00012 00013 00014 /* Default Nucleos pinout, change accordingly on other platforms */ 00015 out01a1 = new XNucleoOUT01A1(mode_direct, NC, A3, A4, A5, A0, A1, NC, A2, 00016 D5, D4, D14, D15); 00017 out01a1->enable_outputs(true); 00018 00019 printf("\n\rSetting all channels on\r\n"); 00020 00021 out01a1->set_inputs(0xFF); 00022 00023 wait(3); 00024 00025 out01a1->set_inputs(0x00); 00026 00027 printf("\n\rIterating through channels in direct mode\r\n"); 00028 00029 for (int i=1; i<=8; i++) { 00030 00031 uint8_t input_mask = 0x1 << (i-1); 00032 out01a1->set_inputs(input_mask); 00033 00034 if (i == 3) { 00035 printf ("Input 3 not connected\n\r"); // pin3 not connected on Nucleo boards 00036 } else { 00037 printf("Output %d set \n\r", i); 00038 } 00039 00040 wait(1); 00041 } 00042 00043 out01a1->set_inputs(0x00); 00044 00045 out01a1->enable_outputs(false); 00046 00047 delete out01a1; 00048 00049 wait(1); 00050 00051 printf("\n\rNow iterating through channels in sync mode\r\n"); 00052 00053 /* Default Nucleos pinout, change accordingly on other platforms */ 00054 out01a1 = new XNucleoOUT01A1(mode_sync); 00055 out01a1->enable_outputs(true); 00056 00057 for (int i=1; i<=8; i++) { 00058 00059 uint8_t input_mask = 0x1 << (i-1); 00060 out01a1->set_inputs(input_mask); 00061 out01a1->update_outputs(); 00062 00063 if (i == 3) { 00064 printf ("Input 3 not connected\n\r"); // pin3 not connected on Nucleo boards 00065 } else { 00066 printf("Output %d set \n\r", i); 00067 } 00068 00069 wait(1); 00070 } 00071 00072 out01a1->enable_outputs(false); 00073 00074 printf("\n\rTest completed, now blinking the LED!!\n\r"); 00075 00076 while (true) { 00077 led1 = !led1; 00078 wait(0.5); 00079 } 00080 } 00081
Generated on Tue Jul 12 2022 17:42:00 by 1.7.2