📄 lib_apmc.c
字号:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name : lib_apmcBooster.c
//* Object : Advanced Power Management Controller Library.
//*
//* 1.0 10/10/01 HI : Creation
//*----------------------------------------------------------------------------
#include "lib_apmc.h"
#include "periph\stdc\lib_err.h"
//*----------------------------------------------------------------------------
//* Function Name : at91_clock_set_mode
//* Object : Set System Clock Mode.
//* Input Parameters : <mode> =
//* Output Parameters : none
//* Functions called : at91_error
//*----------------------------------------------------------------------------
void at91_clock_set_mode ( AT91PS_APMC pApmc, u_int mode )
{
//* Depending on the required mode
switch (mode)
{
//* Idle mode required
case PS_MODE_IDLE:
//* Write the System Clock Disable Register
pApmc->APMC_SCDR = APMC_PROC ;
break ;
//* Active all peripheral clocks
case PS_ALL_PERIPH_ACTIVE:
//* Enable all the peripheral clocks
pApmc->APMC_PCER = 0xFFFFFFFF ;
break ;
//* Desactive all peripheral clocks
case PS_ALL_PERIPH_INACTIVE:
//* Disable all the peripheral clocks
pApmc->APMC_PCDR = 0xFFFFFFFF ;
break ;
//* Unknown
default:
//* Run AT91 Library error function
at91_error (__FILE__, __LINE__) ;
}
//* EndSwitch
}
//*----------------------------------------------------------------------------
//* Function Name : at91_clock_open
//* Object : Enable the peripheral clock
//* Input Parameters : <periph_id> = peripheral identifier
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
void at91_clock_open (AT91PS_APMC pApmc, u_int periph_id )
{
//* Write the Peripheral Clock Enable Register
pApmc->APMC_PCER = (1 << periph_id) ;
}
//*----------------------------------------------------------------------------
//* Function Name : at91_clock_close
//* Object : Disable the clock of a Peripheral
//* Input Parameters : <periph_id> = peripheral identifier
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
void at91_clock_close (AT91PS_APMC pApmc, u_int periph_id )
{
//* Write the Peripheral Clock Disable Register
pApmc->APMC_PCDR = (1 << periph_id) ;
}
//*----------------------------------------------------------------------------
//* Function Name : at91_clock_get_status
//* Object : Return the Peripheral clock status
//* Input Parameters : <periph_id> = peripheral identifier
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
u_int at91_clock_get_status (AT91PS_APMC pApmc, u_int periph_id )
{
//* Return the Peripheral Clock Status Register
return ( pApmc->APMC_PCSR & (1<<periph_id) ) ;
}
#if 0
//*----------------------------------------------------------------------------
//* Function Name : at91_clock_get_pll_status
//* Object : Return the APMC Status Register
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
u_int at91_clock_get_pll_status ( AT91PS_APMC pApmc )
{
//* Return the PMC Status Register
return ( pApmc->APMC_SR ) ;
}
//*----------------------------------------------------------------------------
//* Function Name : at91_clock_generator_mode
//* Object : Set Master Clock selection, Main OSC & PLL
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
void at91_clock_generator_mode (AT91PS_APMC pApmc, u_int source, u_int mode )
{
//* Depending on the required source
switch (source)
{
//* MCK source
case APMC_MCK:
//* Write the Master Register
pApmc->APMC_MCKR = mode ;
break ;
//* PCK0 source
case APMC_PCK0:
//* Write the Pad0 Register
pApmc->APMC_PCKR[0] = mode ;
break ;
//* PCK1 source
case APMC_PCK1:
//* Write the Pad1 Register
pApmc->APMC_PCKR[1] = mode ;
break ;
//* PCK2 source
case APMC_PCK2:
//* Write the Pad2 Register
pApmc->APMC_PCKR[2] = mode ;
break ;
//* PCK3 source
case APMC_PCK3:
//* Write the Pad3 Register
pApmc->APMC_PCKR[3] = mode ;
break ;
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -