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.
main.cpp
00001 /** ADC Processing, Serial Comm, Timers 00002 * 00003 * @version 0.0 00004 * 00005 * @author boseji (http://m8051.blogspot.com) 00006 * 00007 * @note 00008 * Copyright (c) 2010, boseji 00009 * released under MIT license http://mbed.org/licence/mit 00010 * 00011 */ 00012 ////////////////////////////////////////////////// 00013 // Include Files 00014 #include "mbed.h" 00015 #include "PowerControl.h" 00016 #include "EthernetPowerControl.h" 00017 ////////////////////////////////////////////////// 00018 //Pin Defines 00019 DigitalOut sysled(LED1); //System Indicator 00020 DigitalOut ind1(LED2); 00021 DigitalOut ind2(LED3); 00022 DigitalOut ind3(LED4); 00023 00024 AnalogIn Sense1(p15); //Sensor 1 00025 AnalogIn Sense2(p16); //Sensor 2 00026 AnalogIn Sense3(p17); //Sensor 3 00027 AnalogIn Sense4(p19); //Sensor 4 00028 AnalogIn Sense5(p20); //Sensor 5 00029 00030 AnalogOut Voc(p18); 00031 00032 Ticker t1;//Timer 00033 00034 //Configure the PC Serial Port for CDC USB 00035 Serial pc(USBTX, USBRX); // tx, rx 00036 ////////////////////////////////////////////////// 00037 // Function Declarations 00038 void tint1( void ); 00039 ////////////////////////////////////////////////// 00040 // main Program 00041 int main() { 00042 00043 unsigned short usCurrentValue; 00044 //Power Down the Unused Ethernet PHY 00045 EMAC_Init(); 00046 PHY_EnergyDetect_Disable(); 00047 PHY_PowerDown(); 00048 00049 //Configure the Fastest Baud Rate 00050 pc.baud(115200); 00051 00052 printf("Aum Sri Ganeshay Namh !!\n"); 00053 00054 //Configure the Timer 00055 t1.attach(&tint1,0.8); 00056 00057 //Say the System is Ready to Run 00058 sysled = 1; 00059 00060 //Final Infinite Loop 00061 while (1) { 00062 usCurrentValue = (Sense1.read_u16()&0xFFF); 00063 ind3 = !ind3; 00064 wait(0.2); 00065 printf("\n ADC Val : %f Volts = %d (Decimal Reading)",(usCurrentValue*3.3/4095),usCurrentValue); 00066 } 00067 } 00068 ////////////////////////////////////////////////// 00069 // Functions 00070 00071 // Interrupt for the Timer 00072 void tint1( void ) { 00073 //printf("\n Aum "); 00074 ind2 = !ind2; 00075 00076 }
Generated on Sat Aug 6 2022 13:12:35 by
1.7.2