32 #if defined(CONFIG_AVR_SPI_AVAILABLE) && defined(CONFIG_AVR_SPI_ENABLE) 36 #define PORT_SPI PORTB 39 #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) 51 #define SPI_CLOCK_MASK 0x03 52 #define SPI_2XCLOCK_MASK 0x01 56 static void ssd1306_spiConfigure_avr()
59 uint32_t clockSetting = F_CPU / 2;
75 DDR_SPI &= ~((1<<DD_SCK)|(1<<DD_SS)|(1<<DD_MOSI));
76 PORT_SPI |= (1<<DD_SS);
78 DDR_SPI |= ((1<<DD_MOSI)|(1<<DD_SCK)|(1<<DD_SS));
79 PORT_SPI |= (1<<DD_SS);
81 SPCR = (1<<SPE)|(1<<MSTR)|(0<<CPOL)|(0<<CPHA)|
82 ((clockDiv >> 1) & SPI_CLOCK_MASK);
83 SPSR = clockDiv & SPI_2XCLOCK_MASK;
88 static void ssd1306_spiClose_avr()
92 static void ssd1306_spiStart_avr()
100 static void ssd1306_spiSendByte_avr(uint8_t data)
104 while((SPSR & (1<<SPIF))==0);
107 static void ssd1306_spiSendBytes_avr(
const uint8_t * buffer, uint16_t size)
113 while((SPSR & (1<<SPIF))==0);
119 static void ssd1306_spiStop_avr()
124 ssd1306_spiSendByte_avr( 0x00 );
135 if (cesPin >=0) pinMode(cesPin, OUTPUT);
136 if (dcPin >= 0) pinMode(dcPin, OUTPUT);
140 ssd1306_spiConfigure_avr();
void(* send)(uint8_t data)
uint32_t s_ssd1306_spi_clock
void ssd1306_spiInit_avr(int8_t cesPin, int8_t dcPin)
void(* close)(void)
deinitializes internal resources, allocated for interface.
ssd1306_lcd_t ssd1306_lcd
ssd1306_interface_t ssd1306_intf
void(* send_buffer)(const uint8_t *buffer, uint16_t size)
Sends bytes to SSD1306 device.