You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

428 lines
18 KiB

4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
  1. #include "port.h"
  2. #include "../zes8p5066lib/adc.h"
  3. #include "../zes8p5066lib/gpio.h"
  4. #include "../zes8p5066lib/pwm.h"
  5. #include "../zes8p5066lib/uart0.h"
  6. #include "pwm.h"
  7. zpwm_t g_ozonepwm;
  8. void port_init() {
  9. // LED-GPIO初始化
  10. zgpio_init_as_output(GPIO_Pin_A3 /* */, zgpio_get_default_output_config(), true);
  11. zgpio_init_as_output(GPIO_Pin_B13 /**/, zgpio_get_default_output_config(), true);
  12. zgpio_init_as_output(GPIO_Pin_A5 /* */, zgpio_get_default_output_config(), true);
  13. zgpio_init_as_output(GPIO_Pin_A6 /* */, zgpio_get_default_output_config(), true);
  14. // rgb
  15. zgpio_init_as_output(GPIO_Pin_A7 /* */, zgpio_get_default_ode_output_config(), true);
  16. zgpio_init_as_output(GPIO_Pin_A8 /* */, zgpio_get_default_ode_output_config(), true);
  17. zgpio_init_as_output(GPIO_Pin_A9 /* */, zgpio_get_default_ode_output_config(), true);
  18. //调试指示灯初始化
  19. zgpio_init_as_output(GPIO_Pin_A22 /**/, zgpio_get_default_output_config(), true);
  20. //风扇控制GPIO初始化
  21. zgpio_init_as_output(GPIO_Pin_B1 /* */, zgpio_get_default_output_config(), false);
  22. //按键GPIO初始化
  23. zgpio_init_as_input(GPIO_Pin_A11 /**/, zgpio_get_default_input_config());
  24. zgpio_init_as_input(GPIO_Pin_A16 /**/, zgpio_get_default_input_config());
  25. zgpio_init_as_input(GPIO_Pin_A13 /**/, zgpio_get_default_input_config());
  26. zgpio_init_as_input(GPIO_Pin_A12 /**/, zgpio_get_default_input_config());
  27. //串口初始化
  28. uart0_init(uart0_port_24and25, 115200);
  29. // ADC初始化
  30. adc_pin_init(GPIO_Pin_A2);
  31. adc_pin_init(GPIO_Pin_B8);
  32. adc_module_init();
  33. // PWM初始化
  34. // t16_pa4_init();
  35. // set_pwm_modbul_freq_duty2(1000,50);
  36. {
  37. g_ozonepwm.T16Nx = T16N0;
  38. g_ozonepwm.T16Nx_PREMAT = 1;
  39. //臭氧PWM控制引脚
  40. g_ozonepwm.C1Enable = true;
  41. g_ozonepwm.C1Pin = GPIO_Pin_A4;
  42. g_ozonepwm.C1PinReuseFunc = GPIO_Reuse_Func2;
  43. g_ozonepwm.C1PinIdleState = false;
  44. g_ozonepwm.C1freq = 1;
  45. g_ozonepwm.CH1_ODE = GPIO_ODE_Output_Disable;
  46. g_ozonepwm.CH1_DS = GPIO_DS_Output_Normal;
  47. g_ozonepwm.CH1_PUE = GPIO_PUE_Input_Disable;
  48. g_ozonepwm.CH1_PDE = GPIO_PUE_Input_Disable;
  49. // g_ozonepwm.C0Enable = ;
  50. // g_ozonepwm.C0Pin =
  51. // g_ozonepwm.C0PinReuseFunc =
  52. // g_ozonepwm.C0PinIdleState =
  53. // g_ozonepwm.C0freq =
  54. zpwm_init(&g_ozonepwm);
  55. zpwm_set_freq(&g_ozonepwm, 1, 1000);
  56. zpwm_set_duty(&g_ozonepwm, 1, 50);
  57. zpwm_start(&g_ozonepwm, 1);
  58. }
  59. while (true) {
  60. }
  61. }
  62. void port_ozone_pwm_set_duty(float freq, uint32_t dutyns) {
  63. zpwm_set_freq(&g_ozonepwm, 0, freq);
  64. zpwm_set_duty_ns(&g_ozonepwm, 0, dutyns);
  65. }
  66. void port_ozone_pwm_start() { zpwm_start(&g_ozonepwm, 0); }
  67. void port_ozone_pwm_stop() { zpwm_stop(&g_ozonepwm, 0); }
  68. /***********************************************************************************************************************
  69. * =======================================================GPIO======================================================== *
  70. ***********************************************************************************************************************/
  71. void port_debug_set(bool state) { GPIO_SET(A, 22, !, state); }
  72. bool port_fan_get() { return GPIO_GET(B, 1, !!); }
  73. void port_fan_set(bool state) {
  74. if (port_fan_get() == state) {
  75. return;
  76. }
  77. GPIO_SET(B, 1, !!, state);
  78. }
  79. void port_led0_set(bool state) { GPIO_SET(A, 3, !, state); }
  80. void port_led1_set(bool state) { GPIO_SET(B, 13, !, state); }
  81. void port_led2_set(bool state) { GPIO_SET(A, 5, !, state); }
  82. void port_led3_set(bool state) { GPIO_SET(A, 6, !, state); }
  83. void port_led_r_set(bool state) { GPIO_SET(A, 7, !, state); }
  84. void port_led_g_set(bool state) { GPIO_SET(A, 8, !, state); }
  85. void port_led_b_set(bool state) { GPIO_SET(A, 9, !, state); }
  86. bool port_gpio_get_timer_key_state(void) { return GPIO_GET(A, 11, !!); }
  87. bool port_gpio_get_level_key_state(void) { return GPIO_GET(A, 16, !!); }
  88. bool port_gpio_get_power_key_state(void) { return GPIO_GET(A, 12, !!); }
  89. bool port_gpio_get_interval_key_state(void) { return GPIO_GET(A, 13, !!); }
  90. bool port_led0_get_state(void) { return GPIO_GET(A, 3, !); }
  91. bool port_led1_get_state(void) { return GPIO_GET(B, 13, !); }
  92. bool port_led2_get_state(void) { return GPIO_GET(A, 5, !); }
  93. bool port_led3_get_state(void) { return GPIO_GET(A, 6, !); }
  94. /***********************************************************************************************************************
  95. * ========================================================ADC======================================================== *
  96. ***********************************************************************************************************************/
  97. float port_adc_get_fan_voltage() {
  98. float voltage = adc_get_voltage(GPIO_Pin_A2);
  99. return voltage; // u^2/R
  100. }
  101. float port_adc_get_ozone_generator_voltage() {
  102. float voltage = adc_get_voltage(GPIO_Pin_B8);
  103. return voltage; // u^2/R
  104. }
  105. float port_adc_get_fan_power() {
  106. float voltage = adc_get_voltage(GPIO_Pin_A2);
  107. /**
  108. * @brief /(1) X (12V)
  109. */
  110. return voltage / 1 * 12; // RU/R * fanU
  111. }
  112. float port_adc_get_ozone_generator_power() {
  113. float voltage = adc_get_voltage(GPIO_Pin_B8);
  114. return voltage * voltage / 0.5; // u^2/R
  115. }
  116. #if 0
  117. /***********************************************************************************************************************
  118. * =======================================================GPIO======================================================== *
  119. ***********************************************************************************************************************/
  120. static GPIO_InitSettingType default_input_config = {
  121. default_input_config.Signal = GPIO_Pin_Signal_Digital, //
  122. default_input_config.Dir = GPIO_Direction_Input, //
  123. default_input_config.Func = GPIO_Reuse_Func0, //
  124. default_input_config.PUE = GPIO_PUE_Input_Disable, //
  125. default_input_config.PDE = GPIO_PDE_Input_Disable //
  126. };
  127. static GPIO_InitSettingType default_output_config = {
  128. default_output_config.Signal = GPIO_Pin_Signal_Digital, //
  129. default_output_config.Dir = GPIO_Direction_Output, //
  130. default_output_config.Func = GPIO_Reuse_Func0, //
  131. default_output_config.ODE = GPIO_ODE_Output_Disable, //
  132. default_output_config.DS = GPIO_DS_Output_Normal, //
  133. default_output_config.PUE = GPIO_PUE_Input_Disable, //
  134. default_output_config.PDE = GPIO_PDE_Input_Enable //
  135. };
  136. // default_input_config
  137. static void zgpio_init_as_output(GPIO_Pin Pin, GPIO_InitSettingType* setting, int initvalue) {
  138. GPIO_Init(Pin, setting);
  139. GPIO_WriteBit(GPIO_Pin_A3, initvalue);
  140. }
  141. static void zgpio_init_as_input(GPIO_Pin Pin, GPIO_InitSettingType* setting) { GPIO_Init(Pin, setting); }
  142. /***********************************************************************************************************************
  143. * ========================================================ADC======================================================== *
  144. ***********************************************************************************************************************/
  145. extern void ADC_Set_CH(ADC_TYPE_CHS AdcCH);
  146. ADC_TYPE_CHS adc_get_chnum(GPIO_Pin gpiopin) {
  147. /**
  148. * @brief
  149. * :http://192.168.1.3:3000/manufacturer_eastsoft/ES8P5066_res/raw/branch/master/ES8P5066_Datasheet_C%20V1.1.pdf
  150. * Page25:1. 5. 2
  151. *
  152. * | **PIN NAME (FUNO(D))** | **FUN4(A)** |
  153. * | ------------------------- | ----------- |
  154. * | PA1 | AVREFP/AIN7 |
  155. * | PA2 | AIN8 |
  156. * | PA3 | AIN9 |
  157. * | PA4 | AIN10 |
  158. * | PA5 | AIN11 |
  159. * | PA6 | AIN12 |
  160. * | PA7 | AIN13 |
  161. * | PM | AIN14 |
  162. * | PA9 | AIN15 |
  163. * | PA10 | |
  164. * | PA11 | AIN1 |
  165. * | PAl2 | AIN2 |
  166. * | PA13 | AIN6 |
  167. * | PA14(ISCK) | AIN16 |
  168. * | PA15(ISDA) | AIN17 |
  169. * | PA16 | |
  170. * | PA22 | |
  171. * | PA23 | |
  172. * | PA24 | AIN19 |
  173. * | PA25 | |
  174. * | PA27 | |
  175. * | PA28 | |
  176. * | PBO | |
  177. * | PB1 | |
  178. * | PB8 | AIN3 |
  179. * | PB9 | AIN4 |
  180. * | PB10 | OSCI |
  181. * | PB11 | OSCO |
  182. * | PB12(MRSTN) | AIN0 |
  183. * | PB13 | AIN5 |
  184. */
  185. if (gpiopin == GPIO_Pin_A1 /* */) return ADC_CHS_AIN7;
  186. if (gpiopin == GPIO_Pin_A2 /* */) return ADC_CHS_AIN8;
  187. if (gpiopin == GPIO_Pin_A3 /* */) return ADC_CHS_AIN9;
  188. if (gpiopin == GPIO_Pin_A4 /* */) return ADC_CHS_AIN10;
  189. if (gpiopin == GPIO_Pin_A5 /* */) return ADC_CHS_AIN11;
  190. if (gpiopin == GPIO_Pin_A6 /* */) return ADC_CHS_AIN12;
  191. if (gpiopin == GPIO_Pin_A7 /* */) return ADC_CHS_AIN13;
  192. if (gpiopin == GPIO_Pin_A14 /**/) return ADC_CHS_AIN14;
  193. if (gpiopin == GPIO_Pin_A9 /* */) return ADC_CHS_AIN15;
  194. if (gpiopin == GPIO_Pin_A11 /**/) return ADC_CHS_AIN1;
  195. if (gpiopin == GPIO_Pin_A12 /**/) return ADC_CHS_AIN2;
  196. if (gpiopin == GPIO_Pin_A13 /**/) return ADC_CHS_AIN6;
  197. if (gpiopin == GPIO_Pin_A14 /**/) return ADC_CHS_AIN16;
  198. if (gpiopin == GPIO_Pin_A15 /**/) return ADC_CHS_AIN17;
  199. if (gpiopin == GPIO_Pin_A24 /**/) return ADC_CHS_AIN19;
  200. if (gpiopin == GPIO_Pin_B8 /* */) return ADC_CHS_AIN3;
  201. if (gpiopin == GPIO_Pin_B9 /* */) return ADC_CHS_AIN4;
  202. if (gpiopin == GPIO_Pin_B12 /**/) return ADC_CHS_AIN0;
  203. if (gpiopin == GPIO_Pin_B13 /**/) return ADC_CHS_AIN5;
  204. ZASSERT(0);
  205. return (ADC_TYPE_CHS)-1;
  206. }
  207. uint32_t adc_get_value(ADC_TYPE_CHS adc_ch) {
  208. ADC_Set_CH(adc_ch);
  209. ADC_SoftStart();
  210. port_delay_ms(1);
  211. ADC_SoftStop();
  212. while (ADC_GetIFStatus(ADC_IF) == RESET)
  213. ;
  214. uint32_t adcv = ADC_GetConvValue();
  215. ADC_ClearIFStatus(ADC_IF);
  216. return adcv;
  217. }
  218. /***********************************************************************************************************************
  219. * =======================================================UART======================================================== *
  220. ***********************************************************************************************************************/
  221. // 1、keil勾选Use MicroLIB 2、IAR/keil #define __PRINTF_USE_UART0__
  222. void uart0_init(void) {
  223. /**
  224. * @brief 0115200
  225. * Fpclk
  226. */
  227. GPIO_InitSettingType InitSet;
  228. InitSet.Dir = GPIO_Direction_Output;
  229. InitSet.DS = GPIO_DS_Output_Strong;
  230. InitSet.Func = GPIO_Reuse_Func2;
  231. InitSet.ODE = GPIO_ODE_Output_Disable;
  232. InitSet.PDE = GPIO_PDE_Input_Disable;
  233. InitSet.PUE = GPIO_PUE_Input_Enable;
  234. InitSet.Signal = GPIO_Pin_Signal_Digital;
  235. GPIO_Init(UART0_TXD0_PIN, &InitSet);
  236. InitSet.Dir = GPIO_Direction_Input;
  237. InitSet.DS = GPIO_DS_Output_Strong;
  238. InitSet.Func = GPIO_Reuse_Func2;
  239. InitSet.ODE = GPIO_ODE_Output_Disable;
  240. InitSet.PDE = GPIO_PDE_Input_Disable;
  241. InitSet.PUE = GPIO_PUE_Input_Disable;
  242. InitSet.Signal = GPIO_Pin_Signal_Digital;
  243. GPIO_Init(UART0_RXD0_PIN, &InitSet);
  244. UART_InitStruType UART_InitStruct;
  245. UART_InitStruct.UART_BaudRate = 115200; //波特率
  246. UART_InitStruct.UART_ClockSet = UART_Clock_1; //时钟选择不分频
  247. UART_InitStruct.UART_RxMode = UART_DataMode_8; // 8数据位无奇偶校验位
  248. //标准极性端口数据和传输数据相同
  249. UART_InitStruct.UART_RxPolar = UART_Polar_Normal;
  250. UART_InitStruct.UART_StopBits = UART_StopBits_1; //一个停止位
  251. UART_InitStruct.UART_TxMode = UART_DataMode_8; // 8数据位无奇偶校验位
  252. UART_InitStruct.UART_TxPolar = UART_Polar_Normal; //标准usart极性
  253. UART_Init(UART0, &UART_InitStruct);
  254. UART_ITConfig(UART0, UART_IT_RB, Enable); /* UART0接收中断使能 */
  255. /* UART0发送缓冲区空中断模式: 全空中断 */
  256. UART_TBIMConfig(UART0, UART_TBIM_Byte);
  257. UART_ClearITPendingBit(UART0, UART_FLAG_TB);
  258. UART_ClearITPendingBit(UART0, UART_FLAG_RB);
  259. UART_ClearITPendingBit(UART0, UART_FLAG_FE);
  260. NVIC_Init(NVIC_UART0_IRQn, NVIC_Priority_1, Enable); //使能串口0中断
  261. UART0_TxEnable();
  262. UART0_RxEnable();
  263. }
  264. /***********************************************************************************************************************
  265. * =======================================================PORT-GPIO======================================================== *
  266. ***********************************************************************************************************************/
  267. void port_unused_gpio_init(void) {
  268. /**
  269. * @brief
  270. * http://192.168.1.3:3000/manufacturer_eastsoft/ES8P5066_res/raw/branch/master/AN142_应用笔记_ES8P5066%20V1.0.pdf
  271. * Page8:1. 13 使GPIO端口处理
  272. * 使 GPIO
  273. *
  274. */
  275. // GPIO_InitSettingType x;
  276. // x.Signal = GPIO_Pin_Signal_Digital;
  277. // x.Dir = GPIO_Direction_Output; //输出模式
  278. // x.Func = GPIO_Reuse_Func0;
  279. // x.ODE = GPIO_ODE_Output_Disable;
  280. // x.DS = GPIO_DS_Output_Normal;
  281. // x.PUE = GPIO_PUE_Input_Disable;
  282. // x.PDE = GPIO_PDE_Input_Enable;
  283. // GPIO_Init(GPIO_Pin_A10, &x);
  284. // GPIO_Init(GPIO_Pin_A23, &x);
  285. // GPIO_Init(GPIO_Pin_A27, &x); // 自己原理图上是26
  286. // GPIO_Init(GPIO_Pin_A28, &x); // 自己原理图上是27
  287. // GPIO_Init(GPIO_Pin_B0, &x);
  288. // //三个adc
  289. // GPIO_Init(GPIO_Pin_B8, &x);
  290. // GPIO_Init(GPIO_Pin_B9, &x);
  291. // GPIO_Init(GPIO_Pin_A2, &x);
  292. // GPIO_WriteBit(GPIO_Pin_A10, 0);
  293. // GPIO_WriteBit(GPIO_Pin_A23, 0);
  294. // GPIO_WriteBit(GPIO_Pin_A27, 0);
  295. // GPIO_WriteBit(GPIO_Pin_A28, 0);
  296. // GPIO_WriteBit(GPIO_Pin_B0, 0);
  297. // GPIO_WriteBit(GPIO_Pin_B8, 0);
  298. // GPIO_WriteBit(GPIO_Pin_B9, 0);
  299. // GPIO_WriteBit(GPIO_Pin_A2, 0);
  300. }
  301. void port_gpio_init(void) {
  302. // LED-GPIO初始化
  303. zgpio_init_as_output(GPIO_Pin_A3 /* */, &default_output_config, 0);
  304. zgpio_init_as_output(GPIO_Pin_B13 /**/, &default_output_config, 0);
  305. zgpio_init_as_output(GPIO_Pin_A5 /* */, &default_output_config, 0);
  306. zgpio_init_as_output(GPIO_Pin_A6 /* */, &default_output_config, 0);
  307. zgpio_init_as_output(GPIO_Pin_A7 /* */, &default_output_config, 0);
  308. zgpio_init_as_output(GPIO_Pin_A8 /* */, &default_output_config, 0);
  309. zgpio_init_as_output(GPIO_Pin_A9 /* */, &default_output_config, 0);
  310. //调试指示灯初始化
  311. zgpio_init_as_output(GPIO_Pin_A22 /**/, &default_output_config, 0);
  312. //风扇控制GPIO初始化
  313. zgpio_init_as_output(GPIO_Pin_B1 /* */, &default_output_config, 0);
  314. //按键GPIO初始化
  315. zgpio_init_as_input(GPIO_Pin_A11 /**/, &default_input_config);
  316. zgpio_init_as_input(GPIO_Pin_A16 /**/, &default_input_config);
  317. zgpio_init_as_input(GPIO_Pin_A13 /**/, &default_input_config);
  318. zgpio_init_as_input(GPIO_Pin_A12 /**/, &default_input_config);
  319. }
  320. void port_debug_set(bool state) { GPIO_SET(A, 22, !, state); }
  321. bool port_fan_get() { return GPIO_GET(B, 1, !!); }
  322. void port_fan_set(bool state) {
  323. if (port_fan_get() == state) {
  324. return;
  325. }
  326. GPIO_SET(B, 1, !!, state);
  327. }
  328. void port_led0_set(bool state) { GPIO_SET(A, 3, !, state); }
  329. void port_led1_set(bool state) { GPIO_SET(B, 13, !, state); }
  330. void port_led2_set(bool state) { GPIO_SET(A, 5, !, state); }
  331. void port_led3_set(bool state) { GPIO_SET(A, 6, !, state); }
  332. void port_led_r_set(bool state) { GPIO_SET(A, 7, !, state); }
  333. void port_led_g_set(bool state) { GPIO_SET(A, 8, !, state); }
  334. void port_led_b_set(bool state) { GPIO_SET(A, 9, !, state); }
  335. bool port_gpio_get_timer_key_state(void) { return GPIO_GET(A, 11, !!); }
  336. bool port_gpio_get_level_key_state(void) { return GPIO_GET(A, 16, !!); }
  337. bool port_gpio_get_power_key_state(void) { return GPIO_GET(A, 12, !!); }
  338. bool port_gpio_get_interval_key_state(void) { return GPIO_GET(A, 13, !!); }
  339. bool port_led0_get_state(void) { return GPIO_GET(A, 3, !); }
  340. bool port_led1_get_state(void) { return GPIO_GET(B, 13, !); }
  341. bool port_led2_get_state(void) { return GPIO_GET(A, 5, !); }
  342. bool port_led3_get_state(void) { return GPIO_GET(A, 6, !); }
  343. /***********************************************************************************************************************
  344. * =====================================================PORT-ADC====================================================== *
  345. ***********************************************************************************************************************/
  346. void ADCInit(void) {}
  347. static void adcinit() {
  348. // ADC_GPIO_INIT
  349. {
  350. GPIO_InitSettingType y;
  351. y.Signal = GPIO_Pin_Signal_Analog;
  352. y.Dir = GPIO_Direction_Input;
  353. y.Func = GPIO_Reuse_Func0;
  354. GPIO_Init(GPIO_Pin_A2, &y);
  355. }
  356. {
  357. GPIO_InitSettingType y;
  358. y.Signal = GPIO_Pin_Signal_Analog;
  359. y.Dir = GPIO_Direction_Input;
  360. y.Func = GPIO_Reuse_Func0;
  361. GPIO_Init(GPIO_Pin_B8, &y);
  362. }
  363. // ADCINIT
  364. ADC_InitStruType x;
  365. x.CLKS = ADC_CLKS_PCLK;
  366. x.CLKDIV = ADC_CLKDIV_1_32; /* ADC时钟源预分频 */
  367. x.VREF_SEL = ADC_VREF_SEL_0; /* 内部参考电压2.048v,仅设置内部参考电压为多少 */
  368. x.VREFP = ADC_VREFP_VDD; /* 选择芯片的工作电压VDD,*/
  369. x.VREFN = ADC_VREFN_VSS; /* 负向参考电压选择 */
  370. x.SMPS = ADC_SMPS_SOFT; /* AD采样模式为软件控制 */
  371. x.ST = 10; /*采样时间st*2+1(个Tadclk)=1.743us AD硬件采样时间选择 */
  372. x.BITSEL = ADC_BITSEL_12; /* AD分辨率12位 */
  373. x.CHS = ADC_CHS_AIN0; /*这里使用通道零作为默认,当没有使能ADC采集时,这个通道数关系不大*/
  374. ADC_Init(&x);
  375. }
  376. float port_adc_get_fan_power() {
  377. uint32_t adcraw = adc_get_value(adc_get_chnum(GPIO_Pin_A2));
  378. float voltage = adcraw * 3.3 / 4096;
  379. return voltage * voltage / 1; // u^2/R
  380. }
  381. float port_adc_get_ozone_generator_power() {
  382. uint32_t adcv = adc_get_value(adc_get_chnum(GPIO_Pin_B8));
  383. float voltage = adcv * 3.3 / 4096;
  384. return voltage * voltage / 0.5; // u^2/R
  385. }
  386. #endif