⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d_power.r

📁 乐高机器人的源码,开发平台是IAR_for_AVR.
💻 R
字号:
//
// Programmer      
//
// Date init       14.12.2004
//
// Reviser         $Author:: Dktochpe                                        $
//
// Revision date   $Date:: 2-09-05 14:37                                     $
//
// Filename        $Workfile:: d_power.r                                     $
//
// Version         $Revision:: 8                                             $
//
// Archive         $Archive:: /LMS2006/Sys01/Ioctrl/Firmware/Source/d_power. $
//
// Platform        C
//

#ifdef    ATMEGAX8

#define   POWERInit                     {\
                                          PORTC      &= ~0x04;\
                                          DDRC       &= ~0x04;\
                                          DIDR0      |=  0x04;\
                                        }

#define   POWEROff                      {\
                                          PORTD &= ~0x10;\
                                          DDRD  |=  0x10;\
                                        }
                                        
#define   POWEROn                       {\
                                          PORTD |=  0x10;\
                                          DDRD  |=  0x10;\
                                        }

#define   POWERSelect                   {\
                                          PORTD |=  0x04;\
                                          DDRD  |=  0x04;\
                                        }

#define   POWERConvert(V)               {\
                                          ADMUX    =  0x42;\
                                          ADCSRA  &= ~0x07;\
                                          ADCSRA  |=  0x05;\
                                          ADCSRA  |=  0x40;\
                                          while ((ADCSRA & 0x40));\
                                          ADCSRA  |=  0x40;\
                                          while ((ADCSRA & 0x40));\
                                          V        = ADC;\
                                          V       &= 0x7FFF;\
                                          IoFromAvr.Battery &= 0x8000;\
                                          IoFromAvr.Battery |= V;\
                                        }

#define   POWERDeselect                 {\
                                          PORTD &= ~0x04;\
                                          DDRD  |=  0x04;\
                                        }

#define   POWERHigh                     {\
                                          PORTC |=  0x04;\
                                          DDRC  |=  0x04;\
                                        }

#define   POWERFloat                    {\
                                          PORTC &= ~0x04;\
                                          DDRC  &= ~0x04;\
                                        }



#define   POWERExit                     {\
                                          POWEROff;\
                                          POWERDeselect;\
                                          POWERConvert(ADC);\
                                        }

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -