?? spi.c
字號:
/*****************************************************************************
*
* Atmel Corporation
*
* File : spi.c
* Compiler : IAR EWAAVR 2.28a/3.10c
* Revision : $Revision: 1.3 $
* Date : $Date: 17. mars 2004 14:47:10 $
* Updated by : $Author: ltwa $
*
* Support mail : avr@atmel.com
*
* Supported devices : All devices with a SPI and USART module can be used.
* The example is written for the ATmega8
*
* AppNote : AVR303 - SPI-UART Gateway
*
// Author : Andy Gayne. avr@gayne.co.uk www.gd-technik.com
// Description : Based on example code from Mega8 data sheet
****************************************************************************/
void SPI_MasterInit(void)
{
// Set MOSI, SCK and SS output, all others input
DDR_SPI = (1 << P_MOSI) | (1 << P_SCK) | (1 << P_SS);
// make SS output high
PORT_SPI |= (1 << P_SS);
// Enable SPI, Master, set clock rate fck/16
SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR0);
}
char SPI_MasterTransmit(char cData)
{
// Start transmission
SPDR = cData;
// Wait for transmission complete
while(!(SPSR & (1 << SPIF)));
return (SPDR);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -