?? all_init.c
字號:
/*********************************************************************************************
* File: all_init.c
* Author: Embest z.j.zheng
* Desc: init the testable functions of the board by the usart
* History:
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/
#include "Board.h"
/*********************************************************************************************
* name: SPI_init
* func: init the SPI
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void SPI_Init(void)
{
AT91F_SPI_CfgPIO();
AT91F_SPI_CfgPMC(); // AT91F_PIOA_CfgPMC();
AT91F_SPI_Open(0);
AT91F_SPI_CfgCs(AT91C_BASE_SPI,0,(AT91C_SPI_BITS_8 | AT91C_SPI_CSAAT | AT91C_SPI_NCPHA | AT91C_SPI_SCBR));
AT91F_SPI_CfgMode(AT91C_BASE_SPI,AT91C_SPI_MSTR);
AT91F_SPI_DisableIt(AT91C_BASE_SPI,0x3f); // Disable SPI interrupt
AT91F_SPI_Enable(AT91C_BASE_SPI); // Enable SPI
}
/*********************************************************************************************
* name: adc_init
* func: adc init
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void adc_Init(void)
{
AT91F_ADC_CfgModeReg(AT91C_BASE_ADC,AT91C_ADC_TRGEN_DIS | AT91C_ADC_LOWRES_8_BIT | AT91C_ADC_SLEEP_NORMAL_MODE
| AT91C_ADC_PRESCAL | AT91C_ADC_STARTUP | AT91C_ADC_SHTIM);
AT91F_ADC_EnableChannel(AT91C_BASE_ADC,AT91C_ADC_CH4);
AT91F_ADC_StartConversion(AT91C_BASE_ADC);
}
/*********************************************************************************************
* name: pwm_Init
* func: init the pwm
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void pwm_Init(void)
{
AT91F_PWMC_CH0_CfgPIO();
AT91F_PWMC_CfgPMC();
AT91F_PWMC_InterruptDisable(AT91C_BASE_PWMC,AT91C_PWMC_CHID0); //Disable PWM Interrupt
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC,0,
(AT91C_PWMC_CPRE_MCK | AT91C_PWMC_CALG | AT91C_PWMC_CPOL | AT91C_PWMC_CPD),
AT91C_PWMC_CPRD,AT91C_PWMC_CDTY);
}
/*********************************************************************************************
* name: init_twi
* func:
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void twi_Init(void)
{
// Configure PIO controllers to periph mode, in open drain
AT91F_TWI_CfgPIO();
AT91F_PIO_CfgOpendrain(AT91C_BASE_PIOA,AT91C_PA3_TWD | AT91C_PA4_TWCK);
AT91F_TWI_CfgPMC();
AT91F_TWI_DisableIt(AT91C_BASE_TWI,-1); // Disable TWI IT
AT91F_TWI_Configure(AT91C_BASE_TWI); // Configure TWI in master mode
}
/*********************************************************************************************
* name: button_Init
* func: init the button
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void button_Init(void)
{
// configure the PIO Lines corresponding to button1 to button4
AT91F_PIO_CfgInput( AT91C_BASE_PIOA, SW_MASK ) ;
AT91F_PIO_InputFilterEnable(AT91C_BASE_PIOA,SW_MASK); // enable the input filter
AT91F_PIO_Enable(AT91C_BASE_PIOA,SW_MASK);
}
/*********************************************************************************************
* name: led_Init
* func: init the led
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_Init(void)
{
// then, we configure the PIO Lines corresponding to LED1 to LED3
// to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only.
AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, LED_MASK ) ;
// Clear the LED's. On the EB55 we must apply a "1" to turn off LEDs
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED_MASK ) ;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -