mbed code for Farrari board
Dependencies: DDRO_Farrari mbed
Fork of DDRO_Farrari by
power.cpp
00001 #include "dac.h" 00002 #include "power.h" 00003 00004 using namespace std; 00005 00006 #define INA_GAIN 200 00007 /* 00008 float current_meas(bool core) 00009 { 00010 float ampv = meas_amp * 3.3; 00011 float vdrop = ampv / INA_GAIN; 00012 float res = 1; 00013 if(core){ 00014 res = 0.25; 00015 } 00016 return vdrop / res; 00017 } 00018 */ 00019 00020 00021 void power_core(float core_volt) 00022 { 00023 float periph_volt = core_volt; 00024 float mem_volt = periph_volt; 00025 if(core_volt > 1){ 00026 periph_volt = 1; 00027 core_volt = 1; 00028 mem_volt = 1; 00029 } 00030 if(core_volt < 0.9){ 00031 periph_volt = 0.9; 00032 } 00033 if(core_volt < 0.8){ 00034 mem_volt = core_volt + 0.05; 00035 } 00036 power_chan(PADVDD, periph_volt); 00037 wait(POWER_UP_TIME); 00038 00039 // Core and Memory 00040 power_chan(COREVDD, core_volt); 00041 wait(POWER_UP_TIME); 00042 power_chan(MEM1VDD, mem_volt); 00043 wait(POWER_UP_TIME); 00044 power_chan(MEM2VDD, mem_volt); 00045 wait(POWER_UP_TIME); 00046 00047 // Clock 00048 power_chan(CLOCKVDD, periph_volt); 00049 wait(POWER_UP_TIME); 00050 power_chan(PLLAVDD, periph_volt); 00051 wait(POWER_UP_TIME); 00052 00053 // Sensor 00054 power_chan(SENSORVDD, core_volt);//power_chan(SENSORVDD, 1.0); 00055 wait(POWER_UP_TIME); 00056 power_chan(SENSORLOWVDD, 0.35); 00057 wait(POWER_UP_TIME); 00058 power_chan(SENSORSTRESSVDD, periph_volt);//power_chan(SENSORSTRESSVDD, 1.0); 00059 wait(POWER_UP_TIME); 00060 } 00061 00062 00063 void power_up(float core_volt) 00064 { 00065 // The 1.8V supplies MUST be up whenever the 3.3V ones are 00066 power_chan(ADVDD2, 1.8); 00067 wait(POWER_UP_TIME); 00068 power_chan(DVDD2, 1.8); 00069 wait(POWER_UP_TIME); 00070 00071 float periph_volt = core_volt; 00072 00073 00074 if(core_volt > 1){ 00075 periph_volt = 1; 00076 core_volt = 1; 00077 } 00078 if(core_volt < 0.95){ 00079 periph_volt = 0.95; 00080 } 00081 00082 float mem_volt = periph_volt; 00083 00084 // Other padring 00085 power_chan(ADVDD, 3.3); 00086 wait(POWER_UP_TIME); 00087 power_chan(DVDD, 3.3); 00088 wait(POWER_UP_TIME); 00089 power_chan(PADVDD, 1.0);//power_chan(PADVDD, 1.0); 00090 wait(POWER_UP_TIME); 00091 00092 // Core and Memory 00093 power_chan(COREVDD, core_volt); 00094 wait(POWER_UP_TIME); 00095 power_chan(MEM1VDD, mem_volt);//power_chan(MEM1VDD, 1.0); 00096 wait(POWER_UP_TIME); 00097 power_chan(MEM2VDD, mem_volt);//power_chan(MEM2VDD, 1.0); 00098 wait(POWER_UP_TIME); 00099 00100 // Clock 00101 power_chan(CLOCKVDD, periph_volt);//power_chan(CLOCKVDD, 1.0); 00102 wait(POWER_UP_TIME); 00103 power_chan(PLLAVDD, 1.0);//power_chan(PLLAVDD, 1.0); 00104 wait(POWER_UP_TIME); 00105 power_chan(RING_OSC_NBIAS, 0.75); 00106 wait(POWER_UP_TIME); 00107 00108 // Sensor Supplies 00109 power_chan(SENSORVDD, core_volt);//power_chan(SENSORVDD, 1.0); 00110 wait(POWER_UP_TIME); 00111 power_chan(SENSORLOWVDD, 0.35); 00112 wait(POWER_UP_TIME); 00113 power_chan(SENSORSTRESSVDD, 1.0);//power_chan(SENSORSTRESSVDD, 1.0); 00114 wait(POWER_UP_TIME); 00115 00116 power_indicator = 1; 00117 } 00118 00119 void power_down() 00120 { 00121 00122 // Zero/float all inputs, so they are not above DVDD when you lower it 00123 PORESETn = 0; 00124 CORERESETn = 0; 00125 GPIO1.input(); 00126 GPIO2.input(); 00127 GPIO3.input(); 00128 TCK = 0; 00129 TMS = 0; 00130 TDI = 0; 00131 scan_data_in = 0; 00132 scan_phi = 0; 00133 scan_phi_bar = 0; 00134 scan_load_chain = 0; 00135 scan_load_chip = 0; 00136 00137 // Core and Memory 00138 power_chan(COREVDD, 0); 00139 wait(POWER_UP_TIME); 00140 power_chan(MEM1VDD, 0); 00141 wait(POWER_UP_TIME); 00142 power_chan(MEM2VDD, 0); 00143 wait(POWER_UP_TIME); 00144 00145 // Clock 00146 power_chan(CLOCKVDD, 0); 00147 wait(POWER_UP_TIME); 00148 power_chan(PLLAVDD, 0); 00149 wait(POWER_UP_TIME); 00150 power_chan(RING_OSC_NBIAS, 0); 00151 wait(POWER_UP_TIME); 00152 00153 // Sensor Supplies 00154 power_chan(SENSORVDD, 0); 00155 wait(POWER_UP_TIME); 00156 power_chan(SENSORLOWVDD, 0); 00157 wait(POWER_UP_TIME); 00158 power_chan(SENSORSTRESSVDD, 0); 00159 wait(POWER_UP_TIME); 00160 00161 // Other padring 00162 power_chan(ADVDD, 0); 00163 wait(POWER_UP_TIME); 00164 power_chan(DVDD, 0); 00165 wait(POWER_UP_TIME); 00166 power_chan(PADVDD, 0); 00167 wait(POWER_UP_TIME); 00168 00169 // The 1.8V supplies MUST be up whenever the 3.3V ones are 00170 power_chan(ADVDD2, 0); 00171 wait(POWER_UP_TIME); 00172 power_chan(DVDD2, 0); 00173 wait(POWER_UP_TIME); 00174 00175 power_indicator = 0; 00176 }
Generated on Wed Jul 27 2022 00:15:18 by
1.7.2
