Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
AirAdaptorLib.cpp
00001 #include "SysConfig.h" 00002 00003 //On-board LED number 00004 const int LED_NUM_MAX = 3; 00005 00006 //I2C for SHT20 & BMP180 00007 I2C i2c_sen(PB_11, PB_10); 00008 00009 //USART2 to PC, USART1 to sensors & WiFi module 00010 Serial uart_pc(SERIAL_TX, SERIAL_RX); 00011 Serial uart_sen(PA_9, PA_10); 00012 00013 //LEDs on mother board and daughter board 00014 DigitalOut led_mb(LED1, 0), led_db1_n(PB_1, 1), led_db2_n(PB_2, 1); 00015 00016 //GPIO for CD4052 serial mux control 00017 DigitalOut smux_a(PB_14, 0), smux_b(PB_13, 0), smux_oe_n(PB_15, 1); 00018 00019 AnalogIn adc_ch10(PC_0), adc_ch11(PC_1); 00020 00021 00022 //Init board library 00023 //--> Success return 0 00024 int BoardLibInit(void) 00025 { 00026 //Init LED status 00027 LedOnAll(); 00028 00029 //Init debug & sensor UART 00030 uart_pc.baud(115200); 00031 uart_sen.baud(9600); 00032 00033 //Init sensor I2C 00034 i2c_sen.frequency(100000); 00035 00036 //Init serial mux chip 00037 SerialMuxDisable(); 00038 SerialMuxSel(0); 00039 00040 //Return 0 if success 00041 return 0; 00042 } 00043 00044 void SerialMuxSel(int ch) 00045 { 00046 switch(ch) 00047 { 00048 case 1: 00049 smux_a = 1; 00050 smux_b = 0; 00051 break; 00052 00053 case 2: 00054 smux_a = 0; 00055 smux_b = 1; 00056 break; 00057 00058 case 3: 00059 smux_a = 1; 00060 smux_b = 1; 00061 break; 00062 00063 00064 case 0: 00065 default: 00066 smux_a = 0; 00067 smux_b = 0; 00068 break; 00069 } 00070 } 00071 00072 void SerialMuxEnable(void) 00073 { 00074 smux_oe_n = 0; 00075 } 00076 00077 void SerialMuxDisable(void) 00078 { 00079 smux_oe_n = 0; 00080 } 00081 00082 void LedOn(int ch) 00083 { 00084 switch(ch) 00085 { 00086 case 0: 00087 led_mb = 1; 00088 break; 00089 00090 case 1: 00091 led_db1_n = 0; 00092 break; 00093 00094 case 2: 00095 led_db2_n = 0; 00096 break; 00097 00098 default: 00099 break; 00100 } 00101 } 00102 00103 void LedOff(int ch) 00104 { 00105 switch(ch) 00106 { 00107 case 0: 00108 led_mb = 0; 00109 break; 00110 00111 case 1: 00112 led_db1_n = 1; 00113 break; 00114 00115 case 2: 00116 led_db2_n = 1; 00117 break; 00118 00119 default: 00120 break; 00121 } 00122 } 00123 00124 void LedToggle(int ch) 00125 { 00126 switch(ch) 00127 { 00128 case 0: 00129 if(led_mb) 00130 led_mb = 0; 00131 else 00132 led_mb = 1; 00133 break; 00134 00135 case 1: 00136 if(led_db1_n) 00137 led_db1_n = 0; 00138 else 00139 led_db1_n = 1; 00140 break; 00141 00142 case 2: 00143 if(led_db2_n) 00144 led_db2_n = 0; 00145 else 00146 led_db2_n = 1; 00147 break; 00148 00149 default: 00150 break; 00151 } 00152 } 00153 00154 void LedOnAll(void) 00155 { 00156 for(int ledNum = 0; ledNum < LED_NUM_MAX; ledNum++) 00157 LedOn(ledNum); 00158 } 00159 00160 void LedOffAll(void) 00161 { 00162 for(int ledNum = 0; ledNum < LED_NUM_MAX; ledNum++) 00163 LedOff(ledNum); 00164 }
Generated on Fri Jul 15 2022 14:37:21 by
1.7.2