?? tlc5615.c
字號:
#include "avr/io.h"
#include "spi.h"
#include "util/delay.h"
#define MAX 1023
#define MIN 0
#define DA_CS_SET() PORTA|= (1<<PA2)
#define DA_CS_RESET() PORTA&=~(1<<PA2)
#define RTC_CE_SET() PORTC|= (1<<PC7)
#define RTC_CE_RESET() PORTC&=~(1<<PC7)
void DA_Convert(unsigned int DAVal)
{
DA_CS_RESET();
SPI_RW((DAVal>>6)&0xFF);
SPI_RW((DAVal<<2)&0xFF);
DA_CS_SET();
}
int main(void)
{
int i=0;
/* Set LED and Smg LE pin as output , databus as output */
DDRA |=(1<<PA4)|(1<<PA5)|(1<<PA6);
DDRB = 0xFF;
/* Off the Smg display */
PORTA|= (1<<PA5);
PORTB = 0x00;
PORTA&=~(1<<PA5);
/* Off the LED display */
PORTA|= (1<<PA6);
PORTB = 0xFF;
PORTA&=~(1<<PA6);
DDRA |= (1<<PA2);
DDRC |= (1<<PC7);
RTC_CE_RESET();
SPI_Init();
while(1)
{
for(i=0;i<MAX;i+=8)
DA_Convert(i);
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -