📄 ma_io.c
字号:
/*
*****************************************************************************
**
** Project : My project
**
** Component : test (ATmega128)
**
** Modulename : I/O
**
** Filename : ma_io.c
**
** Abstract : This file implements a device driver for the I/O
** module.
**
** Compiler : IAR C compiler
**
** Date : 2005-10-21 16:57:06
**
** License no. : N/A Administrator
**
** Warning : This file has been automatically generated.
** Do not edit this file if you intend to regenerate it.
**
** This device driver was created by IAR MakeApp version
** 4.01A (Atmel megaAVR: 4.00A) for the Atmel megaAVR series of
** microcontrollers.
**
** (c)Copyright 2003 IAR Systems.
** Your rights to this file are explained in the IAR MakeApp
** License Agreement. All other rights reserved.
**
*****************************************************************************
*/
/*
**===========================================================================
** 1 GENERAL
** 1.1 Revisions
**
** Please read the IAR MakeApp for Atmel megaAVR readme file
**
**
**===========================================================================
*/
/*
**===========================================================================
** 1.2 References
**
** No Identification Name or Description
** == =================== ================================
** 1 2467G-AVR-09/02 ATmega128 Hardware Manual
**
**===========================================================================
*/
/*
**===========================================================================
** 2. INCLUDE FILES
** 2.1 Standard include files
**===========================================================================
*/
/*
**===========================================================================
** 2.2 Application include files
**===========================================================================
*/
//#include "usercode.h" /* Usercode macros (see <template.h>) */
#include "ma_tgt.h" /* Target specific header file */
#include "iom128.h" /* Internal registers */
#include "ma_io.h" /* Module driver header file */
/*
**===========================================================================
** 3. DECLARATIONS
** 3.1 Internal constants
**===========================================================================
*/
#define MA_DDRE_IO 0x00 /* Port E data direction register */
#define MA_DDRE_IO_MASK 0xFF /* Used bits */
#define MA_PORTE_IO 0x00 /* Port E data register */
#define MA_PORTE_IO_MASK 0xFF /* Used bits */
#define MA_DDRD_IO 0x00 /* Port D data direction register */
#define MA_DDRD_IO_MASK 0xFF /* Used bits */
#define MA_PORTD_IO 0x00 /* Port D data register */
#define MA_PORTD_IO_MASK 0xFF /* Used bits */
#define MA_DDRC_IO 0x00 /* Port C data direction register */
#define MA_DDRC_IO_MASK 0xFF /* Used bits */
#define MA_PORTC_IO 0x00 /* Port C data register */
#define MA_PORTC_IO_MASK 0xFF /* Used bits */
#define MA_DDRB_IO 0xFF /* Port B data direction register */
#define MA_DDRB_IO_MASK 0xFF /* Used bits */
#define MA_PORTB_IO 0x00 /* Port B data register */
#define MA_PORTB_IO_MASK 0xFF /* Used bits */
#define MA_DDRA_IO 0x00 /* Port A data direction register */
#define MA_DDRA_IO_MASK 0xFF /* Used bits */
#define MA_PORTA_IO 0x00 /* Port A data register */
#define MA_PORTA_IO_MASK 0xFF /* Used bits */
#define MA_SFIOR_IO 0x00 /* Special function IO register */
#define MA_SFIOR_IO_MASK 0x9F /* Used bits */
#define MA_DDRF_IO 0x00 /* Port F data direction register */
#define MA_DDRF_IO_MASK 0xFF /* Used bits */
#define MA_PORTF_IO 0x00 /* Port F data register */
#define MA_PORTF_IO_MASK 0xFF /* Used bits */
#define MA_DDRG_IO 0x00 /* Port G data direction register */
#define MA_DDRG_IO_MASK 0x1F /* Used bits */
#define MA_PORTG_IO 0x00 /* Port G data register */
#define MA_PORTG_IO_MASK 0x1F /* Used bits */
/*
**===========================================================================
** 3.2 Internal macros
**===========================================================================
*/
/*
**===========================================================================
** 3.3 Internal type definitions
**===========================================================================
*/
/*
**===========================================================================
** 3.4 Global variables (declared as 'extern' in some header file)
**===========================================================================
*/
/*
**===========================================================================
** 3.5 Internal function prototypes (defined in Section 5)
**===========================================================================
*/
/*
**===========================================================================
** 3.6 Internal variables
**===========================================================================
*/
/*
**===========================================================================
** 4. GLOBAL FUNCTIONS (declared as 'extern' in some header file)
**===========================================================================
*/
void MA_Init_IO( void )
/*
**---------------------------------------------------------------------------
**
** Abstract:
** Initialises the I/O ports. Only sets those registers with values
** not equal to the power-on reset values.
**
** Parameters:
** None
**
** Returns:
** None
**
**---------------------------------------------------------------------------
*/
{
/*--- Handle user code on function entry ---*/
// ENTER_MA_INIT_IO;
/*--- Initialise registers ---*/
DDRB = MA_DDRB_IO;
/*--- Handle user code on function exit ---*/
// EXIT_MA_INIT_IO;
} /* MA_Init_IO */
void MA_Reset_IO( void )
/*
**---------------------------------------------------------------------------
**
** Abstract:
** Resets the I/O module. Sets all registers.
**
** Parameters:
** None
**
** Returns:
** None
**
**---------------------------------------------------------------------------
*/
{
/*--- Handle user code on function entry ---*/
// ENTER_MA_RESET_IO;
/*--- Reset registers ---*/
DDRE = MA_DDRE_IO;
PORTE = MA_PORTE_IO;
DDRD = MA_DDRD_IO;
PORTD = MA_PORTD_IO;
DDRC = MA_DDRC_IO;
PORTC = MA_PORTC_IO;
DDRB = MA_DDRB_IO;
PORTB = MA_PORTB_IO;
DDRA = MA_DDRA_IO;
PORTA = MA_PORTA_IO;
SFIOR = ( SFIOR & ~MA_SFIOR_IO_MASK ) | MA_SFIOR_IO;
DDRF = MA_DDRF_IO;
PORTF = MA_PORTF_IO;
DDRG = ( DDRG & ~MA_DDRG_IO_MASK ) | MA_DDRG_IO;
PORTG = ( PORTG & ~MA_PORTG_IO_MASK ) | MA_PORTG_IO;
/*--- Handle user code on function exit ---*/
// EXIT_MA_RESET_IO;
} /* MA_Reset_IO */
S8 MA_SetPortIn_IO( U8 Port, U8 BitMask )
/*
**---------------------------------------------------------------------------
**
** Abstract:
** Reprograms selected I/O pins as input pins.
**
** Parameters:
** Port The port to reprogram (MA_PORTA - MA_PORTG)
** BitMask Set a bit to program the corresponding pin to input
**
** Returns:
** MA_ERROR If an illegal port was given.
** MA_OK Otherwise
**
**---------------------------------------------------------------------------
*/
{
/*--- Handle user code on function entry ---*/
// ENTER_MA_SETPORTIN_IO;
/*--- Set selected pins as input pins ---*/
switch( Port )
{
case MA_PORTA:
/*--- Port A ---*/
ClrBit( DDRA, BitMask );
break;
case MA_PORTB:
/*--- Port B ---*/
ClrBit( DDRB, BitMask );
break;
case MA_PORTC:
/*--- Port C ---*/
ClrBit( DDRC, BitMask );
break;
case MA_PORTD:
/*--- Port D ---*/
ClrBit( DDRD, BitMask );
break;
case MA_PORTE:
/*--- Port E ---*/
ClrBit( DDRE, BitMask );
break;
case MA_PORTF:
/*--- Port F ---*/
ClrBit( DDRF, BitMask );
break;
case MA_PORTG:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -