init_sys.c

来自「ks0108 avr单片机1284显示」· C语言 代码 · 共 72 行

C
72
字号
/*----------------------------------------------------------------------------*-
   
   Source Name   :  Init_SYS.C (v1.00)  

  ---------------------------------------------------------------------------- 
   COPYRIGHT 
   ---------	

   Created Date  :  2008.03.01
   Created By    :  HOCHIEN
   Modified By   :
   Modified Date :
   Version       :  2.0  
   Description   :  Global system initialization source files. 
   
   * * * This program is from : www.ICEworksop.com * * *

-*----------------------------------------------------------------------------*/

#include "Main.H"
#include "Init_SYS.H"

// ------ Private function prototypes ----------------------------------------

static void Port_Init(void);

/*----------------------------------------------------------------------------*-

   Port_Init() 
   
   Globally set up all the port pins to a certain state. 

-*----------------------------------------------------------------------------*/
static void Port_Init(void)
   {
   PORTA = 0x00;
   DDRA  = 0x00;
   PORTB = 0x00;
   DDRB  = 0x00;
   PORTC = 0x00;
   DDRC  = 0x00;
   PORTD = 0x00;
   DDRD  = 0x00;
   }

/*----------------------------------------------------------------------------*-

   Init_System()
   
   System initialization function.
   Call this routine to initialize all peripherals 

-*----------------------------------------------------------------------------*/  
void Init_System(void)
   {
   OSCCAL = 0xA7; // Calibrate internal RC 1MHz
   
   // Stop errant interrupts until set up
   CLI(); // Disable all interrupts
   
   Port_Init(); // Set port
   
   MCUCR = 0x00;
   GICR  = 0x00;
   TIMSK = 0x00; // Timer interrupt sources
   SEI(); // Re-enable interrupts
   // All peripherals are now initialized
   } 

/*----------------------------------------------------------------------------*-
  ---- END OF FILE -----------------------------------------------------------
-*----------------------------------------------------------------------------*/

⌨️ 快捷键说明

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