Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware SPI support for ATmega128 #415

Merged
merged 2 commits into from
May 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions csrc/u8g_com_atmega_hw_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,25 @@ uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
u8g_SetPIOutput(u8g, U8G_PI_RESET);

U8G_ATOMIC_START();

#if defined (__AVR_ATmega128__)

DDRB |= _BV(2); /* D0, MOSI */
DDRB |= _BV(1); /* SCK */
DDRB |= _BV(0); /* slave select */

PORTB &= ~_BV(2); /* D0, MOSI = 0 */
PORTB &= ~_BV(1); /* SCK = 0 */
#else

DDRB |= _BV(3); /* D0, MOSI */
DDRB |= _BV(5); /* SCK */
DDRB |= _BV(2); /* slave select */

PORTB &= ~_BV(3); /* D0, MOSI = 0 */
PORTB &= ~_BV(5); /* SCK = 0 */

#endif

U8G_ATOMIC_END();

Expand Down Expand Up @@ -136,7 +148,11 @@ uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
}
else
{
#if defined (__AVR_ATmega128__)
PORTB &= ~_BV(1); /* SCK = 0 */
#else
PORTB &= ~_BV(5); /* SCK = 0 */
#endif
/* enable */
u8g_SetPILevel(u8g, U8G_PI_CS, 0); /* CS = 0 (low active) */
}
Expand Down